Skip to content

Clean Architecture Example using FastAPI framework

License

Notifications You must be signed in to change notification settings

dookki/fastapi-example

 
 

Repository files navigation

fastapi-example

Python FastAPI Swagger Code style: black

Description

Example Application Interface using FastAPI framework in Python 3

This example showcases Repository Pattern in Hexagonal Architecture (also known as Clean Architecture). Here we have two Entities - Books and Authors, whose relationships have been exploited to create CRUD endpoint in REST under OpenAPI standard.

Installation

  • Create and activate a Virtual Environment for Python 3 in your workspace:

    $ python3 -m venv env
    $ source venv/bin/activate
  • Install all the project dependency using Pip:

    $ pip install -r requirements.txt
  • Run the application from command prompt:

    $ uvicorn main:app --reload
  • Open localhost:8000/docs for API Documentation

Testing

For Testing, unittest module is used for Test Suite and Assertion, whereas pytest is being used for Test Runner and Coverage Reporter.

  • Run the following command to initiate test:
    pytest
  • To include Coverage Reporting as well:
    pytest --cov-report xml --cov=.

License

© MIT License

About

Clean Architecture Example using FastAPI framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%