# CI/CD and Deployment Documentation This directory contains the CI/CD configuration for the project. ## Testing The project includes end-to-end (e2e) tests to ensure the API endpoints work correctly. The tests are located in the `backend/test` directory. ### Running E2E Tests ```bash # Navigate to the backend directory cd backend # Run e2e tests npm run test:e2e ``` ### Test Structure - `app.e2e-spec.ts`: Tests the basic API endpoint (/api) - `auth.e2e-spec.ts`: Tests authentication endpoints including: - User profile retrieval - Token refresh - GitHub OAuth redirection - `test-utils.ts`: Utility functions for testing including: - Creating test applications - Creating test users - Generating authentication tokens - Cleaning up test data ## CI/CD Workflow The CI/CD pipeline is configured using GitHub Actions and is defined in the `.github/workflows/ci-cd.yml` file. The workflow consists of the following steps: ### Build and Test This job runs on every push to the main branch and on pull requests: 1. Sets up Node.js and pnpm 2. Installs dependencies 3. Builds and tests the backend 4. Builds and lints the frontend ### Build and Push Docker Images This job runs only on pushes to the main branch: 1. Sets up Docker Buildx 2. Logs in to GitHub Container Registry 3. Builds and pushes the backend Docker image 4. Builds and pushes the frontend Docker image ## Deployment The application is containerized using Docker. Dockerfiles are provided for both the backend and frontend: - `backend/Dockerfile`: Multi-stage build for the NestJS backend - `frontend/Dockerfile`: Multi-stage build for the Next.js frontend A `docker-compose.yml` file is also provided at the root of the project for local development and as a reference for deployment. ### Running Locally with Docker Compose ```bash # Build and start all services docker-compose up -d # View logs docker-compose logs -f # Stop all services docker-compose down ``` ### Environment Variables The following environment variables are used in the deployment: #### Backend - `NODE_ENV`: Environment (development, production) - `PORT`: Port on which the backend runs - `POSTGRES_HOST`: PostgreSQL host - `POSTGRES_PORT`: PostgreSQL port - `POSTGRES_DB`: PostgreSQL database name - `POSTGRES_USER`: PostgreSQL username - `POSTGRES_PASSWORD`: PostgreSQL password #### Frontend - `NODE_ENV`: Environment (development, production) - `PORT`: Port on which the frontend runs - `NEXT_PUBLIC_API_URL`: URL of the backend API ## Production Deployment Considerations For production deployment, consider the following: 1. Use a proper secrets management solution for sensitive information 2. Set up proper networking and security groups 3. Configure a reverse proxy (like Nginx) for SSL termination 4. Set up monitoring and logging 5. Configure database backups