How elvismutinda/intelaw works
Intelaw is a Kenyan-law research and document-assistance product: users can create document-backed or case-law chats, ask legal questions, and generate drafts; the repository also includes account, subscription, and admin features. The main runtime is a Next.js client with authenticated API routes and database-backed chat history, alongside a separate FastAPI service and legal-material scraping tools. The graph shows only relationships visible in sampled code or the source index; unsampled settings and product areas are represented without guessed call paths.
Main entry points: caselaws/route.ts Case-law chat API · auth.ts Authentication · chat/route.ts Document chat API · create-chat/route.ts Document chat setup
Components 29
Web Experience
- Landing and legal pages
client/src/app/(nondashboard)/landing/page.tsx - Research chat UI
client/src/components/chat/Chat.tsx - Case-law browser
client/src/app/app/caselaws/[id]/page.tsx - Draft workspace
client/src/app/app/draft/[slug]/page.tsx - Account settings
client/src/app/app/settings/actions.ts
Legal Research
- Document chat API
client/src/app/api/chat/route.ts - Case-law chat API
client/src/app/api/caselaws/route.ts - Document chat setup
client/src/app/api/create-chat/route.ts - Case chat history API
client/src/app/api/case-messages/route.ts - Chat history API
client/src/app/api/history/route.ts - Context retrieval
client/src/lib/context.ts - Application database
client/src/lib/db/schema.ts - PDF file service
client/src/lib/cloudinary.ts - PDF indexing
client/src/lib/neon.ts
Accounts and Admin
- Admin reporting
client/src/app/admin/page.tsx - Authentication
client/auth.ts - Sign-in and registration
client/src/app/(auth)/login/page.tsx
AI Services
- Draft chat embedding API
local-llm/main.py - Draft generation
local-llm/draft.py - Hugging Face chat
local-llm/hf_model.py - Local model runner
local-llm/local_model.py
Legal Material Ingestion
- Scraper entry point
scraping/scraper.py - Case link collection
scraping/case_laws/case_link_scraper.py - Case download and metadata
scraping/case_laws/case_law_downloader.py - KLR case collection
scraping/new_klr/case_laws - KLR acts collection
scraping/new_klr/acts
Other components
- Legal user
- Hugging Face inference
- Kenya Law website
Connections 35
- Legal user → Landing and legal pages: browses
- Legal user → Sign-in and registration: signs in
- Sign-in and registration → Authentication: authenticates
- Legal user → Research chat UI: asks questions
- Research chat UI → Document chat API: submits chat
- Document chat API → Authentication: checks session
client/src/app/api/chat/route.ts - Document chat API → Context retrieval: gets context
client/src/app/api/chat/route.ts - Document chat API → Application database: reads and saves
client/src/app/api/chat/route.ts - Document chat API → Hugging Face inference: streams completion
client/src/app/api/chat/route.ts - Legal user → Case-law browser: opens case
- Case-law browser → Case-law chat API: asks case question
- Case-law chat API → Authentication: checks session
client/src/app/api/caselaws/route.ts - Case-law chat API → Context retrieval: gets case context
client/src/app/api/caselaws/route.ts - Case-law chat API → Application database: reads and saves
client/src/app/api/caselaws/route.ts - Case-law chat API → Hugging Face inference: streams completion
client/src/app/api/caselaws/route.ts - Case-law chat API → KLR case collection: loads case text
client/src/app/api/caselaws/route.ts - Legal user → Draft workspace: requests draft
- Legal user → Account settings: manages account
- Legal user → Admin reporting: administers
- Document chat setup → Authentication: checks session
client/src/app/api/create-chat/route.ts - Document chat setup → PDF indexing: indexes PDF
client/src/app/api/create-chat/route.ts - Document chat setup → PDF file service: resolves file URL
client/src/app/api/create-chat/route.ts - Document chat setup → Application database: creates chat
client/src/app/api/create-chat/route.ts - Case chat history API → Authentication: checks session
client/src/app/api/case-messages/route.ts - Case chat history API → Application database: reads messages
client/src/app/api/case-messages/route.ts - Chat history API → Authentication: checks session
client/src/app/api/history/route.ts - Legal user → Draft chat embedding API: requests draft or chat
- Draft chat embedding API → Draft generation: generates draft
local-llm/main.py - Draft chat embedding API → Hugging Face chat: runs chat
local-llm/main.py - Draft generation → Local model runner: runs model
local-llm/draft.py - Hugging Face chat → Hugging Face inference: sends inference
local-llm/hf_model.py - Scraper entry point → Case link collection: uses links
scraping/scraper.py - Scraper entry point → Case download and metadata: downloads cases
scraping/scraper.py - Case link collection → Kenya Law website: collects links
- Case download and metadata → Kenya Law website: downloads materials