KO
Home
ARCHITECTURE · v60

System Architecture

From question to verified answer — how Lawmadi OS works

8
Processing Layers
60
AI Legal Leaders
43,652
RAG Documents
31,024
Cached Statute Articles
100%
DRF Verification

4-Stage Hybrid Pipeline

Every legal query passes through a 4-stage pipeline to produce verified answers. Each stage has independent failure detection and recovery. If verification fails, the system blocks the answer (Fail-Closed policy).

STAGE

Stage 0+1 — Classification + RAG Search (Parallel)

NLU intent analysis assigns the optimal leader from 60 specialists while simultaneously searching Vertex AI Search and the statute cache for relevant laws and precedents. 3-tier routing classifies queries: greeting, non-legal, or legal.

NLU Intent Analysis Keyword Matching Vertex AI Search Auto Leader Assignment
STAGE

Stage 1.5~1.7 — Statute Enrichment

Injects the assigned leader's core statutes (LAW_BOOST), links delegation clauses and enforcement decree forms via 3-tier comparison, and pre-fetches full article text from the DRF API to maximize accuracy.

LAW_BOOST Injection 3-Tier Comparison DRF Article Pre-fetch
STAGE

Stage 3 — Gemini Real-Time Streaming Analysis

Gemini 3.5 Flash generates answers via real-time SSE streaming, using the leader's persona and RAG context. Responses follow a 5-step framework: Empathize, Diagnose, Action Roadmap, Safety Net, and Closing.

Gemini 3.5 Flash SSE Token Streaming 5-Step Analysis Framework 2,500+ Character Depth
STAGE

Stage 4 — DRF Full Verification (Fail-Closed)

Every statute, precedent, and constitutional court decision cited in the answer is cross-verified in real-time against Korea's National Law Information Center (law.go.kr) DRF API. If unverified citations exceed 0.1%, the answer is blocked. Verified corrections replace text in real-time.

Real-Time DRF Cross-Verification Fail-Closed Policy answer_replace Live Swap Audit Logging

8-Layer Processing Architecture

Lawmadi OS is designed like an operating system with 8 independent layers, each performing a specialized role.

L0
KERNEL
Orchestration, Circuit Breaker, Rate Limiter
L1
VISION
Legal Document OCR & Layout Analysis
L2
SWARM
60-Agent Multi-Agent Parallel Processing
L3
SHORT_SYNC
Real-Time Legal Data Integration
L4
PERSONA
Adaptive Interaction & Crisis Detection
L5
JURISPRUDENCE
Precedent Matching & Temporal Validation
L6
SCENARIO
Legal Routes, Risk & Deadline Calculation
L7
RENDERER
Legal Basis / Reference Segregated Output

SSOT Data Sources

All answers are grounded in Korea's official legal databases (Single Source of Truth). Self-generated inference or fabrication is strictly prohibited.

Current Statutes

Laws, enforcement decrees, and enforcement rules

Supreme Court Precedents

Supreme Court and High Court case law

Constitutional Court Decisions

Constitutional Court rulings and opinions

Administrative Rules & Ordinances

Directives, regulations, notices, and local ordinances

Legal Interpretations

Official statutory interpretation cases

Treaties & Legal Terminology

International treaties and legal glossary

Technology Stack

AI Engine

Gemini 3.5 Flash — real-time SSE streaming, 429 exponential backoff

RAG Search

Vertex AI Search — 43,652 legal documents indexed, extractive answers

Backend

FastAPI + Uvicorn — async Python on Cloud Run (Seoul region)

Database

Cloud SQL PostgreSQL 17 — statute cache, audit logs, session management

Frontend

Firebase Hosting — Korean/English static pages, PWA support

CI/CD

GitHub Actions 5-stage — Test, Staging, Production, Frontend, Notify

6 Constitutional Principles

Every answer in Lawmadi OS is governed by 6 constitutional principles. These are enforced at code level with zero exceptions.

SSOT_FACT_ONLY

All answers based on official statutory data in real-time

ZERO_INFERENCE

No self-generated legal citations or reasoning

FAIL_CLOSED

Verification failure blocks the answer entirely

IDENTITY

No encouragement of illegal acts or evidence tampering

TIMELINE_RULE

Law at time of act takes precedence; transitional provisions checked

SOURCE_TRANSPARENCY

Every citation includes law ID and enforcement date

Start Free Legal Analysis