https://github.com/fergusdixon/fastapi-example
An example of FastAPI basics
https://github.com/fergusdixon/fastapi-example
fastapi python
Last synced: 3 months ago
JSON representation
An example of FastAPI basics
- Host: GitHub
- URL: https://github.com/fergusdixon/fastapi-example
- Owner: fergusdixon
- License: mit
- Created: 2021-04-25T10:28:47.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-02-11T02:40:21.000Z (over 3 years ago)
- Last Synced: 2025-06-22T16:41:27.984Z (about 1 year ago)
- Topics: fastapi, python
- Language: Python
- Homepage:
- Size: 73.2 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fastapi-example
An example of FastAPI basics
[](https://www.codacy.com/gh/fergusdixon/fastapi-example/dashboard?utm_source=github.com&utm_medium=referral&utm_content=fergusdixon/fastapi-example&utm_campaign=Badge_Grade)
[](https://www.codacy.com/gh/fergusdixon/fastapi-example/dashboard?utm_source=github.com&utm_medium=referral&utm_content=fergusdixon/fastapi-example&utm_campaign=Badge_Coverage)
## Getting set up
Check the Makefile for useful macros
Using [Poetry](https://python-poetry.org/) install dependencies
```shell
poetry install
poetry shell
```
Run migrations
```shell
make migrate
```
### Structure
```
-- .github : Github Actions defintions
-- alembic : Database table definitions
-- app
---- api : Endpoint defintions and routes
---- core : Configuration management
---- crud : Tools for performing CRUD ops on various models
---- db : Boilerplate sqlalchemy set up
---- schemas : Pydantic definitions for models and API requests/responses
---- tests : Unit and BDD tests
```
### Build the docker image
```shell
make docker-build
```
Start the docker image
```shell
make docker-run
```
The API will be available at http://localhost (port 80)
Docs are at http://localhost/docs
### Tests
Run unittests with coverage (in `app/tests`):
```shell
make test-cov
```
Or with pytest-watch to rerun tests every time a change is made:
```shell
make test-watch
```
Run Behave tests (in `app/tests/features`):
```shell
make bdd
```
### Linting
You can check if your code is up to scratch:
```shell
make lint
```
Fix it automatically:
```shell
make format-imports
```