Skip to content

Latest commit

Β 

History

History
145 lines (122 loc) Β· 3.86 KB

File metadata and controls

145 lines (122 loc) Β· 3.86 KB

AITutor - Modular Deployment Structure

Project Structure

aitutor/
β”œβ”€β”€ backend/                    # FastAPI Backend Module
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ core/config.py
β”‚   β”‚   β”œβ”€β”€ models/schemas.py
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ api/routes/
β”‚   β”‚   └── main.py
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ render.yaml           # Render deployment config
β”‚   β”œβ”€β”€ .env.example          # Environment variables template
β”‚   β”œβ”€β”€ deploy.sh            # Deployment script
β”‚   └── README.md            # Backend-specific docs
β”‚
β”œβ”€β”€ frontend/                   # Next.js Frontend Module
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   └── types/
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ vercel.json          # Vercel deployment config
β”‚   β”œβ”€β”€ .env.example         # Environment variables template
β”‚   β”œβ”€β”€ deploy.sh            # Deployment script
β”‚   └── README.md            # Frontend-specific docs
β”‚
β”œβ”€β”€ src/                       # Original source (can be removed)
β”œβ”€β”€ deployment/                 # Deployment guides and scripts
β”œβ”€β”€ docs/                      # Documentation
└── README.md                  # Main project README

Deployment Options

Option 1: Separate Repositories (Recommended)

Create two separate GitHub repositories:

  • aitutor-backend β†’ Deploy to Render
  • aitutor-frontend β†’ Deploy to Vercel

Option 2: Monorepo with Subfolders

Keep single repository but deploy from subfolders:

  • Backend: Deploy backend/ folder to Render
  • Frontend: Deploy frontend/ folder to Vercel

Quick Deployment Commands

Backend Deployment

cd backend
./deploy.sh

Frontend Deployment

cd frontend
./deploy.sh

Both Services (from root)

# Deploy backend
cd backend && ./deploy.sh

# Deploy frontend
cd ../frontend && ./deploy.sh

Environment Setup

Backend Environment Variables

  • OPENROUTER_API_KEY: OpenRouter API key
  • PORT: 8000 (Render sets automatically)
  • NODE_ENV: production

Frontend Environment Variables

  • NEXT_PUBLIC_API_URL: Backend URL
  • NODE_ENV: production

URLs After Deployment

Benefits of Modular Structure

  1. Independent Deployment: Deploy frontend/backend separately
  2. Faster Builds: Smaller codebases build faster
  3. Team Collaboration: Frontend/backend teams can work independently
  4. Scaling: Scale services independently
  5. Maintenance: Update one service without affecting the other
  6. Testing: Test services in isolation

Migration from Current Structure

If migrating from the current src/ structure:

  1. Copy src/backend/ to backend/
  2. Copy src/frontend/ to frontend/
  3. Update deployment configurations
  4. Create separate repositories (optional)
  5. Update CI/CD pipelines

CI/CD Integration

GitHub Actions (Backend)

name: Deploy Backend
on:
  push:
    branches: [main]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Deploy to Render
        run: curl -X POST https://api.render.com/v1/services/${{RENDER_SERVICE_ID}}/deploys

GitHub Actions (Frontend)

name: Deploy Frontend
on:
  push:
    branches: [main]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Deploy to Vercel
        uses: amondnet/vercel-action@v20
        with:
          vercel-token: ${{ secrets.VERCEL_TOKEN }}
          vercel-org-id: ${{ secrets.ORG_ID }}
          vercel-project-id: ${{ secrets.PROJECT_ID }}