How abegerov4/qorgauai works
QorgauAI is a Kazakhstan legal assistant whose main workflow streams a question through retrieval, tool-assisted research, answer generation and a second-agent citation check, returning claims with legal citations and visible progress. A separate document workflow masks personal data, extracts contract clauses, gathers legal evidence, and verifies clause verdicts before presenting a color-coded review and downloadable report. The README also documents dense-versus-hybrid search comparison, chat history, feedback, quotas and administration. The graph reflects documented routes and sampled calls; several internal links are omitted where excerpts do not establish wiring.
Main entry points: routes.py Request routes · QorgauApp.tsx Qorgau app · search.py Legal search · main.py FastAPI app
Components 25
Web experience
- Qorgau app
frontend/components/QorgauApp.tsx - Chat and answers
frontend/components/AnswerCard.tsx - Review interface
frontend/components/ContractReview.tsx - API client
frontend/lib/api.ts - Session token
frontend/app/api/token/route.ts
API and accounts
- FastAPI app
backend/app/main.py - Request routes
backend/app/api/routes.py - Authentication
backend/app/accounts/auth.py - Usage and admin
backend/app/accounts/service.py
Legal research
- Answer agent
backend/app/agents/graph.py - Legal tool client
backend/app/agents/toolbox.py - MCP legal tools
backend/app/mcp_tools/server.py - Legal search
backend/app/retrieval/search.py - Embeddings
backend/app/retrieval/embeddings.py - Legal corpus index
backend/app/retrieval/qdrant_setup.py
Contract review
- Document ingestion
backend/app/ingestion/documents.py - PII and input safeguards
backend/app/guardrails/pii.py - Clause review
backend/app/agents/review.py - PDF report
backend/app/reports/review_pdf.py
State and observability
- Account database
backend/app/accounts/db.py - Tracing and costs
backend/app/observability.py
Other components
- User
- Browser
- OpenAI models
- Langfuse
Connections 29
- User → Qorgau app: uses
- Qorgau app → Chat and answers: renders
- Qorgau app → Review interface: renders
- Chat and answers → API client: submits questions
- Review interface → API client: uploads contract
- Qorgau app → Session token: requests token
- API client → Browser: calls API
- Browser → FastAPI app: sends requests
- FastAPI app → Request routes: mounts routes
- Request routes → Authentication: checks user
- Request routes → Answer agent: runs answer graph
- Answer agent → Legal tool client: invokes tools
- Legal tool client → MCP legal tools: dispatches calls
- MCP legal tools → Legal search: searches corpus
- Legal search → Embeddings: embeds queries
- Legal search → Legal corpus index: queries index
- Embeddings → OpenAI models: dense embeddings
- Request routes → Document ingestion: reads upload
- Document ingestion → PII and input safeguards: masks personal data
- Request routes → Clause review: reviews document
- Clause review → Legal search: retrieves evidence
- Request routes → PDF report: renders report
- Request routes → Usage and admin: records usage
- Usage and admin → Account database: reads and writes
- Request routes → Account database: stores account data
- Answer agent → OpenAI models: generates and verifies
- Clause review → OpenAI models: assesses clauses
- FastAPI app → Tracing and costs: flushes traces
- Tracing and costs → Langfuse: sends telemetry