Skip to content

Commit d2578e3

Browse files
authored
Merge pull request #3 from MrMatAP/feature/readme
Updated documentation
2 parents 7c0ac32 + 923977e commit d2578e3

File tree

5 files changed

+68
-4
lines changed

5 files changed

+68
-4
lines changed

.idea/dataSources.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/mrmat-python-api-fastapi.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,56 @@
22

33
[![Build](https://github.com/MrMatOrg/mrmat-python-api-fastapi/actions/workflows/build.yml/badge.svg)](https://github.com/MrMatOrg/mrmat-python-api-fastapi/actions/workflows/build.yml)
44

5+
Boilerplate (and playground) for a code-first Python FastAPI API.
56

6-
Boilerplate (and playground) for a code-first Python FastAPI API, with all the bells and whistles we've come to expect.
7+
## How to build this
78

9+
Create a virtual environment, then:
10+
11+
```shell
12+
(venv) $ pip install -r requirements.txt
13+
(venv) $ python python -m build -n --wheel
14+
```
15+
16+
If you intend to run the testsuite or work on the code, then also install the requirements from `requirements.dev.txt`. You can run the testsuite using
17+
18+
```shell
19+
(venv) $ PYTHONPATH=src pytest tests
20+
```
21+
22+
The resulting wheel is installable and knows its runtime dependencies. Any locally produced wheel will have version 0.0.0.dev0. This is intentional to distinguish local versions from those that are produced as releases in GitHub. You can override this behaviour by setting the `MRMAT_VERSION` environment variable to the desired version.
23+
24+
You can produce a container image and associated Helm chart using the provided Makefile:
25+
26+
```shell
27+
$ make container
28+
29+
# Optionally install the produced container image in the current Kubernetes context
30+
$ make helm-install
31+
```
32+
33+
## How to run this
34+
35+
To run a local development instance straight from the code:
36+
37+
```shell
38+
$ fastapi dev src/mrmat_python_api_fastapi/app.py
39+
```
40+
41+
To run from an installed wheel:
42+
43+
```shell
44+
$ uvicorn --host 0.0.0.0 --port 8000 mrmat_python_api_fastapi.app:app
45+
```
46+
47+
Or you can just start the container image or Helm chart. Both are declared in `var/container` and `var/helm` respectively and used by the top-level Makefile.
48+
49+
## How to configure this
50+
51+
When you do not explicitly configure anything the app will use an ephemeral in-memory SQLite database. You can change this to PostgreSQL by:
52+
53+
* overriding the `config.db_url` variable of the Helm chart, or
54+
* setting the `APP_CONFIG_DB_URL` environment variable, or
55+
* creating a config file in JSON setting `db_url`
56+
57+
The app will pick up the config file from the path set in the `APP_CONFIG` environment variable, if it is set. Note that the `APP_CONFIG_DB_URL` environment variable overrides the setting in the configuration file.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Runtime requirements
33

4-
fastapi==0.115.11 # MIT
4+
fastapi[standard]==0.115.11 # MIT
55
sqlalchemy[asyncio]==2.0.40 # MIT
66
uvicorn==0.34.0 # BSD 3-Clause
77
pydantic==2.10.6 # MIT

0 commit comments

Comments
 (0)