Skip to content
/ fastapi-boilerplate Public template

This boilerplate leverages route-service structure, is equipped with pre-commit hooks, github actions and dependabot and is constructed as per personal preference of workflow for quick API development.

License

Notifications You must be signed in to change notification settings

Ahnaf19/fastapi-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

fastapi-boilerplate

This boilerplate leverages route-service structure, is equipped with pre-commit hooks, github actions and dependabot and is constructed as per personal preference of workflow for quick API development.

Usage of the boilerplat

  1. From Settings > General: select the checkbox Tempate repository.
  2. This will add a use this template button. When need to use this as a template, use the button.

Project Overview

add text for project overview

Developed on: python 3.10.16

Python

FastAPI Pydantic Pytest Uvicorn Loguru

NumPy Pandas PyTorch

Black isort flake8 mypy bandit Pre-commit CodeQL GitHub Actions Docker MIT License Apache License 2.0


Docker Build & Run

To build and run the application using Docker, follow these steps:


Prerequisites

Ensure you have Docker installed on your machine. You can download it from here.

Build Docker Image

Important

Docker Daemon or Docker Desktop must be running while building Docker Image.

Navigate to the root directory of the repo where the Dockerfile is located and run the following command to build the Docker image:

docker build -t <project_name>:latest .

Run Docker Container

After building the Docker image, you can run it using the following command:

docker run -dp 8000:8000 <project_name>:latest

or give the container a name:

docker run -dp 8000:8000 --name <project_name>-latest <project_name>:latest

This will start the application in a Docker container. The application can be accessed at http://localhost:8000 e.g. 127.0.0.1:8000

Note

-dp (-d & -p) tag runs the container in detached mode (in the background, terminal is available to use right away) and container port 8000 is mapped to local port 8000.

Stopping the Container

To stop the running container, first find the container ID using:

docker ps

Then stop the container using:

docker stop <container_id>

Run locally with Uvicorn

  • [optional but recommended] create a venv and activate it
  • Install dependencies:
    pip install -r requirements.txt
  • start Uvicorn server:
    uvicorn app.main:app --reload
  • ctrl+c to break the server.

Milestones

  • develop pipeline πŸ€–
  • Expose the pipeline with api end points 🌐
  • unit testing πŸ§ͺ
  • write comprehensive readme πŸ“–βœ¨
  • write readme-dev πŸ“–
  • dockerize the repo 🐳
  • Code Auto-formatting & Linting with Pre-commit (check-yaml, end-of-file-fixer, trailing-whitespace, black, isort, mypy, flake8, bandit) 🎨
  • add GitHub Action for format checks βœ…
  • Study deploy requirement and deploy! πŸš€

Resources

add resources here


Collaborate & Contribute

Bug reports, issues, forks and pull requests are always welcome!


License

This project is available as open source under the MIT License. See the LICENSE file for details.

About

This boilerplate leverages route-service structure, is equipped with pre-commit hooks, github actions and dependabot and is constructed as per personal preference of workflow for quick API development.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •