Architecture v0.2

Charles Dana · Monce AI · April 2026

Request flow

                  HTTPS
                    │
          ┌─────────▼─────────┐
          │   Route53 A       │   alma.aws.monce.ai → 35.180.91.48
          └─────────┬─────────┘
                    │
          ┌─────────▼─────────┐
          │   nginx (443)     │   Let's Encrypt TLS, reverse proxy
          └─────────┬─────────┘
                    │  127.0.0.1:8000
          ┌─────────▼─────────┐
          │  uvicorn/FastAPI  │   systemd: alma.service
          │  api/app.py       │
          └─────────┬─────────┘
                    │
          ┌─────────▼─────────┐       ┌─────────────────────┐
          │  Pipeline (7 st)  │──────▶│  AWS Bedrock        │
          │  stages 0..6+4.5  │       │  eu-west-3          │
          └─────────┬─────────┘       │  Haiku 4.5          │
                    │                 │  Sonnet 4.6         │
                    │                 └─────────────────────┘
                    │
          ┌─────────▼─────────┐
          │  Snake v5.4.5     │   pure Python, in-process
          │  SAT classifier   │   3 models in data/models/
          └───────────────────┘

Pipeline stages

#StageCostTypical timeOutput
0Client IDregex + 1 Haiku call< 1 scustomer_id, CIF, language
1Doc Analyzerregex + 1 Haiku call< 1 spage triage, layout
2Unified Extractor1 Sonnet call per 3-page chunk3–6 sstructured JSON
3Rules Enginedeterministic< 10 mscleaned values
4Snake Matcherin-process SAT< 20 ms/linematched PN/customer
4.5Pricing (NEW)deterministic lookup< 50 μs/linetariff-filled unit_price
5Validation1 Haiku call1–2 sflags & overall confidence
6Routerdeterministic< 1 msauto-approve / review / full review

Data layout

data/
 ├─ articles.json         847 parts (67 real + 180 AXALYS + 600 filler)
 ├─ clients.json          216 customers (16 real + 200 filler)
 ├─ alma_entities.json    1 entity — ALMA COMPONENTES
 ├─ axalys_tarif.json     180 AXALYS refs across 21 product sheets
 ├─ pricing.json          313 priced entries (155 GPAO + 158 AXALYS)
 └─ models/
    ├─ article_matcher.json
    ├─ client_matcher.json
    └─ entity_matcher.json

tarifs/
 └─ TARIF GENERAL 240207.xlsx  (password: soleil)

Deployment topology

LayerSpec
EC2t3.medium, Ubuntu 24.04, 20 GB gp3, eu-west-3
IAMinstance profile safran-po-ec2-profile → Bedrock InvokeModel
AuthAWS_BEARER_TOKEN_BEDROCK env in systemd unit
Nginx443 TLS (Let's Encrypt) → 127.0.0.1:8000
Servicealma.service, auto-restart, 3 worker coroutines
DNSRoute53 zone aws.monce.ai, A-record TTL 300
Certcertbot renewal cron, valid until 2026-07-21

Extensibility