A multi-user email client with Next.js frontend and FastAPI backend, using PostgreSQL for email storage and Gmail API integration.
- Node.js 20+
- Python 3.11+
- Docker (for PostgreSQL)
- Google OAuth credentials
cd backend
# Start PostgreSQL
docker-compose up -d
# Create virtual environment and install dependencies
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env with your Google OAuth credentials
# Run database migrations
alembic upgrade head
# Start the server
uvicorn main:app --host 0.0.0.0 --port 8000 --reloadAPI documentation available at: http://localhost:8000/docs
cd frontend
# Install dependencies
npm install
# Configure environment
cp .env.local.example .env.local
# Edit .env.local with:
# - Google OAuth credentials
# - NEXTAUTH_SECRET
# - NEXT_PUBLIC_BACKEND_URL=http://localhost:8000
# Start development server
npm run devApp available at: http://localhost:3000
- Multi-user authentication: Sign in with any Google account
- Email management: Read, send, search, archive emails
- Database caching: Fast email access via PostgreSQL
- Background sync: Automatic email synchronization from Gmail
- Secure: User-isolated data with JWT authentication
Frontend (Next.js, Port 3000)
↓
Backend API (FastAPI, Port 8000)
↓
PostgreSQL Database (Docker, Port 5432)
↓
Gmail API (Google)
POST /auth/google-token- Exchange Google token for JWTGET /auth/me- Get current user infoGET /auth/status- Check auth status
GET /emails- List emails with paginationGET /emails/{id}- Get specific emailPOST /emails/send- Send emailPOST /emails/{id}/read- Mark as readDELETE /emails/{id}- Delete email
Tables:
users- User accounts and OAuth tokensemails- Email content and metadatasync_state- Sync tracking per useralembic_version- Migration history
cd backend
python test_api.pycd backend
python sync_worker.pycd backend
alembic revision --autogenerate -m "description"
alembic upgrade head- Update environment variables for production
- Set secure
NEXTAUTH_SECRETand JWT secrets - Use production PostgreSQL instance
- Set up proper CORS configuration
- Enable HTTPS
- Set up background job queue (Celery/Redis) for email sync
Frontend:
- Next.js 15
- React 18
- TypeScript
- NextAuth.js
- Tailwind CSS
Backend:
- FastAPI
- SQLAlchemy
- Alembic
- PostgreSQL
- Python-JOSE (JWT)
- Google Auth Library
Infrastructure:
- Docker & Docker Compose
- Uvicorn (ASGI server)