Skip to content

Commit f4fda69

Browse files
committed
feat: complete reliability suite with auth, rate-limiting, and docker
1 parent d658361 commit f4fda69

22 files changed

+711
-30
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__pycache__
2+
*.pyc
3+
.env
4+
.git
5+
.pytest_cache
6+
tests/

.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PROJECT_NAME="API Reliability Suite"
2+
LOG_LEVEL="info"
3+
OTLP_ENDPOINT="http://localhost:4317"
4+
SECRET_KEY="my-super-secret-dev-key-change-in-prod"
5+
ACCESS_TOKEN_EXPIRE_MINUTES = 30

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: daretechie

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
strategy:
2020
matrix:
21-
python-version: ["3.12", "3.13"]
21+
python-version: ["3.13", "3.12"]
2222

2323
steps:
2424
- name: Checkout code

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Stage 1: Build
2+
FROM python:3.12-slim AS builder
3+
4+
WORKDIR /app
5+
6+
# Install Poetry
7+
RUN pip install poetry
8+
9+
# Copy dependencies file
10+
COPY pyproject.toml poetry.lock* ./
11+
12+
# Install dependencies
13+
RUN poetry config virtualenvs.create false \
14+
&& poetry install --no-dev --no-interaction --no-ansi
15+
16+
# Stage 2: Runtime
17+
FROM python:3.12-slim
18+
19+
WORKDIR /app
20+
21+
# Copy installed packages from builder
22+
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
23+
COPY --from=builder /usr/local/bin /usr/local/bin
24+
25+
# Copy application code
26+
COPY src/ ./src/
27+
28+
# Expose port
29+
EXPOSE 8000
30+
31+
# Run application
32+
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]

README.md

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
>
1414
> **"This endpoint is slow, but we can't figure out where the bottleneck is."**
1515
>
16-
> **"We deployed a fix, but it broke something else."**
16+
> **"We're getting hammered by bots and can't stop them."**
1717
18-
Sound familiar? Most APIs are built without proper **observability** or **testing**—making debugging a nightmare.
18+
Sound familiar? Most APIs are built without proper **observability**, **security**, or **testing**—making debugging a nightmare.
1919

2020
## ✅ The Solution
2121

2222
This project is a **production-ready template** that shows you how to build APIs that are:
2323

2424
- 🔍 **Observable** — Every request is traced, every error is logged in structured JSON
25-
- 🛡️ **Resilient**Global exception handling ensures clean error responses
25+
- 🛡️ **Secure**Rate limiting & JWT authentication protect your resources
2626
-**Tested** — Automated tests catch bugs before they reach production
2727
- 🚀 **CI/CD Ready** — Push code, tests run automatically
2828

@@ -36,34 +36,68 @@ This project is a **production-ready template** that shows you how to build APIs
3636
| **Structured Logging** | JSON logs via Structlog (ELK/Datadog ready) |
3737
| **Distributed Tracing** | OpenTelemetry instrumentation |
3838
| **Error Handling** | Global exception middleware |
39+
| **Rate Limiting** | Slowapi with IP-based throttling |
40+
| **Authentication** | JWT tokens with OAuth2 password flow |
41+
| **Configuration** | Environment-aware settings (Pydantic) |
42+
| **Containerization** | Multi-stage Docker build |
3943
| **Automated Testing** | Pytest with async support |
4044
| **CI/CD** | GitHub Actions with matrix testing |
4145

4246
---
4347

4448
## 🚀 Quick Start
4549

50+
### Local Development
4651
```bash
4752
git clone https://github.com/daretechie/api-reliability-suite.git
4853
cd api-reliability-suite
4954
poetry install
5055
poetry run uvicorn src.main:app --reload
5156
```
5257

58+
### Run with Docker
59+
```bash
60+
docker build -t reliability-suite .
61+
docker run -p 8000:8000 reliability-suite
62+
```
63+
64+
---
65+
5366
## 🔍 API Endpoints
5467

55-
| Endpoint | Description |
56-
|----------|-------------|
57-
| `GET /health` | Health check |
58-
| `GET /slow` | Simulates slow request (tracing demo) |
59-
| `GET /force-error` | Triggers 500 error (error handling demo) |
60-
| `GET /docs` | Interactive Swagger docs |
68+
| Endpoint | Auth | Rate Limited | Description |
69+
|----------|------|--------------|-------------|
70+
| `GET /health` || ✅ 5/min | Health check |
71+
| `GET /slow` ||| Simulates slow request (tracing demo) |
72+
| `POST /login` ||| Get JWT token (demo/secret123) |
73+
| `GET /protected` ||| Protected route (requires JWT) |
74+
| `GET /force-error` ||| Triggers 500 error (error handling demo) |
75+
| `GET /docs` ||| Interactive Swagger docs |
6176

6277
---
6378

64-
## 🧠 Roadmap: AI-Powered Debugging
79+
## 📡 Observability & Tracing
80+
81+
This suite supports **OTLP (OpenTelemetry Line Protocol)** for production-grade tracing.
6582

66-
> *Coming Soon: Intelligent observability features*
83+
### Connecting to Jaeger
84+
To see your traces in a dashboard, update your `.env`:
85+
```env
86+
OTLP_ENDPOINT="http://localhost:4317"
87+
```
88+
Then run Jaeger via Docker:
89+
```bash
90+
docker run -d --name jaeger \
91+
-e COLLECTOR_OTLP_ENABLED=true \
92+
-p 16686:16686 \
93+
-p 4317:4317 \
94+
jaegertracing/all-in-one:latest
95+
```
96+
View your traces at `http://localhost:16686`.
97+
98+
---
99+
100+
## 🧠 Roadmap: AI-Powered Debugging
67101

68102
- 🤖 **LLM-Powered Log Analysis** — Auto-summarize error patterns
69103
- 🔮 **Predictive Alerts** — Detect anomalies before they become incidents
@@ -77,5 +111,5 @@ If this template helps you, consider [sponsoring my work](https://github.com/spo
77111

78112
## 🤝 Hire Me
79113

80-
Looking for a developer who understands **API reliability and DevOps**?
114+
Looking for a developer who understands **API reliability, security, and DevOps**?
81115
📧 [[email protected]](mailto:[email protected]) | [LinkedIn](https://linkedin.com/in/daretechie)

0 commit comments

Comments
 (0)