https://github.com/d-ashesss/nulland
Note taking REST API with Python and FastAPI
https://github.com/d-ashesss/nulland
fastapi jwt oauth2 postgresql python rest-api
Last synced: about 2 months ago
JSON representation
Note taking REST API with Python and FastAPI
- Host: GitHub
- URL: https://github.com/d-ashesss/nulland
- Owner: d-ashesss
- License: mit
- Created: 2023-08-04T21:03:17.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-10T17:24:13.000Z (almost 3 years ago)
- Last Synced: 2025-03-04T05:20:49.053Z (over 1 year ago)
- Topics: fastapi, jwt, oauth2, postgresql, python, rest-api
- Language: Python
- Homepage:
- Size: 84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Note taking API
REST API backend for note taking application.
[](https://github.com/d-ashesss/nulland/actions/workflows/test.yml)
[](https://opensource.org/licenses/MIT)
[](https://github.com/d-ashesss/nulland/tags)

## Running the app
To run the app first you must install the dependencies from requirements.txt then use Uvicorn to run the app.
```bash
pip install -r requirements.txt
python -m uvicorn app.main:app
```
Alternalively, to run in Docker (provide environment variables as needed):
```bash
docker run -p 8000:8000 -e 'DATABASE_URI=postgresql://postgres:postpwd@localhost' -e 'AUTH_OPENID_CONFIGURATION_URL=https://accounts.google.com/.well-known/openid-configuration' ashesss/nulland:latest
```
Or even with docker compose, configure environment in `docker-compose.override.yml` (see [example](https://github.com/d-ashesss/nulland/wiki/example-docker%E2%80%90compose.override.yml)), then simply run:
```bash
docker-compose up
```
## Configuration
### Authentication
The API handles authentication using JWT tokens. The token is passed in the `Authorization` header as a bearer token. It is possible to use OIDC service like [Auth0](https://auth0.com) to obtain the token and then use it with this API. It is required to provide the app with the URL to the OIDC discovery documents in the `AUTH_OPENID_CONFIGURATION_URL` environment variable.
### Database
The API uses PostgreSQL database. The connection string must be passed in the `DATABASE_URL` environment variable.
### Logging
To get the log format compatible with Google Cloud structured logging, set the `LOG_FORMAT` environment variable to `json`.
### Event logging
Application is able to post events to Kafka topic. To configure this feature set `EVENT_PRODUCER` environment variable to `kafka` and the hostname of Kafka server in `KAFKA_BOOTSTRAP_SERVERS` variable. Additionaly, `KAFKA_SASL_USERNAME` and `KAFKA_SASL_PASSWORD` must be set if Kafka server requires authentication.
### CORS
To configure CORS to allow access from a specific domain, set the `CORS_ALLOWED_ORIGINS` environment variable to JSON-formatted list of allowed URLs,
for example `CORS_ALLOWED_ORIGINS='["http://localhost:5000"]'`.
## API documentation
OpenAPI documentation is available at `/docs` endpoint.