Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Clean Architecture Example using FastAPI framework

License

NotificationsYou must be signed in to change notification settings

0xTheProDev/fastapi-clean-example

Repository files navigation

PythonFastAPIOpenAPISwaggerGraphQLCode style: blackTyped with: pydanticOpen IssuesClosed IssuesOpen PullsClosed PullsContributorsActivity

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

  • Install all the project dependency usingPipenv:

    $ pipenv install --dev
  • Run the application from command prompt:

    $ pipenv run uvicorn main:app --reload
  • You can also open a shell inside virtual environment:

    $ pipenv shell
  • Openlocalhost:8000/docs for API Documentation

  • Openlocalhost:8000/graphql for GraphQL Documentation

Note: In case you are not able to accesspipenv from youPATH locations, replace all instances ofpipenv withpython3 -m pipenv.

Testing

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

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

License

© MIT License

Sponsor this project

 

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2026 Movatter.jp