This repository is dedicated to learning and practicing FastAPI concepts, backend architecture, and modern Python development. It serves as a hands-on playground for building APIs, working with databases, authentication, and deployment workflows.
The project focuses on:
- Building REST APIs with FastAPI
- Modeling and validating data with Pydantic
- Working with SQLAlchemy and Alembic
- Implementing authentication and authorization
- Writing tests with pytest
- Preparing applications for containerized deployment
"The best way to learn a framework is to build something real with it."
fastapi_learning/
app.py
database.py
security.py
settings.py
models/
routers/
schemas/
tests/
conftest.py
test_app.py
test_auth.py
test_todos.py
test_users.py
git clone https://github.com/LyanKaleu/fastapi_learning.git
cd fastapi_learningpoetry install
poetry shellBefore starting the app, make sure you have a .env file with the required environment variables, such as:
DATABASE_URL=...
SECRET_KEY=...
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30If you prefer the development-style command, you can use:
poetry run fastapi dev fastapi_learning/app.pypytest -qIf you prefer a shorter workflow, Taskipy is already configured in pyproject.toml.
task run
task test
task lint
task format
task migrate
task migration-create "Describe your change"Here is what each task does:
task runβ starts the FastAPI development servertask testβ runs the test suite with pytest and coveragetask lintβ checks the codebase with Rufftask formatβ formats the code with Rufftask migrateβ applies the latest Alembic migrationstask migration-create "..."β creates a new Alembic migration with an autogenerated messagetask migrate-downβ reverts the last migration
This project uses Alembic for schema evolution.
poetry run alembic upgrade head
poetry run alembic revision --autogenerate -m "Describe your change"The test suite covers API behavior, authentication, database access, and core application flows.
pytest -qYou can also run the project in a container.
docker build -t fastapi-learning .
docker run -p 8000:8000 fastapi-learningThe project is also prepared for deployment on Fly.io through the GitHub Actions workflow in .github/workflows/fly-deploy.yml.
Before deploying, make sure you have the Fly CLI installed. You can install it from: https://fly.io/docs/hands-on/install-flyctl/
Typical flow:
flyctl deployThe application image uses the entrypoint defined in entrypoint.sh, so migrations are applied automatically when the container starts.
FastAPI combines Python simplicity with modern API development practices:
- Clean and expressive route definitions
- Automatic request and response validation
- Excellent editor support and type hints
- Strong async support for scalable services
- Great fit for learning backend architecture in practice
Lyan Kaleu