This is a FastAPI boilerplate, which includes includes:
- MongoDB as database
- Bcrypt for password hashing
- JWT for user token management and verification
- Dockerfile and docker-compose files for easy deployment
- CORS Middleware configuration
- User registration.
- User authentication and token creation.
- User verification and token validation.
- Encrypted password management.
You'll need Docker and Docker Compose to run this application.
- Build the project
docker-compose build
- Start the project
docker-compose up -d
- Watch logs
docker-compose logs -f app
This command will start the FastAPI server on port 8000, the MongoDB service on port 27017 and Mongo admin panel on port 8081.
You can navigate to https://localhost:8000/docs
in your browser to access the automatically generated API documentation.
The main sections of the project are:
app/main.py
: This is the entry point of the application.app/config.py
: This file contains the global configuration of the application.app/auth
: This folder contains the logic related to the authentication system.app/auth/service.py
: Contains the service layer logic for the authentication system.app/auth/repository
: Contains the logic for interacting with the MongoDB database.app/auth/router
: Contains the routing logic for the authentication API.app/auth/adapters
: Contains the JWT management logic.app/auth/utils
: Contains utility functions, such as password hashing.
poetry install
poetry shell
sh ./scripts/launch.sh