--- title: Nyaya Agent Legal Platform emoji: πŸ›οΈ colorFrom: yellow colorTo: gray sdk: docker pinned: false app_port: 7860 --- # πŸ›οΈ Nyaya Agent: Premium Legal AI Platform Nyaya Agent is a state-of-the-art, persona-aware legal assistant built specifically for the Indian Judiciary system. It provides citizens, law students, and legal professionals with intelligent legal research, automated drafting, compliance auditing, and case law retrievalβ€”all wrapped in a stunning, modern glassmorphic user interface. ## ✨ Core Features - **βš–οΈ Law BRIDGE (IPC to BNS)**: Instantly translate and map old criminal laws (IPC, CrPC, IEA) to the newly enacted criminal laws (Bharatiya Nyaya Sanhita, BNSS, BSA). - **πŸ›‘οΈ Compliance Audit (DPDPA 2023)**: Upload legal documents (PDF/TXT) via the interactive chat interface and run automated compliance audits against the Digital Personal Data Protection Act, 2023. - **πŸ” Case Network (Indian Kanoon Integration)**: Perform live legal research. Retrieve landmark Supreme Court judgments, case summaries, and precedent analysis directly from the Indian Kanoon database. - **πŸ“œ Smart Document Drafting**: Generate precise Right to Information (RTI) applications and formal Legal Notices. Features interactive, dynamically generated UI forms to collect missing details, and supports iterative drafting (Edit Draft) while maintaining full conversation context. - **πŸ“₯ Export Options**: One-click download of generated legal drafts into formatted DOC or PDF files, or copy directly to clipboard. - **🎭 Persona-Aware AI**: The agent dynamically shifts its tone and technical depth. It explains simple concepts to citizens while providing deep statutory analysis and case citations to lawyers. ## πŸ› οΈ Technology Stack **Backend & Databases** - **Python 3 & FastAPI**: High-performance asynchronous API server handling document parsing and AI orchestration. - **Google Gemini 2.0 Flash**: State-of-the-art Large Language Model powering the core intelligence, legal reasoning, and JSON-based form routing. - **ChromaDB**: Persistent Vector Database used to store and retrieve dense vector embeddings for RAG (Retrieval-Augmented Generation) on legal documents. - **Indian Kanoon API**: External integration for live querying of Indian legal statutes, Supreme Court judgments, and case precedents. - **LangChain**: Orchestrates tool calling and search capabilities. - **PyPDF**: Extracts text from uploaded legal documents for the compliance engine. **Frontend** - **Vanilla HTML5, CSS3, JavaScript**: A completely bespoke, lightweight frontend. No heavy frameworks. - **Glassmorphic UI**: Beautiful, premium aesthetic featuring translucent panels, blur effects, animated gradients, and gold accents (`#C5A059`) inspired by judicial elegance. - **Dynamic DOM Manipulation**: LLM-driven UI generation, securely converting JSON tool requests from the AI directly into interactive HTML forms. **Deployment & DevOps** - **Docker / Podman**: Fully containerized application for identical local and production environments. - **Hugging Face Spaces**: Hosted seamlessly as a Docker Space on Hugging Face infrastructure. ## πŸš€ Local Development Workflow ### Prerequisites - Docker or Podman Desktop installed. - A valid Google Gemini API Key. ### 1. Environment Setup Create a `.env` file in the root directory and add your API key: ```env GEMINI_API_KEY=your_gemini_api_key_here PORT=7860 ``` ### 2. Build and Run Use Docker Compose (or Podman Compose) to build and start the application: ```bash docker-compose up -d --build ``` *(If using Podman, replace `docker-compose` with `podman compose`)* ### 3. Access the Application Once the container is running, open your web browser and navigate to: ```text http://localhost:7860 ``` ## πŸ” Security & Privacy - **Stateless Architecture**: Uploaded documents and chat histories are processed entirely in-memory and are not persisted to a database, ensuring maximum privacy for sensitive legal queries. - **API Key Protection**: `.env` and `.venv` files are strictly git-ignored and docker-ignored to prevent credential leaks. --- *Satyameva Jayate - Truth Alone Triumphs*