A modern web application template using FastAPI for the backend API, React TypeScript for the frontend, MongoDB as the database, and Redis for caching.
- Prerequisites
- Project Setup
- Development Environment
- Development Commands
- Production Deployment
- API Documentation
-
Install Python 3.11
- Download from Python Official Website
- Verify installation:
python --version
-
Install Poetry
curl -sSL https://install.python-poetry.org | python3 -Verify installation:
poetry --version
-
Install Node.js
- Download from Node.js Official Website
- Verify installation:
node --version
-
Install Yarn
npm install -g yarn
Verify installation:
yarn --version
- Install Docker and Docker Compose
- Follow instructions at Docker Official Documentation
- Verify installation:
docker --version docker-compose --version
-
Backend Environment Setup
cd backend cp .env-example .envConfigure the following variables in
.env:ENVIRONMENT=production MONGO_URI=mongodb://foo:bar@localhost:27017/ # Use 'mongo' as host if not working MONGO_DB=database REDIS_HOST=localhost # Use 'redis' as host if not working REDIS_PASSWORD=password JWT_SECRET_KEY=secret -
Database Environment Setup
cd database cp .env-example .envConfigure the following variables in
.env:MONGO_INITDB_ROOT_USERNAME=username MONGO_INITDB_ROOT_PASSWORD=password MONGO_INITDB_DATABASE=database MONGO_INITDB_ROOT_EMAIL=user@example.com REDIS_PASSWORD=password
Run the entire stack using Docker:
docker-compose -f docker-compose.yml up --build -dRun only MongoDB and Redis in Docker, with local development servers:
-
Start Required Services
docker-compose -f docker-compose.yml up mongo redis --build -d
-
Setup Backend
cd backend poetry install ./cmd.sh start # Alternative: poetry run python -m app.main
-
Setup Frontend
cd frontend yarn install yarn start
cd backend
./cmd.sh formatcd frontend
yarn lint- Backend API:
http://localhost:8000 - Frontend Application:
http://localhost:3000
Deploy the entire stack for production:
docker-compose -f docker-compose.prod.yml up --build -dWhen the backend is running, access the API documentation at:
- Swagger UI:
http://localhost:8000 - ReDoc:
http://localhost:8000/redoc