# Deployment Architecture ## Deployment Strategy **Frontend Deployment:** - **Platform:** Coolify (self-hosted) - **Build Command:** `npm run build` (in frontend/) - **Output Directory:** `frontend/dist` - **Serving:** Static files served by Nginx/Caddy via Coolify reverse proxy - **CDN/Edge:** No CDN (self-hosted), Coolify handles SSL and caching headers **Backend Deployment:** - **Platform:** Coolify (self-hosted) - **Build Command:** None (Node.js runs directly) - **Deployment Method:** Docker container with `npm start` - **Process Manager:** Docker handles restarts, no PM2 needed - **Health Checks:** `GET /api/health` monitored by Coolify **Database Deployment:** - **Platform:** Coolify-managed PostgreSQL container - **Backups:** Automated daily backups via Coolify - **Migrations:** Run `npx prisma migrate deploy` on deployment ## CI/CD Pipeline **MVP:** Manual deployment via Coolify UI (no CI/CD pipeline initially). **Future CI/CD (GitHub Actions example):** ```yaml # .github/workflows/deploy.yaml name: Deploy to Coolify on: push: branches: [main] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '20' - name: Install dependencies run: | cd frontend && npm ci cd ../backend && npm ci - name: Run tests run: | cd frontend && npm test cd ../backend && npm test - name: Build frontend run: cd frontend && npm run build - name: Deploy to Coolify uses: coolify/action@v1 with: api-key: ${{ secrets.COOLIFY_API_KEY }} project-id: ${{ secrets.COOLIFY_PROJECT_ID }} ``` ## Environments | Environment | Frontend URL | Backend URL | Purpose | |-------------|-------------|-------------|---------| | Development | http://localhost:5173 | http://localhost:3000/api | Local development with hot reload | | Production | https://books.yourdomain.com | https://books.yourdomain.com/api | Live environment on Coolify | **Note:** No staging environment for MVP (single-user, can test locally). Add staging in v1.1 if needed. ---