Skip to content
This repository was archived by the owner on Oct 27, 2026. It is now read-only.
hhhhhffdPublic archive

About

AI decision-support layer for a public appeal-intake system: Rust/Axum Core API, FastAPI ML service, PostgreSQL job queue, Qdrant similarity search and a human-gated model promotion loop. Demo on synthetic data.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Pulse 109

Pulse 109 — AI Decision Support for Public Services


Appeal triage in one place: human-confirmed AI suggestions, similar-ticket search, forecast and alerts

RUST FASTAPI POSTGRESQL QDRANT REACT LICENSE

Architecture · Quick start · Docs

English · Русский

What it is

Pulse 109 is a demo AI layer for the 109 appeal-intake system. It helps an operator check the topic, priority and addressee of an appeal, and helps a manager see the flow, alerts and forecast. The official status, assignee and reply stay in the external 109 system.

The engineering problem is to tie a model suggestion to a verifiable human decision and to analytics, while keeping a strict data-access boundary. The demo runs on 160 synthetic appeals; classification quality on real 109 data is not proven by it.

Highlights

  • Core/ML boundary and OpenAPI contracts: 73 operations in the Core API and 16 in the ML service, backed by 26 PostgreSQL migrations.
  • Job queue on PostgreSQL with FOR UPDATE SKIP LOCKED: the ML worker claims jobs without a separate broker.
  • Human-gated model promotion: a candidate model goes COLLECT → TRAINING → EVALUATE → human PROMOTE/REJECT and never replaces production automatically.
  • Zero-downtime Qdrant reindexing: the worker builds a staging collection and switches the PostgreSQL lineage only on success.
  • Demo data: 20 regions, 16 topics, 160 synthetic RU/KZ appeals.

Role: team lead in a team of 2, GovTech Camp 2026. Designed the Core/ML boundary and the OpenAPI contracts, and ran the branch merges.

Technical Stack

Group Technology Role
Core Rust, Axum 0.8, SQLx 0.8, Tokio HTTP API, auth/RBAC, transactions, audit, business rules
Frontend React 19, TypeScript, Vite 7, ECharts Operator workspace and manager overview through the Core API
Data PostgreSQL 16, Qdrant v1.12.6 Pulse state (source of truth) and a separate vector index
AI/ML Python 3.12, FastAPI, StatsForecast Internal inference, embeddings, forecast and evaluation
Infra Docker Compose, Nginx 1.27 Reproducible demo stack and a single HTTP gateway

By default RU/KZ classification and embeddings are deterministic, the forecast uses the SeasonalNaive baseline and the optional LLM is disabled. The repository contains the candidate training process and its contracts, but does not claim a trained production model or confirmed quality metrics on customer data.

Architecture

flowchart LR
    Browser --> Gateway[Nginx gateway]
    Gateway --> Frontend[React frontend]
    Gateway --> Core[Rust Core API]
    Core -->|source of truth| Postgres[(PostgreSQL)]
    Core -->|similar tickets| Qdrant[(Qdrant)]
    Core -->|internal inference| ML[FastAPI ML service]
    Worker[ML worker] -->|jobs and results| Postgres
    Worker --> ML
Loading

Nginx forwards /api/* to Core and does not expose /internal/*. The frontend never calls the ML service directly. In Compose the database service is named postgres, so Core connects to postgres:5432. Qdrant holds vectors and a minimal allow-listed payload, so the index can be rebuilt from PostgreSQL.

sequenceDiagram
    participant O as Operator
    participant C as Core API
    participant M as ML service
    participant P as PostgreSQL
    C->>M: Text and allowed context for inference
    M-->>C: Topic, confidence, alternatives
    C->>P: Store AI prediction
    C-->>O: Suggestion and review flag
    O->>C: Confirm or correct
    C->>P: Store separate operator decision and feedback
    Note over C,P: Feedback does not trigger online retraining
Loading

Architecture decisions

  1. Core is the only access boundary. Roles, input validation and business operations are enforced there; the ML service stays an internal compute component, so the frontend cannot bypass auth/RBAC.
  2. PostgreSQL and Qdrant have different jobs. Decisions, model versions, feedback and audit live in PostgreSQL. Qdrant only speeds up similar-ticket search and does not duplicate full text or PII.
  3. A human controls model release. Feedback goes through COLLECT → TRAINING → EVALUATE → human PROMOTE/REJECT. A candidate never replaces production on its own; versions and evidence are stored separately.

Project Structure

backend/       Rust Core API (Axum, SQLx) and its tests
ml-service/    FastAPI ML service, worker.py job worker, training and evaluation
frontend/      React + TypeScript SPA
migrations/    26 PostgreSQL migrations
data/          Synthetic demo data, importers, PII normalization, reports
docs/          Architecture, contracts, learning loop, privacy, OpenAPI
docker/        Nginx gateway config
scripts/       Smoke test, demo seed, evaluation and data tooling
tests/         Contract tests and fixtures

Setup & Deployment

Requires Docker Engine and Compose v2. From the repository root:

cp .env.example .env
docker compose --profile demo config
docker compose --profile demo up --build -d
docker compose --profile demo ps
scripts/smoke

Open http://localhost:8012. The demo-seed container validates the manifest and loads the synthetic appeals; on success it exits with code 0, and re-running it is idempotent. /healthz reports a live process, /readyz reports dependencies, migrations and the model.

Variable Demo default Purpose
PULSE_HTTP_PORT 8012 Only published port: Nginx on host 127.0.0.1
PULSE_PUBLIC_HOST empty Domain allowed for Vite preview in a public demo
POSTGRES_DB pulse PostgreSQL database
POSTGRES_USER pulse Demo user
POSTGRES_PASSWORD pulse_demo_only Local demo password only
PULSE_DEV_AUTH true Role picker for the demo, no external identity
CORS_ALLOWED_ORIGINS http://localhost:8012 Allowed browser origin

Warning

PULSE_DEV_AUTH=true and the demo password are not a substitute for real identity. Replace every demo-only credential before exposing the stack beyond localhost, and never publish Core, ML, PostgreSQL or Qdrant directly.

.env is not committed. Stop without deleting data:

docker compose --profile demo down

For a shared demo, run the same stack on a server behind an HTTPS ingress with access limited to invited viewers; see the deployment guide.

Checks

docker compose --profile demo config
cargo test --manifest-path backend/Cargo.toml
npm run build --prefix frontend
scripts/smoke

Running the Rust PDF-export test on the host needs weasyprint; the runtime Docker image already includes it. There is no CI pipeline in the repository; checks are run manually. More check levels are in the testing guide.

Note

Production identity, sync with the live 109 system, official routing and verified metrics on customer data need separate inputs and integration. Do not read the demo numbers as real quality.

Documentation

Topic Link
Architecture docs/architecture.md
Data contracts docs/data-contract.md, docs/contracts.md
Learning loop and model registry docs/learning-loop.md, docs/model-registry.md
PII boundaries docs/privacy.md
OpenAPI Core, ML

License

Proprietary, all rights reserved. The source is published for viewing only; see LICENSE.

About

AI decision-support layer for a public appeal-intake system: Rust/Axum Core API, FastAPI ML service, PostgreSQL job queue, Qdrant similarity search and a human-gated model promotion loop. Demo on synthetic data.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages