KO
arrow_back Home
ARCHITECTURE · v60

System Architecture

From question to verified answer — how Lawmadi OS works

8
Processing Layers
60
AI Legal Leaders
14,601
RAG Documents
20,798
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 psychology

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 auto_fix_high

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 edit_note

Stage 3 — Gemini Real-Time Streaming Analysis

Gemini 2.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 2.5 Flash SSE Token Streaming 5-Step Analysis Framework 2,500+ Character Depth
STAGE verified_user

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.

gavel

Current Statutes

Laws, enforcement decrees, and enforcement rules

balance

Supreme Court Precedents

Supreme Court and High Court case law

account_balance

Constitutional Court Decisions

Constitutional Court rulings and opinions

description

Administrative Rules & Ordinances

Directives, regulations, notices, and local ordinances

question_answer

Legal Interpretations

Official statutory interpretation cases

public

Treaties & Legal Terminology

International treaties and legal glossary

Technology Stack

smart_toy AI Engine

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

search RAG Search

Vertex AI Search — 14,601 legal documents indexed, extractive answers

api Backend

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

storage Database

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

language Frontend

Firebase Hosting — Korean/English static pages, PWA support

rocket_launch 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.

verified

SSOT_FACT_ONLY

All answers based on official statutory data in real-time

block

ZERO_INFERENCE

No self-generated legal citations or reasoning

front_hand

FAIL_CLOSED

Verification failure blocks the answer entirely

shield

IDENTITY

No encouragement of illegal acts or evidence tampering

schedule

TIMELINE_RULE

Law at time of act takes precedence; transitional provisions checked

link

SOURCE_TRANSPARENCY

Every citation includes law ID and enforcement date

chat Start Free Legal Analysis