Case file 05 / 06 — Distributed systems / Applied AI
AI Document Platform
Four microservices behind a JWT gateway that read, summarise and search documents — and keep working when the AI provider doesn’t.
Illustration02At a glance
- Type
- Distributed systems / applied AI, open source
- Role
- Architecture, back-end services, CI/CD, observability
- Stack
- FastAPI, PostgreSQL, RabbitMQ, Celery, Redis, Docker
- Coverage gate
- ≥ 80% per service
What shipped
- An API gateway on :8080 with JWT checks, rate limiting, security headers and a circuit breaker.
- Document, auth and notification services, each with its own PostgreSQL database.
- A
document.createdevent on RabbitMQ that triggers a Celery worker for OCR, embeddings and summaries. - Prometheus metrics and Grafana dashboards; a test suite that must keep coverage at 80% or more.
03The noise
Document processing pipelines tend to fail all at once when one dependency does, especially an external AI API.
This platform was designed so each concern — authentication, documents, notifications, AI work — is a separate, separately tested service, and every AI feature has a non-AI fallback.
04The signal
- 01
Fallbacks before features
Embeddings use text-embedding-3-small and summaries use GPT-4o-mini, but search falls back to TF-IDF and summaries to extractive text.
Why — With no API key, or with the provider down, the platform still uploads, indexes and searches documents.
- 02
Events, not calls
The document service publishes
document.createdand returns; AI work happens in a Celery worker.Why — Uploads stay fast, and a slow AI step can’t time out a user request.
- 03
One database per service
Each service owns its PostgreSQL database; no service reads another’s tables.
Why — Services can change their schema and be deployed independently.
05Showcase
ScreenshotNew document — write it or upload a file; tags are set at the same time.
ScreenshotCreated, then processed — the worker picks up the document.created event in the background.
ScreenshotNotifications — the notification service hears the same event.
ScreenshotNo API key — semantic search says so plainly and points to keyword search.
ScreenshotThe fallback — keyword similarity still finds the document, ranked, with no AI at all.
ScreenshotDocument view — content, AI summary, AI tags and basic stats in one place. - Not captured yet — A capture of the running Grafana dashboard. Requires the full Docker Compose stack; not captured yet.
Grafana dashboard
06Architecture
Requests enter through one gateway. Uploads become events; AI work happens asynchronously, and every service reports metrics.
Select a part of the system to see what it does and what it talks to.
Connections
- Client to API gateway :8080HTTPS + JWT
- API gateway :8080 to auth-serviceverify
- API gateway :8080 to document-service :8001route
- document-service :8001 to RabbitMQdocument.created
- RabbitMQ to notification-serviceconsume
- document-service :8001 to Celery worker + Redisenqueue AI job
- document-service :8001 to Prometheus + Grafanametrics
07Challenges
Challenge: An outage at the AI provider would otherwise take search and summaries down with it.
What I did: Each AI step has a deterministic fallback, and the gateway’s circuit breaker stops a failing dependency from cascading.
Challenge: Keeping four services honest as they change independently.
What I did: Each has its own tests with an 80% coverage gate in CI, its own database and its own metrics.
08Outcome
- Source is public on GitHub, with Docker Compose for local runs and Kubernetes manifests in the repository.
Not yet documented
- A capture of the running Grafana dashboard.
- Load-test figures — not measured.
09Sources
- Project README on GitHub
- Khalid’s screen recording of the running app, 1 Dec 2026