https://github.com/heinrich10/pyfastapi
Simple backend example using Python and FastAPI
https://github.com/heinrich10/pyfastapi
fastapi python sqlalchemy sqlite
Last synced: 2 months ago
JSON representation
Simple backend example using Python and FastAPI
- Host: GitHub
- URL: https://github.com/heinrich10/pyfastapi
- Owner: heinrich10
- License: mit
- Created: 2023-08-02T16:49:11.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-15T03:07:04.000Z (over 2 years ago)
- Last Synced: 2025-05-15T08:19:41.742Z (about 1 year ago)
- Topics: fastapi, python, sqlalchemy, sqlite
- Language: Python
- Homepage:
- Size: 110 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PYFASTAPI
sample backend using pyfastapi, sqlalchemy, and alembic
## Pre-requisites
- python 3.12
- poetry
- sqlite
## How to run
1. install dependencies `poetry install`
2. copy `.env.example` to `.env` and change the values if needed
2. run the app `poetry run python run.py`
3. call the api endpoint `curl http://localhost:5000/persons`
4. open `http://localhost:5000/docs` to view then openapi docs
## How to run in a container
1. build the image `podman build -t pyfastapi .`
2. run the image `podman run -p 5000:5000 pyfastapi`
note: you can use `docker` instead of `podman` as it is a drop in replacement
## Seed Data
1. run `alembic upgrade head`
2. sql schema and the data should be on `./sql_app.db`
3. refer to `alembic.ini` to change other configuration, it uses .env for the DB url
## Tests
1. make sure main dependencies are installed
2. run `poetry install`
2. run `pytest`, take note that it uses `.env.test` for configuration
## Data Model
```mermaid
---
config:
layout: dagre
look: handDrawn
title: ERD
---
erDiagram
person {
int id PK ""
String last_name ""
String first_name ""
String country_code FK ""
timestamp updated_at ""
timestamp created_at ""
}
country {
String code PK ""
String name ""
int phone ""
String symbol ""
String capital ""
String currency ""
String continent_code FK ""
String alpha_3 ""
timestamp updated_at ""
timestamp created_at ""
}
continent {
String code PK ""
String name ""
}
person}|--||country:"residesIn"
country}|--||continent:"belongsTo"
```