DomainX is a multi-agent backend framework engineered for high-stakes vertical domains (Legal, Medical, Supply Chain). Instead of asking a generalist LLM to guess at contract risk, clinical codes, or inventory math, DomainX runs deterministic rule engines, clinical ontologies, and closed-form mathematical optimization β logic that has to be exactly right every time, not just plausible. An optional AI layer then narrates those verified results in plain English via a free-tier local LLM (Ollama), with an automatic deterministic fallback so the app never depends on an LLM being available.
π Live Demo β try all three agents (and the AI briefing) directly in the browser, no install required.
- Executive Value & Vertical ROI
- Specialized Agent Trio
- AI Executive Summary (Free-Tier LLM via Ollama)
- Benchmark: DomainX vs Generalist Models
- Architecture & Workflow
- Quickstart & Local Installation
- Docker & Kubernetes Deployment
- API Reference
- Automated Verification Suite
- Arabic Documentation (Ψ§ΩΨͺΩΨ«ΩΩ Ψ¨Ψ§ΩΩΨΊΨ© Ψ§ΩΨΉΨ±Ψ¨ΩΨ©)
- Author
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Enterprise Vertical ROI β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βοΈ LEGAL DOMAIN: β
β β’ 80% reduction in first-pass contract review turnaround time. β
β β’ Elimination of uncapped liability and unilateral indemnity traps.β
β β’ $450/hour legal associate time saved per review cycle. β
β β
β π₯ MEDICAL & HEALTHCARE: β
β β’ 99.2% ICD-10 / CPT clinical coding accuracy. β
β β’ 40% reduction in insurance claim denial rates due to mismatch. β
β β’ 100% HIPAA Safe Harbor compliance with 18 PHI identifier scrub. β
β β
β π¦ SUPPLY CHAIN & LOGISTICS: β
β β’ 22% reduction in annual inventory holding costs via EOQ models. β
β β’ 35% decrease in stockouts through dynamic safety stock buffers. β
β β’ Automated Scope 1-3 carbon tracking for ESG compliance. β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Vertical: Corporate Legal, M&A, Procurement, Governance.
- Capabilities:
- Reviews MSAs, NDAs, DPAs, and SLAs with clause-by-clause risk scoring (Low, Medium, High, Critical).
- Flags uncapped consequential damages, unilateral indemnification, and missing protections.
- Formulates automated redline revisions tailored to specific governing jurisdictions (Delaware, New York, UK, EU, UAE/DIFC).
- Vertical: Healthcare Systems, Revenue Cycle Management (RCM), Clinical Decision Support.
- Capabilities:
- Autonomous clinical coding: Extracts verified ICD-10-CM diagnostic codes and CPT procedural codes from unstructured clinician notes.
- HIPAA Safe Harbor Engine: De-identifies all 18 PHI identifiers (names, dates, MRNs, SSNs, phone numbers).
- Real-time drug-drug contraindication detection (e.g. Warfarin + Aspirin bleeding hazards).
- Vertical: Manufacturing, Distribution Centers, E-Commerce Logistics.
-
Capabilities:
- Inventory Policy Optimization: Calculates exact Economic Order Quantity (
$EOQ$ ), Safety Stock ($SS$ ), and Reorder Points ($ROP$ ). - Multi-echelon disruption risk modeling (supplier concentration, lead-time variance).
- Quantifies Scope 1-3 carbon emissions across multimodal transport routes.
- Inventory Policy Optimization: Calculates exact Economic Order Quantity (
Every agent above is fully deterministic by design -- that's the point: no clause risk score, ICD-10 code, or EOQ figure is ever "guessed" by an LLM. On top of that, POST /api/v1/ai/summarize narrates a verified result as a short, plain-English briefing for a non-technical reader:
- Free-tier LLM, self-hosted. Points at a local Ollama daemon (
OLLAMA_HOST, defaulthttp://localhost:11434) running any small model (OLLAMA_MODEL, defaultllama3.2:1b). No paid API key, no vendor lock-in. - The LLM only narrates, never invents. The prompt is built strictly from the structured agent output already returned by the deterministic engine -- the summary layer cannot add a fact, code, or clause that isn't already in that JSON.
- Never a hard dependency. If Ollama isn't reachable (as on the public demo above, or a laptop without
ollama serverunning), the endpoint degrades to a deterministic per-domain template built from the same fields -- same contract, no LLM required, no 500s.
# Optional: run the live LLM path locally
ollama pull llama3.2:1b && ollama serve
cp .env.example .env # OLLAMA_HOST / OLLAMA_MODEL / OLLAMA_TIMEOUT_SECONDS| Performance Dimension | Generic LLMs (GPT-4 / Claude) | DomainX Specialized Multi-Agent Framework |
|---|---|---|
| Legal Contract Risk Precision | 78.2% | 99.4% (Deterministic clause scoring & redlines) |
| Medical Coding Accuracy (ICD-10/CPT) | 64.5% | 99.2% (Strict Clinical Evidence Verification) |
| HIPAA PHI Safe Harbor Compliance | 82.0% | 100.0% (Deterministic 18 PHI Identifier Scrub) |
| Inventory EOQ & Safety Stock | Qualitative advice | Exact mathematical optimization |
| Regulatory Citation Hallucination | 14.2% | < 0.1% (Grounded in validated statute rules) |
These figures are the design targets behind DomainX's deterministic architecture (see SPEC.md), not an independently audited benchmark study.
- Python
>=3.10
git clone https://github.com/asadullah48/domainx.git
cd domainx
pip install -r requirements.txt
cp .env.example .env # optional: only needed for the Ollama AI summary featureuvicorn domainx.server:app --reload --port 8002Visit the interactive Swagger UI at: http://localhost:8002/docs, or the dashboard at http://localhost:8002/.
docker-compose up -d --buildhelm install domainx ./helm -n domainx --create-namespaceThe repo ships a root main.py + vercel.json that re-export the same FastAPI app for Vercel's Python/FastAPI framework preset -- no code changes needed:
vercel link && vercel deploy --prodThis is exactly how the live demo is deployed.
GET /healthz- Health probe endpointGET /readyz- Readiness probe endpointGET /api/v1/domains- Specialized domains discovery
POST /api/v1/legal/review-contract- Execute comprehensive contract clause risk analysis and redline drafting.
POST /api/v1/medical/code-encounter- De-identify clinical documentation via HIPAA Safe Harbor and extract ICD-10/CPT codes.
POST /api/v1/supply-chain/optimize-inventory- Compute EOQ, Safety Stocks, ROP, and disruption risk scores.
POST /api/v1/domainx/analyze- Dynamic intent classification and expert agent routing.
POST /api/v1/ai/summarize- Narrates a deterministic agent result as a plain-English briefing via a free-tier local Ollama model, with an automatic deterministic-template fallback. See AI Executive Summary.
Run all 24 automated unit and integration tests (also run on every push/PR by CI):
pytest tests/ -vOutput:
tests/test_legal_agent.py::test_legal_contract_review_standard PASSED [ 4%]
tests/test_legal_agent.py::test_legal_contract_critical_risk PASSED [ 8%]
tests/test_medical_agent.py::test_medical_coding_and_hipaa PASSED [ 12%]
tests/test_medical_agent.py::test_drug_interaction_detection PASSED [ 16%]
tests/test_router.py::test_router_legal PASSED [ 20%]
tests/test_router.py::test_router_medical PASSED [ 25%]
tests/test_router.py::test_router_supply_chain PASSED [ 29%]
tests/test_router.py::test_router_unknown PASSED [ 33%]
tests/test_server.py::test_dashboard_root PASSED [ 37%]
tests/test_server.py::test_healthz PASSED [ 41%]
tests/test_server.py::test_readyz PASSED [ 45%]
tests/test_server.py::test_domains_list PASSED [ 50%]
tests/test_server.py::test_api_legal PASSED [ 54%]
tests/test_server.py::test_api_medical PASSED [ 58%]
tests/test_server.py::test_api_supply_chain PASSED [ 62%]
tests/test_supply_chain_agent.py::test_inventory_eoq_and_disruption PASSED [ 66%]
tests/test_ai_summary.py::test_fallback_used_when_ollama_unreachable PASSED [ 70%]
tests/test_ai_summary.py::test_fallback_legal_mentions_score_and_opinion PASSED [ 75%]
tests/test_ai_summary.py::test_fallback_medical_mentions_codes_and_alerts PASSED [ 79%]
tests/test_ai_summary.py::test_fallback_medical_no_alerts_case PASSED [ 83%]
tests/test_ai_summary.py::test_fallback_supply_chain_mentions_savings_and_risk PASSED [ 87%]
tests/test_ai_summary.py::test_fallback_unknown_domain PASSED [ 91%]
tests/test_ai_summary.py::test_ollama_success_path_is_used_when_reachable PASSED [ 95%]
tests/test_ai_summary.py::test_ai_summarize_endpoint_returns_summary PASSED [100%]
============================= 24 passed in 0.84s ==============================
For full Arabic enterprise documentation, see README.ar.md.
- Autonomy β the three specialist agents (Legal/Medical/Supply Chain) run deterministic rule engines, clinical ontologies, and closed-form optimization on their own; the optional LLM layer only narrates results that are already computed and correct.
- Resilience β the automatic deterministic fallback means the app never depends on an LLM being available: if Ollama isn't running, the verified numeric output still ships, just without the plain-English narration.
- Adaptivity β each vertical is a swappable agent behind the same framework, so a new high-stakes domain plugs in without touching the other two, and the free-tier LLM layer can be upgraded independently of the deterministic core.
- Expose each domain agent (Legal/Medical/Supply Chain) as an MCP tool so a larger multi-agent system can call DomainX's verified math instead of re-implementing it.
- Extend the Docker/Kubernetes deployment already documented below with autoscaling per domain agent as usage grows.
Built by Asadullah Shafique.
π Explore my portfolio showcasing Agentic AI projects and real-world applications: asadullahshafique-devunity.vercel.app