A starter template for building scalable and production-ready FastAPI applications with PostgreSQL and Alembic. This project is fully containerized using Docker and Docker Compose for easy setup and deployment.
- FastAPI backend
- PostgreSQL database
- Alembic for database migrations
- Docker and Docker Compose for easy setup
- JWT authentication
- Pre-configured environment variables
Make sure you have the following installed on your machine:
git clone https://github.com/yourusername/fastapi-starter.git
cd fastapi-starterCreate a .env file in the root directory and copy the content from .env.example. Modify it if needed.
cp .env.example .envRun the following command to build and start the containers:
docker-compose up --buildThis will:
- Start a PostgreSQL database container
- Build and start the FastAPI backend
The application will be available at:
- FastAPI API docs: http://localhost:8000/docs
Before using the application, run database migrations:
docker-compose exec backend alembic upgrade headA default superuser will be created automatically using the credentials in the .env file. If you need to create another superuser, you can manually add it via an API call.
To stop the application, run:
docker-compose downfastapi-starter/
│── backend/
│ ├── src/
│ │ ├── main.py # FastAPI entry point
│ │ ├── models/ # SQLAlchemy models
│ │ ├── crud/ # Database interaction functions
│ │ ├── config/ # Configuration settings
│ ├── Dockerfile # Backend service Dockerfile
│── docker-compose.yml # Docker Compose configuration
│── .env # Environment variables
│── requirements.txt # Dependencies
│── README.md # Documentation
Once the application is running, visit http://localhost:8000/docs to explore available endpoints.
Feel free to fork this repository and customize it according to your needs. Contributions are welcome!
This project is licensed under the MIT License.