Appeal triage in one place: human-confirmed AI suggestions, similar-ticket search, forecast and alerts
Architecture · Quick start · Docs
English · Русский
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.
- 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/REJECTand 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.
| 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.
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
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
- 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.
- 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.
- 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.
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
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/smokeOpen 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 downFor a shared demo, run the same stack on a server behind an HTTPS ingress with access limited to invited viewers; see the deployment guide.
docker compose --profile demo config
cargo test --manifest-path backend/Cargo.toml
npm run build --prefix frontend
scripts/smokeRunning 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.
| 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 |
Proprietary, all rights reserved. The source is published for viewing only; see LICENSE.