A FastAPI-based REST API project with user authentication, todo management, and PostgreSQL database integration.
- User authentication with JWT tokens
- Todo management (CRUD operations)
- PostgreSQL database integration
- Docker support
- Automated testing
- CI/CD pipeline with GitHub Actions
- FastAPI: Modern web framework for building APIs
- SQLAlchemy: SQL toolkit and ORM
- Alembic: Database migration tool
- Pydantic: Data validation and settings management
- JWT: JSON Web Token authentication
- Poetry: Dependency management
- pytest: Testing framework
- Docker: Containerization
- PostgreSQL: Database
- Python 3.13+
- Poetry
- Docker and Docker Compose (optional)
- PostgreSQL (if not using Docker)
- Clone the repository
- Install dependencies:
poetry install- Copy
.env_exampleto.envand configure your environment variables:
cp .env_example .envdocker-compose up --buildThe API will be available at http://localhost:8000
- Start a PostgreSQL database
- Configure your
.envfile - Run database migrations:
poetry run alembic upgrade head- Start the application:
poetry run uvicorn fastapi_zero.app:app --reloadThe project uses taskipy for common development tasks:
# Format code
poetry run task format
# Run linter
poetry run task lint
# Run tests
poetry run task test
# Run migrations
poetry run task migrate
# Generate new migration
poetry run task migrate_generate "migration_name"Tests are written using pytest. To run the test suite:
poetry run task testThis will:
- Run linting checks
- Execute all tests
- Generate coverage report
When running the application, API documentation is available at:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
fastapi_zero/
├── app.py # FastAPI application setup
├── database.py # Database configuration
├── models/ # SQLAlchemy models
├── routers/ # API routes
├── schemas.py # Pydantic models
├── security.py # Authentication logic
└── settings.py # Application settings
migrations/ # Alembic migrations
tests/ # Test suite
DATABASE_URL: PostgreSQL connection stringJWT_SECRET_KEY: Secret key for JWT tokensJWT_ALGORITHM: Algorithm for JWT (default: HS256)JWT_EXPIRE_IN_MINUTES: Token expiration time (default: 30)
The project includes a GitHub Actions workflow that:
- Runs on push and pull requests
- Executes the test suite
- Verifies code quality
This project is open-sourced under the MIT license.