A cookiecutter template for creating a full-stack application with Python FastAPI backend and React frontend with TailwindCSS.
- FastAPI Backend: Modern Python web framework for building APIs
- React Frontend: With Tailwind CSS for styling
- Routing: Ready-to-use React Router setup
- Docker Support: Docker and Docker Compose configurations included
- Poetry: For Python dependency management
- Development Tools: Hot-reloading for both backend and frontend
- Cookiecutter (Python package)
- Python 3.9+
- Node.js and npm (for frontend development)
- Docker and Docker Compose (optional)
# Install cookiecutter if you haven't already
pip install cookiecutter
# Generate a new project
cookiecutter gh:nsnguyen/cookiecutter-fastapi-react
If you want to modify this template or create your own based on it:
-
Clone the repository:
git clone https://github.com/nsnguyen/cookiecutter-fastapi-react.git cd cookiecutter-fastapi-react
-
Make your desired changes to the files in the
{{cookiecutter.project_slug}}/
directory -
Test your modified template by generating a project locally:
# From the repository root directory cookiecutter .
-
Once satisfied, push to your own GitHub repository:
git push origin main
-
Then use your modified template:
cookiecutter gh:nsnguyen/cookiecutter-fastapi-react
Follow the prompts to configure your project:
project_name
: Name of your projectproject_slug
: Directory name for your project (auto-generated from project name)project_description
: Brief description of your projectauthor_name
: Your nameauthor_email
: Your emailversion
: Initial version of your projectpython_version
: Python version for backend development (3.9, 3.10, 3.11, 3.12)use_docker
: Whether to include Docker configurationfrontend_port
: Port for the React frontend (default: 3000)backend_port
: Port for the FastAPI backend (default: 8000)
After generation, your project will have the following structure:
your-project-name/
├── backend/ # FastAPI application
│ ├── app/
│ │ ├── api/ # API endpoints
│ │ ├── core/ # Core utilities
│ │ ├── models/ # Data models
│ │ └── main.py # Application entry point
│ ├── Dockerfile # Backend Docker configuration
│ ├── pyproject.toml # Poetry configuration
│ └── tests/ # Backend tests
├── frontend/ # React application
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API services
│ │ └── utils/ # Utility functions
│ ├── Dockerfile # Frontend Docker configuration
│ └── package.json # npm configuration
├── docker-compose.yml # Docker Compose configuration
└── README.md # Project README
If you chose to include Docker, simply run:
cd your-project-name
docker-compose up
cd your-project-name/backend
poetry install
poetry run uvicorn app.main:app --reload
cd your-project-name/frontend
npm install
npm start
MIT