How dhruthiaithal/themis-legal works
Project type and purpose
• This is a full-stack web application (“AI Legal Aid Platform”) that offers an AI-driven legal chatbot, document generation, and text summarization.
• Key features: React-based frontend, Node/Express backend, a separate Python FastAPI microservice for LLaMA inference, and a data directory holding legal texts and model files.
File structure
• Top-level directories:
• client/ – React SPA, serves UI pages (chatbot.html, login.html, etc.) and components under src/
• server/ – Node/Express server with REST routes (documentProcessing.js, digilockerSimulator.js)
• llama_service/ – FastAPI microservice (main.py) for LLaMA model inference
• data/ – static legal documents and a placeholder for the LLaMA model file
• Supporting files: .gitignore, package.json at root, README.md
• No traditional database: users.csv in server/ acts as a simple user store; legal-docs/*.txt are static content.
README for additional insights
• Architecture overview under “Project Structure.”
• Setup and run instructions for each component.
• API endpoints:
• Backend: GET /, POST /api/chat
• LLaMA: GET /, POST /api/llama
Main components
a. Frontend (React SPA)
• Components: Chatbot.jsx, DocumentProcessor.js, Navbar.jsx, Login.jsx
• Hosted by npm dev server at localhost:3000
b. Backend (Node/Express)
• Routes: /api/chat → handles incoming chat, invokes documentProcessing and/or proxies to LLaMA service
• digilockerSimulator.js (external integration simulator)
• Data store: users.csv, static files in data/legal-docs
c. LLaMA Service (FastAPI microservice)
• main.py: loads the LLaMA model file from data/llama-2-7b-chat.Q4_K_M.gguf
• Endpoint POST /api/llama to accept questions and return AI responses
d. Data Layer
• data/legal-docs/*.txt – source documents for summarization or form generation
• data/llama-2-7b-chat…gguf – LLaMA model binary (external resource)
e. External Services
• LLaMA open-source model loaded locally
• (Optional) Future extension: actual DigiLocker API
Relationships and interactions
• The React frontend issues REST calls to the Express backend (POST /api/chat, file uploads, form generation requests).
• The backend, upon receiving a chat or document operation, may:
• Read static legal docs from data/legal-docs
• Generate RTI or legal forms via server-side logic
• Forward queries to the LLaMA microservice (HTTP POST /api/llama) for AI responses
• The LLaMA service loads the model and returns generated text.
• All components run independently:
• Frontend (port 3000)
• Backend (port 5000, for example)
• LLaMA service (port 8000)
Architectural patterns and design principles
• Microservices: separate AI inference engine (FastAPI) from business logic (Express).
• SPA-backend separation: React frontend vs. REST API.
• File-based data storage for documents and lightweight CSV user store.
• Clear modularization: UI components, API routes, AI logic.
Elements
• Component names and technologies: React/JSX, Express/Node.js, FastAPI/Python, File System
• Ports or endpoints (e.g., :3000, :5000/api/chat, :8000/api/llama)
• Annotations on data assets (legal-docs/*.txt, llama-2-7b-chat…gguf, users.csv)