https://github.com/0x6f677548/fastapi-bootstrap
FastAPI Bootstrap is a project template that bundles NGINX, FastAPI and OpenTelemetry, providing a bootstrap for anyone that wants to expose an API securely and with instrumentation.
https://github.com/0x6f677548/fastapi-bootstrap
fastapi nginx opentelemetry
Last synced: 8 months ago
JSON representation
FastAPI Bootstrap is a project template that bundles NGINX, FastAPI and OpenTelemetry, providing a bootstrap for anyone that wants to expose an API securely and with instrumentation.
- Host: GitHub
- URL: https://github.com/0x6f677548/fastapi-bootstrap
- Owner: 0x6f677548
- Created: 2025-01-19T17:24:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-22T16:26:25.000Z (over 1 year ago)
- Last Synced: 2025-10-02T13:44:49.162Z (9 months ago)
- Topics: fastapi, nginx, opentelemetry
- Language: Python
- Homepage:
- Size: 33.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# FastAPI Bootstrap
[](https://pypi.org/project/fastapi-bootstrap)
[](https://pypi.org/project/fastapi-bootstrap)
[](https://github.com/0x6f677548/fastapi-bootstrap/actions/workflows/build-and-publish-to-ghcr.yml)
[](https://github.com/0x6f677548/fastapi-bootstrap/actions/workflows/deploy-to-dockerhost.yml)
[](https://github.com/0x6f677548/fastapi-bootstrap/actions/workflows/lint.yml)
[](https://github.com/0x6f677548/fastapi-bootstrap/actions/workflows/test.yml)
FastAPI Bootstrap is a project template that bundles NGINX, FastAPI and OpenTelemetry, providing a bootstrap for anyone that wants to expose an API securely and with instrumentation.
# Architecture
The project is composed of the following containers:
- **api-proxy**: An NGINX server that acts as a reverse proxy for api-server (FastAPI).
All inbound requests are limited to cloudflare IPs and forwarded to the api-server, after initial checks. Nginx longs are send through syslog to the otel-collector.
- **api-server**: A FastAPI server that exposes a router through a REST API and is instrumented with OpenTelemetry, sending traces, metrics, and logs to the otel-collector.
- **otel_collector**: An OpenTelemetry collector that exposes syslog and otel endpoints to receive logs, traces, and metrics from the api-proxy and api-server and forwards them to a remote OTEL compliant backend, which may be Jaeger, Prometheus, New Relic, Datadog, or any other backend that supports the OpenTelemetry protocol.
- **jaeger**: A Jaeger server that receives traces from the otel-collector and displays them in a web interface.
## GitHub Actions
Some github actions are also included to lint, test, build, and deploy the project. Deployments are made to a remote server using TailScale, SSH, and Docker.
- **lint**: Lints the code using black and ruff (through hatch).
- **test**: Runs the tests using pytest.
- **lint-super-linter**: Lints the code using super-linter.
- **create-draft-release**: Creates a draft release.
- **build-artifacts**: Builds the artifacts for the project.
- **build-and-publish-to-ghcr**: Builds the Docker images and publishes them to the GitHub Container Registry.
- **build-and-publish-to-pypi**: Builds the Python package and publishes it to PyPI.
- **deploy-to-dockerhost**: Deploys the Docker images to a remote server using TailScale, SSH, and Docker.
- **clear-actions-cache**: Clears the GitHub Actions cache.
- **debug-context**: Prints the GitHub Actions context.
## Other components
Some of the tools and libraries used in this project are:
- **FastAPI**: A modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.
- **Hatch**: A modern project, package, and virtual env manager for Python.
- **NGINX**: A web server that can also be used as a reverse proxy, load balancer, etc.
- **OpenTelemetry**: A set of APIs, libraries, agents, and instrumentation to provide observability.
- **Tailscale**: A ZeroTier alternative that provides a secure, private network for your servers.
- **Docker**: A set of platform as a service products that use OS-level virtualization to deliver software in packages called containers.