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.

Year
2026
Role
Architecture, back-end services, CI/CD, observability
View source
Illustration, not a screenshot: a document sent through the api-gateway to the document, auth and notification services, with RabbitMQ events, a Celery worker, PostgreSQL, Prometheus and Grafana.Illustration
Illustration drawn from the service topology in the README.

02At 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.created event 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

  1. 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.

  2. 02

    Events, not calls

    The document service publishes document.created and returns; AI work happens in a Celery worker.

    Why — Uploads stay fast, and a slow AI step can’t time out a user request.

  3. 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

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
Next case file — 06MedAssist AIOpen