# Deployment Guide

## Prerequisites

- Docker & Docker Compose
- Git

## Steps

1. **Clone the repository** (if not already on the server):

   ```bash
   git clone <repo-url>
   cd elmeg
   ```

2. **Environment Variables**:
   Create a `.env` file in the root directory (or rely on `docker-compose.yml` defaults for dev).
   For production, you should set:

   ```env
   POSTGRES_USER=your_user
   POSTGRES_PASSWORD=your_password
   POSTGRES_DB=elmeg_db
   SECRET_KEY=your_production_secret_key
   ```

3. **Build and Run**:

   ```bash
   docker-compose up --build -d
   ```

4. **Run Migrations**:
   The backend container needs to run migrations.

   ```bash
   docker-compose exec backend alembic upgrade head
   ```

5. **Access the App**:
   - Frontend: `http://localhost:3000` (or your server IP)
   - Backend API: `http://localhost:8000`

## Troubleshooting

- **Database Connection**: Ensure the `backend` service can reach `db`. The `DATABASE_URL` in `docker-compose.yml` should match the postgres credentials.
- **API Connectivity**: If the frontend (SSR) fails to fetch data, check `INTERNAL_API_URL` in `docker-compose.yml`. It should point to `http://backend:8000`.
