This project serves as a boilerplate for building web applications using FastAPI, a modern, fast (high-performance) web framework for Python.
- FastAPI: Leverages FastAPI for building APIs quickly with automatic interactive documentation.
- SQLAlchemy: Utilizes SQLAlchemy for ORM (Object Relational Mapping) to interact with the database.
- Alembic: Includes Alembic for database migrations.
- Poetry: Manages dependencies and virtual environments using Poetry.
- Testing: Configured with pytest for writing and running tests.
Ensure you have the following installed:
- Python 3.13
- Poetry
-
Clone the repository:
git clone https://github.com/lucasgomide/fastapi-boilerplate.git cd fastapi-boilerplate
-
Install dependencies:
poetry install
-
Set up the database:
-
You can either configure your database settings in
alembic.ini
or set a default value inf Setting() class -
Run migrations:
make migrate
-
-
Run the application:
make run-server
Access the application at
http://127.0.0.1:8000
.
fastapi-boilerplate/
├── app/
│ ├── __init__.py
│ ├── main.py
│ ├── models/
│ ├── routers/
│ └── schemas/
├── migrations/
├── tests/
├── alembic.ini
├── pyproject.toml
└── README.md
app/
: Contains the main application code.models/
: Database models.routers/
: API route definitions.schemas/
: Pydantic models for request and response validation.
migrations/
: Database migration scripts managed by Alembic.tests/
: Test cases for the application.
Execute the following command to run tests: (make sure your database connection was properly set)
make test