Giter Site home page Giter Site logo

nrjadkry / fastapi_boilerplate Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 0.0 27 KB

A minimalist and efficient FastAPI boilerplate to kickstart your web application development. This template provides a clean project structure with integrated features like FastAPI, database connectivity (SQLAlchemy), authentication, testing setup, logging, and Docker support. Get started quickly with a solid foundation for your FastAPI projects.

License: MIT License

Dockerfile 1.82% Python 92.72% Shell 1.69% Mako 3.76%
fastapi boilerplate docker python sqlalchemy

fastapi_boilerplate's Introduction

FastAPI Boilerplate with PostgreSQL and Docker

This is a boilerplate project for building web applications using FastAPI framework with PostgreSQL as the database backend, all orchestrated with Docker environment.

Features

  • FastAPI: FastAPI is a modern, fast (high-performance) web framework for building APIs with Python 3.7+ based on standard Python type hints.
  • PostgreSQL: PostgreSQL is a powerful, open-source object-relational database system known for its reliability, robustness, and performance.
  • Pydantic: Pydantic is used for data validation and settings management, enabling easy serialization and validation of data structures.
  • SQLAlchemy: SQLAlchemy is a SQL toolkit and Object-Relational Mapping (ORM) library for Python, providing a full suite of well-known enterprise-level persistence patterns.
  • Alembic: Alembic is a lightweight database migration tool for usage with SQLAlchemy, allowing for easy schema migrations.
  • Docker Compose: Docker Compose is used for orchestrating the FastAPI application and PostgreSQL database within Docker containers.

Prerequisites

Before getting started, ensure you have the following installed on your system:

  • Docker
  • Docker Compose

Installation

  1. Clone this repository:

    git clone [email protected]:nrjadkry/fastapi_boilerplate.git
  2. Navigate into the project directory:

    cd fastapi-postgres-boilerplate
  3. Create a .env file in the project root using the env_sample.txt provided.

    cp env_sample.txt .env

  4. Create a docker-compose file. Update it according to your choice

    cp docker-compose.local.yml docker-compose.yml

  5. Start the application and PostgreSQL database containers using Docker Compose:

    docker-compose up -d

Usage

Once Docker containers are up and running, the FastAPI application will be available at http://localhost:8001.

Project Structure

  • app: Contains the main application code.
    • api: API routers and endpoints.
    • core: Core application modules and configurations.
    • db: Database related code including SQLAlchemy models and database connection setup.
    • schemas: Pydantic models for request/response payloads.
  • alembic: Contains database migration scripts managed by Alembic.
  • tests: Unit and integration tests.
  • docker-compose.yml: Docker Compose configuration file for orchestrating the FastAPI application and PostgreSQL database.

Contributing

Contributions are welcome! Please fork this repository and submit a pull request with your changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.