How erdemhasates35/legal-ai-platform works
Legal AI Platform is a Turkish-law and ECHR research workspace centered on user-provided legal sources and fail-closed verification. The main workflow is to upload a document, analyze its extracted text, then verify claims against registered file or deontic-rule sources; advanced analysis can rank precedent citations. A separate courtroom workflow creates proceedings and simulates role-based assessments. The graph reflects documented capabilities and sampled calls; unsampled UI-to-API wiring and some storage details are not asserted.
Main entry points: analyze/route.ts Document analysis endpoint · server.ts Supabase session client · guards.ts Access guards · analysis/route.ts Advanced analysis endpoint
Components 29
Access and Workspace
- Dashboard
src/app/dashboard/page.tsx - Dashboard shell
src/components/layout/DashboardShell.tsx - Access guards
src/lib/auth/guards.ts - Tier entitlements
src/lib/auth/entitlements.ts - Admin approval
src/app/admin/page.tsx - User management
src/components/admin/AdminUserTable.tsx - Supabase session client
src/lib/supabase/server.ts
Legal Documents
- File upload interface
src/components/modules/FileUploadZone.tsx - Upload endpoint
src/app/api/upload/route.ts - File validation
src/lib/file-processor/file-validation.ts - Document analysis endpoint
src/app/api/document/analyze/route.ts - Enhanced extraction
src/lib/file-processor/enhanced-extract.ts - Text extraction and overlap
src/lib/file-processor/extract-text.ts - UYAP structure detection
src/lib/file-processor/uyap-udf.ts
Verification and Research
- Case analyzer
src/components/modules/CaseAnalyzerClient.tsx - Verification panel
src/components/modules/VerificationPanel.tsx - Verification endpoint
src/app/api/verify/route.ts - Fail-closed verification
src/lib/verification/pipeline.ts - Source registry
src/lib/verification/source-registry.ts - Advanced analysis endpoint
src/app/api/analysis/route.ts - Citation graph ranking
src/lib/citation/graph.ts - Deontic logic
src/lib/logic-engine/deontic.ts - Source-gated consortium
src/lib/academic-verifier/consortium.ts
Courtroom Simulation
- Courtroom workspace
src/app/courtroom/CourtroomClient.tsx - Proceeding creation
src/app/api/courtroom/proceedings/route.ts - Role-based simulation
src/app/api/courtroom/simulate/route.ts
Other components
- Legal researcher
- Supabase Auth, DB, Storage
- AI model providers
Connections 41
- Legal researcher → Dashboard: uses workspace
README.md - Dashboard → Dashboard shell: renders
src/app/dashboard/page.tsx - Dashboard → Access guards: checks access
src/app/dashboard/page.tsx - Dashboard → Tier entitlements: checks tier
src/app/dashboard/page.tsx - Access guards → Supabase session client: creates session client
src/lib/auth/guards.ts - Supabase session client → Supabase Auth, DB, Storage: accesses services
src/lib/supabase/server.ts - Admin approval → User management: renders
src/app/admin/page.tsx - Admin approval → Access guards: checks admin access
src/app/admin/page.tsx - File upload interface → Supabase Auth, DB, Storage: uses client
src/components/modules/FileUploadZone.tsx - Upload endpoint → Supabase session client: creates client
src/app/api/upload/route.ts - Upload endpoint → File validation: validates upload
src/app/api/upload/route.ts - Upload endpoint → Supabase Auth, DB, Storage: stores file and record
src/app/api/upload/route.ts - Document analysis endpoint → Access guards: checks profile
src/app/api/document/analyze/route.ts - Document analysis endpoint → Tier entitlements: checks tier
src/app/api/document/analyze/route.ts - Document analysis endpoint → Supabase session client: creates client
src/app/api/document/analyze/route.ts - Document analysis endpoint → Supabase Auth, DB, Storage: reads file and bytes
src/app/api/document/analyze/route.ts - Document analysis endpoint → Enhanced extraction: extracts text
src/app/api/document/analyze/route.ts - Enhanced extraction → Text extraction and overlap: delegates extraction
src/lib/file-processor/enhanced-extract.ts - Document analysis endpoint → UYAP structure detection: detects structure
src/app/api/document/analyze/route.ts - Document analysis endpoint → Text extraction and overlap: checks claim overlap
src/app/api/document/analyze/route.ts - Case analyzer → Verification panel: renders
src/components/modules/CaseAnalyzerClient.tsx - Verification endpoint → Supabase session client: creates client
src/app/api/verify/route.ts - Verification endpoint → Supabase Auth, DB, Storage: reads rules
src/app/api/verify/route.ts - Verification endpoint → Fail-closed verification: verifies claim
src/app/api/verify/route.ts - Advanced analysis endpoint → Access guards: checks profile
src/app/api/analysis/route.ts - Advanced analysis endpoint → Tier entitlements: checks tier
src/app/api/analysis/route.ts - Advanced analysis endpoint → Supabase session client: creates client
src/app/api/analysis/route.ts - Advanced analysis endpoint → Supabase Auth, DB, Storage: reads source records
src/app/api/analysis/route.ts - Advanced analysis endpoint → Fail-closed verification: verifies claim
src/app/api/analysis/route.ts - Advanced analysis endpoint → Citation graph ranking: ranks precedents
src/app/api/analysis/route.ts - Legal researcher → Courtroom workspace: uses courtroom
README.md - Proceeding creation → Access guards: checks profile
src/app/api/courtroom/proceedings/route.ts - Proceeding creation → Supabase session client: creates client
src/app/api/courtroom/proceedings/route.ts - Proceeding creation → Supabase Auth, DB, Storage: creates proceeding and session
src/app/api/courtroom/proceedings/route.ts - Role-based simulation → Access guards: checks profile
src/app/api/courtroom/simulate/route.ts - Role-based simulation → Supabase session client: creates client
src/app/api/courtroom/simulate/route.ts - Role-based simulation → Supabase Auth, DB, Storage: loads dossier and saves results
src/app/api/courtroom/simulate/route.ts - Role-based simulation → AI model providers: requests assessment
src/app/api/courtroom/simulate/route.ts - Legal researcher → Source-gated consortium: accesses research capability
README.md - Legal researcher → Deontic logic: uses formal rule capability
README.md - Legal researcher → Source registry: uses registered sources
README.md