Skip to content
/ fastapi-starter Public template

FastAPI Starter Kit – a base project designed to help you develop web applications using Python and the FastAPI framework.

Notifications You must be signed in to change notification settings

simonmacor/fastapi-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI

FastAPI Starter Kit

FastAPI Starter Kit – a base project designed to help you develop web applications using Python and the FastAPI framework. This starter kit is built to simplify backend development with a pre-configured architecture for testing, database management, and mocking third-party services.

Features

  • FastAPI Framework: A modern and fast framework for building web APIs with Python.
  • BDD Testing with Behave: Use behavior-driven development (BDD) for scenario-based testing.
  • Unit Testing with Pytest: Pre-configured for unit and functional tests.
  • SQLAlchemy: ORM (Object-Relational Mapper) for database interaction.
  • Alembic: A database schema migration tool for managing schema changes.
  • Mountebank: Mock third-party services with imposters for integration testing.
  • PostgreSQL: Latest version of PostgreSQL as the default database.
  • Adminer: A web-based tool to easily manage the PostgreSQL database.

Prerequisites

  • Docker and Docker Compose must be installed on your machine.

Installation

  1. Clone this repository:

    git clone https://github.com/your-project/fastapi-web-starter-kit.git
    cd fastapi-web-starter-kit
  2. Install Python dependencies (if working locally without Docker):

    python3 -m venv env
    source env/bin/activate
    pip install -r requirements.txt
  3. Start the application using Docker Compose:

    docker-compose up --build
  4. Access the FastAPI application at http://localhost:8000.

  5. Access Adminer to manage the database at http://localhost:8080.

Important Files

Included Services

FastAPI

FastAPI is used to create fast and performant RESTful APIs. The application is available at http://localhost:8000.

PostgreSQL and Adminer

PostgreSQL is the database configured with the latest version, and you can manage it via Adminer at http://localhost:8080.

Mountebank

Mountebank is configured to simulate third-party services and test API integrations. Imposter configuration is stored in the imposters.ejs file.

Testing

  • BDD with Behave: BDD scenarios are defined in the features/ directory.

  • Unit and Functional Testing with Pytest: Traditional tests are located in the tests/ directory.

Database Migrations

Database schema migrations are managed via Alembic. Use the following commands to create and apply migrations:

# Create a new migration
alembic revision --autogenerate -m "Migration name"

# Apply migrations
alembic upgrade head

Useful Commands

  • Start the application:

    docker-compose up --build
  • Apply database migrations:

    docker-compose exec app alembic upgrade head
  • Run unit and functional tests:

    docker-compose exec app pytest
  • Run BDD tests:

    docker-compose exec app behave

About

FastAPI Starter Kit – a base project designed to help you develop web applications using Python and the FastAPI framework.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages