A modern, production-ready template for building full-stack applications with FastAPI and React. This template provides a modular structure with Docker support for both development and production environments.
- 🚀 FastAPI backend for high-performance API development
- ⚛️ React frontend with modern tooling
- 🐳 Docker and Docker Compose support for development
- 📦 Separate production-ready Dockerfiles for cloud deployment
- 📁 Modular project structure for both frontend and backend
- 🔍 Example TODO list CRUD implementation
- 📝 Auto-generated API documentation (Swagger/OpenAPI)
- ✨ Clean, maintainable architecture
- 🔒 Type safety with Pydantic models and TypeScript
- Docker
- Docker Compose
-
Clone the template:
git clone https://github.com/yourusername/full-stack-fastapi-template.git cd full-stack-fastapi-template -
Start the development environment:
docker-compose up
-
Access the applications:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
-
Navigate to the backend directory:
cd backend -
Create and activate virtual environment:
python -m venv venv source venv/bin/activate # On Windows: .\venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the backend:
uvicorn main:app --reload
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install
-
Start the development server:
npm run dev
full-stack-fastapi-template/
├── docker-compose.yml # Development Docker Compose configuration
├── backend/
│ ├── Dockerfile # Production backend Dockerfile
│ ├── Dockerfile.development # Development backend Dockerfile
│ ├── main.py # Application entry point
│ ├── requirements.txt # Python dependencies
│ ├── models/ # Data models
│ └── routes/ # API routes
├── frontend/
│ ├── Dockerfile # Production frontend Dockerfile
│ ├── Dockerfile.development # Development frontend Dockerfile
│ ├── package.json
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Page components
│ │ └── services/ # API services
│ └── public/ # Static assets
The template includes separate Dockerfiles for production deployment of both frontend and backend services. This allows for independent scaling and deployment of each service in cloud environments.
-
Backend:
docker build -t myapp-backend ./backend
-
Frontend:
docker build -t myapp-frontend ./frontend
-
Backend:
DATABASE_URL: Database connection stringSECRET_KEY: Application secret key- Additional environment variables as needed
-
Frontend:
REACT_APP_API_URL: Backend API URL- Additional environment variables as needed
The template includes a complete TODO list API:
GET /api/todos- List all todosPOST /api/todos- Create a todoGET /api/todos/{id}- Get a specific todoPUT /api/todos/{id}- Update a todoDELETE /api/todos/{id}- Delete a todo
We welcome contributions! Please see our Contributing Guidelines for details.
- Follow PEP 8 guidelines
- Use type hints
- Write docstrings for functions and classes
- Implement unit tests for new features
- Follow React best practices
- Use TypeScript for type safety
- Implement component tests
- Follow the established project structure
This project is licensed under the MIT License - see the LICENSE file for details.
- Check the FastAPI documentation
- Visit the React documentation
- Open an issue for bugs
- Start a discussion for questions