A modern full-stack Todo application with FastAPI backend and React frontend, deployable as a single Docker container to AWS Elastic Beanstalk.
- π User Authentication - JWT-based auth with access/refresh tokens
- π₯ Role-Based Access - User and Admin roles
- β Full CRUD Operations - Create, read, update, delete todos
- π Priority Levels - Low, medium, high priority tasks
- π― Filtering - View all, active, or completed todos
- π± Responsive Design - Works on desktop and mobile
- π Security - Rate limiting, password hashing, JWT tokens
- π API Documentation - Auto-generated interactive docs
- FastAPI - Modern Python web framework
- SQLAlchemy - Async ORM
- PostgreSQL - Production database (SQLite for dev)
- JWT - Authentication tokens
- Pydantic - Data validation
- React 18 - UI library
- React Router - Client-side routing
- Axios - HTTP client
- Modern CSS - Styled components
- Docker - Containerization
- Nginx - Reverse proxy & static file serving
- AWS Elastic Beanstalk - Hosting platform
ToDo/
βββ Backend (FastAPI)
β βββ main.py # Application entry point
β βββ auth.py # Authentication logic
β βββ config.py # Configuration
β βββ database.py # Database connection
β βββ models.py # SQLAlchemy models
β βββ schemas.py # Pydantic schemas
β βββ dependencies.py # FastAPI dependencies
β βββ middleware.py # Custom middleware
β βββ routers/ # API route handlers
β βββ auth.py # Auth endpoints
β βββ todos.py # Todo endpoints
β βββ admin.py # Admin endpoints
β
βββ Frontend (React)
β βββ src/
β β βββ components/ # React components
β β βββ context/ # React context (auth)
β β βββ services/ # API client
β β βββ styles/ # CSS styles
β βββ public/ # Static files
β βββ package.json # Dependencies
β
βββ Deployment
β βββ Dockerfile # Multi-stage Docker build
β βββ nginx-fullstack.conf # Nginx configuration
β βββ start-fullstack.sh # Container startup script
β βββ prepare-fullstack-deployment.ps1
β
βββ Development
β βββ run.py # Run backend locally
β βββ start-local.ps1 # Start both services
β βββ docker-compose.yml # Local Docker setup
β βββ requirements.txt # Python dependencies
β
βββ Documentation
βββ README.md # This file
βββ QUICK_DEPLOY.md # Quick AWS deployment guide
βββ FULLSTACK_DEPLOYMENT.md # Detailed deployment guide
βββ LOCAL_TESTING.md # Local development guide
- Python 3.11+
- Node.js 18+
- npm or yarn
# Clone the repository
git clone <your-repo-url>
cd ToDo
# Create virtual environment
python -m venv venv
.\venv\Scripts\Activate.ps1
# Install Python dependencies
pip install -r requirements.txt
# Start both backend and frontend
.\start-local.ps1This opens two terminals:
- Backend: http://localhost:8000
- Frontend: http://localhost:3000
Terminal 1 - Backend:
.\venv\Scripts\Activate.ps1
python run.pyTerminal 2 - Frontend:
cd frontend
npm install
npm startUsername: admin
Password: admin123
# Build and run with Docker Compose
docker-compose up
# Access at http://localhost:8000- Prepare package:
.\prepare-fullstack-deployment.ps1- Generate SECRET_KEY:
python -c "import secrets; print(secrets.token_urlsafe(64))"- Upload to AWS:
- Go to AWS Elastic Beanstalk
- Create Application β Platform: Docker
- Upload
fullstack-deployment.zip
- Set Environment Variables:
SECRET_KEY=<your-generated-key>
DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/dbname
DEBUG=False
- Done! Wait 10-15 minutes.
See QUICK_DEPLOY.md for step-by-step instructions.
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
POST /auth/register- Register new userPOST /auth/login- Login (get tokens)GET /auth/me- Get current userPOST /auth/refresh- Refresh access token
GET /todos/- List todosPOST /todos/- Create todoGET /todos/{id}- Get todoPUT /todos/{id}- Update todoPATCH /todos/{id}/complete- Toggle completeDELETE /todos/{id}- Delete todoGET /todos/stats/summary- Get statistics
GET /admin/users- List usersPUT /admin/users/{id}/role- Update user roleDELETE /admin/users/{id}- Delete user
# Backend tests
pytest
# Frontend tests
cd frontend
npm test# Health check
curl http://localhost:8000/health
# Login
curl -X POST http://localhost:8000/auth/login \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=admin&password=admin123"| Variable | Required | Default | Description |
|---|---|---|---|
SECRET_KEY |
Yes | - | JWT signing key (64+ chars) |
DATABASE_URL |
Yes | sqlite+aiosqlite:///./todo.db | Database connection string |
DEBUG |
No | True | Debug mode (set False in prod) |
ALGORITHM |
No | HS256 | JWT algorithm |
ACCESS_TOKEN_EXPIRE_MINUTES |
No | 30 | Token expiry |
REFRESH_TOKEN_EXPIRE_DAYS |
No | 7 | Refresh token expiry |
Development (SQLite):
DATABASE_URL=sqlite+aiosqlite:///./todo.db
Production (PostgreSQL):
DATABASE_URL=postgresql+asyncpg://user:password@host:5432/dbname
- β Password hashing with bcrypt
- β JWT token authentication
- β Role-based access control
- β Rate limiting (60 req/min)
- β CORS configuration
- β SQL injection protection (SQLAlchemy)
- β XSS protection (React)
- β Security headers (Nginx)
Frontend (React) :3000 β Backend (FastAPI) :8000 β Database
User β Port 8080 (Nginx)
ββ / β React Frontend (SPA)
ββ /api/* β Backend (Proxy)
β
Uvicorn :8000
β
PostgreSQL
Backend automatically reloads on file changes when running python run.py.
Frontend automatically refreshes on file changes when running npm start.
Backend:
pip install <package>
pip freeze > requirements.txtFrontend:
cd frontend
npm install <package>| Script | Purpose |
|---|---|
start-local.ps1 |
Start both backend & frontend |
run.py |
Start backend only |
prepare-fullstack-deployment.ps1 |
Create AWS deployment package |
docker-compose up |
Run with Docker locally |
# Find process
netstat -ano | findstr :8000
# Kill process
taskkill /PID <pid> /F# Delete database and restart
rm todo.db
python run.py- Check backend is running on port 8000
- Check CORS settings in
main.py - Verify API URL in
frontend/src/services/api.js
# Clean Docker cache
docker system prune -a
# Rebuild
docker-compose build --no-cache- Use PostgreSQL in production
- Enable connection pooling
- Add database indexes
- Add Redis for session storage
- Cache frequently accessed data
- Use CDN for static assets
- Deploy multiple EB instances
- Use AWS Application Load Balancer
- Enable auto-scaling
MIT License - see LICENSE file for details
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- π Detailed Deployment Guide
- β‘ Quick Deploy Reference
- π§ͺ Local Testing Guide
- π GitHub Issues
- FastAPI for the amazing framework
- React team for the UI library
- AWS for hosting platform
Built with β€οΈ using FastAPI and React