Giter VIP home page Giter VIP logo

fastapi-clean-code-microservice's Introduction

FastAPI Clean Code Microservice

This is a sample project that demonstrates how to build a microservice using FastAPI framework and sqlalchemy. It follows the principles of clean architecture and hexagonal design. The project consists of one simple customer service.

Features

  • CRUD operations for customers
  • Pagination, filtering, and sorting for customers
  • Validation and error handling
  • Unit testing and code coverage
  • Docker and docker-compose support
  • Nginx reverse proxy
  • OpenAPI documentation

Requirements

  • Python 3.9+
  • Pipenv
  • PostgreSQL
  • Docker and docker-compose
  • Installation

Clone the repository and install the dependencies using pipenv:

git clone https://github.com/sushant-at-nitor/fastapi-clean-code-microservice.git
cd fastapi-clean-code-microservice
pipenv install --dev

Create a .env file in the root directory and add the following environment variables:

POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_SERVER=db
POSTGRES_PORT=5432
POSTGRES_DB=fastapi
API_PORT=8000
API_HOST=0.0.0.0

Usage

To run the application locally, use the following command:

uvicorn main:app --reload
pipenv run uvicorn main:app --reload

To run the application using docker-compose, use the following command:

docker-compose up -d --build

Testing

To run the tests and generate the coverage report, use the following command:

pipenv run pytest --cov-report xml --cov .

License

None

fastapi-clean-code-microservice's People

Contributors

sushant-at-nitor avatar

Watchers

 avatar

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.