https://github.com/0xtheprodev/fastapi-clean-example
Clean Architecture Example using FastAPI framework
https://github.com/0xtheprodev/fastapi-clean-example
clean-architecture fastapi graphql hexagonal-architecture openapi3 pydantic python python3 repository-pattern rest-api starlette strawberry-graphql swagger swagger-ui
Last synced: 16 days ago
JSON representation
Clean Architecture Example using FastAPI framework
- Host: GitHub
- URL: https://github.com/0xtheprodev/fastapi-clean-example
- Owner: 0xTheProDev
- License: mit
- Created: 2022-04-10T10:23:51.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-12T09:03:57.000Z (almost 2 years ago)
- Last Synced: 2025-03-29T18:06:17.594Z (23 days ago)
- Topics: clean-architecture, fastapi, graphql, hexagonal-architecture, openapi3, pydantic, python, python3, repository-pattern, rest-api, starlette, strawberry-graphql, swagger, swagger-ui
- Language: Python
- Homepage:
- Size: 101 KB
- Stars: 441
- Watchers: 5
- Forks: 58
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# fastapi-clean-example
[](https://docs.python.org/3/)
[](https://fastapi.tiangolo.com/)
[](https://www.openapis.org/)
[](https://swagger.io/)
[](https://graphql.org/)
[](https://black.readthedocs.io/en/stable/)
[](https://docs.pydantic.dev/)
[](https://github.com/0xTheProDev/fastapi-clean-example/issues)
[](https://github.com/0xTheProDev/fastapi-clean-example/issues?q=is%3Aissue+is%3Aclosed)
[](https://github.com/0xTheProDev/fastapi-clean-example/pulls)
[](https://github.com/0xTheProDev/fastapi-clean-example/pulls?q=is%3Apr+is%3Aclosed)
[](https://github.com/0xTheProDev/fastapi-clean-example/graphs/contributors)
[](https://github.com/0xTheProDev/fastapi-clean-example/pulse)## 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 using [Pipenv](https://pipenv.pypa.io):
```sh
$ pipenv install --dev
```- Run the application from command prompt:
```sh
$ pipenv run uvicorn main:app --reload
```- You can also open a shell inside virtual environment:
```sh
$ pipenv shell
```- Open `localhost:8000/docs` for API Documentation
- Open `localhost:8000/graphql` for GraphQL Documentation
_*Note:* In case you are not able to access `pipenv` from you `PATH` locations, replace all instances of `pipenv` with `python3 -m pipenv`._
## 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:
```sh
$ pipenv run pytest
```
- To include Coverage Reporting as well:
```sh
$ pipenv run pytest --cov-report xml --cov .
```## License
© MIT License