Changeset 48d2bed for README.md


Ignore:
Timestamp:
09/24/26 12:09:29 (2 days ago)
Author:
MBK <marija.karapandzova@…>
Branches:
master
Parents:
ae6cd79
Message:

Remote database setup, fixed models and application properties

File:
1 edited

Legend:

Unmodified
Added
Removed
  • README.md

    rae6cd79 r48d2bed  
    3030- **Build Tool:** npm/Create React App
    3131
    32 ## 📋 Prerequisites
     32## Prerequisites
    3333
    3434Before you start, make sure you have installed:
    … …  
    3737- **Maven 3.8+** - [Download](https://maven.apache.org/download.cgi)
    3838- **Node.js 22+** - [Download](https://nodejs.org/)
    39 - **PostgreSQL 14+** - [Download](https://www.postgresql.org/download/)
     39- **PostgreSQL 14+** (if using local database) - [Download](https://www.postgresql.org/download/)
     40- **SSH Client** (for remote database access) - Built-in on Windows 10+, Mac, Linux
     41
     42## Configuration for Remote Database
     43
     44### Step 1: Setup `.env.properties` File
     45
     46Create a `.env.properties` file in the project root directory with your remote database credentials:
     47
     48```properties
     49# Remote Database Credentials (provided by your professor or administrator)
     50DB_REMOTE_NAME=your_database_name
     51DB_REMOTE_USERNAME=your_database_username
     52DB_REMOTE_PASSWORD=your_database_password
     53
     54# JWT Secret for authentication
     55JWT_SECRET=your_jwt_secret_key_min_32_characters
     56
     57# Local database password (for local profile, default is 'postgres')
     58DB_PASSWORD=postgres
     59```
     60
     61**Important Security Notes:**
     62- ⚠️ This file is in `.gitignore` and must NEVER be committed to Git
     63- ⚠️ Keep your credentials secure and do not share them
     64- ⚠️ Never upload this file to any public repository
     65
     66### Step 2: SSH Tunnel Setup (for Remote Database)
     67
     68Before starting the application, you must establish an SSH tunnel to access the remote database:
     69
     70```bash
     71# Windows (Command Prompt or PowerShell)
     72ssh -L 9999:localhost:5432 your_ssh_username@remote_server_address
     73
     74# Example:
     75ssh -L 9999:localhost:5432 t_medora@194.149.135.130
     76```
     77
     78**Important:** Keep this terminal window open while running the application. The tunnel will close if you close the terminal.
     79
     80**Expected Output:**
     81```
     82Enter password: [enter your SSH password]
     83Access granted. Press Return to begin session.
     84Local port 9999 forwarding to localhost:5432
     85```
     86
     87---
    4088
    4189##  Quick Start
    4290
    43 ### 1. Setup Database
    44 
    45 Create a PostgreSQL database for the application:
    46 
    47 ```bash
    48 createdb medora
    49 ```
    50 
    51 **Note:** The database schema and tables are automatically created by Flyway migrations and Hibernate when the backend starts.
    52 
    53 ### 2. Start Backend
    54 
    55 Navigate to the backend directory and run:
     91### Prerequisites Checklist
     92
     93Before starting the application, ensure you have:
     94
     95-  Created `.env.properties` file with your database credentials
     96-  SSH tunnel is running and connected (see Configuration section above)
     97-  Terminal window with SSH tunnel remains open
     98
     99---
     100
     101### Step 1: Start Backend (Terminal 1)
     102
     103Navigate to the project root and run:
    56104
    57105```bash
    … …  
    60108```
    61109
    62 The backend will start on `http://localhost:8080`
    63 
    64 **Wait for the message:** `Started Application in X seconds`
    65 
    66 ### 3. Start Frontend (in a new terminal)
    67 
    68 Navigate to the frontend directory and run:
     110**Expected Output:**
     111```
     112Started MedoraApplication in X seconds
     113```
     114
     115**Port:** `http://localhost:8081`
     116
     117---
     118
     119### Step 2: Start Frontend (Terminal 2)
     120
     121In a new terminal, navigate to frontend directory and run:
    69122
    70123```bash
    … …  
    74127```
    75128
    76 The frontend will open automatically on `http://localhost:3000`
     129**Expected Output:**
     130```
     131Compiled successfully!
     132You can now view medora-frontend in the browser.
     133Local: http://localhost:3001
     134```
     135
     136**Port:** `http://localhost:3001`
     137
     138---
     139
     140### Step 3: Access the Application
     141
     142Open your browser and navigate to: **http://localhost:3001**
     143
     144You should see the Medora login screen.
     145
     146---
     147
     148### ⚠️ Important: Keep These Terminals Open
     149
     150- **Terminal 0:** SSH Tunnel (must remain open)
     151- **Terminal 1:** Backend (Spring Boot)
     152- **Terminal 2:** Frontend (React)
     153
     154Close any of these and the application will stop working.
    77155
    78156##  Default Credentials & User Roles
    … …  
    137215### Backend Configuration
    138216
    139 Edit `backend/src/main/resources/application.properties`:
     217The backend is configured to use a **remote PostgreSQL database** via SSH tunnel.
     218
     219**Main Configuration File:** `backend/src/main/resources/application.properties`
    140220
    141221```properties
    142 # Database
    143 spring.datasource.url=jdbc:postgresql://localhost:5432/medora
    144 spring.datasource.username=medora_app
    145 spring.datasource.password=postgres
    146 
    147 # JWT
    148 jwt.secret=your-secret-key
     222# Application Setup
     223spring.application.name=medora
     224server.port=8081
     225spring.profiles.active=remote
     226
     227# Load environment variables from .env.properties
     228spring.config.import=optional:file:.env.properties
     229
     230# JWT Authentication
     231jwt.secret=${JWT_SECRET}
    149232jwt.expiration=86400000
    150233
    151 # Hibernate
    152 spring.jpa.hibernate.ddl-auto=update
     234# Hibernate/JPA Settings
     235spring.jpa.hibernate.ddl-auto=none
     236spring.jpa.open-in-view=true
     237spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
     238```
     239
     240**Remote Database Configuration:** `backend/src/main/resources/application-remote.properties`
     241
     242```properties
     243# Remote PostgreSQL Database (via SSH tunnel on port 9999)
     244spring.datasource.url=jdbc:postgresql://localhost:9999/${DB_REMOTE_NAME}
     245spring.datasource.username=${DB_REMOTE_USERNAME}
     246spring.datasource.password=${DB_REMOTE_PASSWORD}
     247spring.datasource.driver-class-name=org.postgresql.Driver
    153248```
    154249
Note: See TracChangeset for help on using the changeset viewer.