A comprehensive legal case management platform that helps users track, manage, and receive notifications about their legal cases. The platform integrates with e-courts systems, provides IVR support, and real-time hearing updates.
- Features
- Project Structure
- Prerequisites
- Installation
- Available Scripts
- Tech Stack
- Environment Variables
- API Documentation
- Contributing
- License
- Case Tracking: Real-time tracking of legal cases with status updates
- e-Courts Integration: Automated scraping and integration with Indian e-courts system
- IVR Support: Interactive voice response system for case inquiries
- Hearing Notifications: Automated hearing reminders and updates
- User Authentication: Secure JWT-based authentication
- Admin Dashboard: Comprehensive admin panel for case management
- Search & Filter: Advanced case search with multiple filters
nyaya-setu/
βββ frontend/ # React frontend application
β βββ client/
β β βββ src/
β β βββ components/ # Reusable UI components
β β β βββ ui/ # shadcn/ui components
β β β βββ forms/ # Form components
β β β βββ navigation.tsx # Navigation component
β β β βββ ...
β β βββ pages/ # Page components
β β β βββ case-search.tsx
β β β βββ case-detail.tsx
β β β βββ dashboard.tsx
β β β βββ login.tsx
β β β βββ ...
β β βββ services/ # API services
β β β βββ auth.service.ts
β β βββ lib/ # Utility functions
β β β βββ queryClient.ts
β β β βββ auth-context.tsx
β β β βββ ...
β β βββ hooks/ # Custom React hooks
β β βββ App.tsx # Main App component
β β βββ main.tsx # Entry point
β β βββ index.css # Global styles
β βββ vite.config.ts # Vite configuration
β βββ tailwind.config.ts # Tailwind CSS configuration
β βββ postcss.config.js # PostCSS configuration
β βββ components.json # shadcn/ui configuration
β βββ package.json # Frontend dependencies
β βββ .env # Frontend environment variables
β
βββ backend/ # Node.js/Express backend
β βββ src/
β β βββ config/ # Configuration files
β β β βββ database.js
β β βββ controllers/ # Route controllers
β β β βββ authController.js
β β β βββ caseController.js
β β β βββ userController.js
β β β βββ adminController.js
β β β βββ notificationController.js
β β β βββ subscriptionController.js
β β β βββ scrapperController.js
β β β βββ ...
β β βββ models/ # MongoDB schemas
β β β βββ User.js
β β β βββ Case.js
β β β βββ Notification.js
β β β βββ ...
β β βββ routes/ # API routes
β β β βββ auth.js
β β β βββ cases.js
β β β βββ users.js
β β β βββ admin.js
β β β βββ notifications.js
β β β βββ subscriptions.js
β β β βββ scraper.js
β β β βββ ...
β β βββ services/ # Business logic
β β β βββ authService.js
β β β βββ caseService.js
β β β βββ notificationService.js
β β β βββ scrapperService.js
β β β βββ ivrService.js
β β β βββ ...
β β βββ middlewares/ # Express middlewares
β β β βββ authMiddleware.js
β β β βββ errorHandler.js
β β β βββ ...
β β βββ validators/ # Input validation schemas
β β β βββ authValidator.js
β β β βββ caseValidator.js
β β β βββ ...
β β βββ jobs/ # Scheduled jobs
β β β βββ cronJobs.js
β β βββ scripts/ # Utility scripts
β β β βββ seedAdmin.js
β β β βββ ...
β β βββ utils/ # Utility functions
β β βββ index.js # Entry point
β βββ package.json # Backend dependencies
β βββ .env # Backend environment variables
β βββ tsconfig.json # TypeScript configuration
β
βββ types/ # Shared TypeScript types
β βββ schema.ts # Zod schemas and types
β
βββ .gitignore # Git ignore rules
βββ package.json # Root package.json (workspaces)
βββ README.md # This file
- Node.js: v18.0.0 or higher
- npm: v8.0.0 or higher
- MongoDB: v5.0 or higher (local or cloud instance)
- Git: For version control
git clone https://github.com/RonaK699/nyaysetu.git
cd nyaya-setu# Install root dependencies
npm install
# Install frontend dependencies
cd frontend
npm install
# Install backend dependencies
cd ../backend
npm install
# Return to root
cd ..Frontend (.env in frontend/ directory):
VITE_API_URL=http://localhost:5000
VITE_FIREBASE_API_KEY=your_firebase_key
VITE_FIREBASE_PROJECT_ID=your_project_idBackend (.env in backend/ directory):
PORT=5000
NODE_ENV=development
FRONTEND_ORIGIN=http://localhost:5173
MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/?appName=Cluster
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=7d
ADMIN_EMAIL=admin@nyaysetu.com
ADMIN_PASSWORD=admin123
ADMIN_NAME=Admin User
ECOURT_BASE_URL=https://api.ecourts.gov.in
ECOURT_SCRAPE_URL=https://services.ecourts.gov.in/ecourtindia_v6/
ECOURT_CACHE_TTL_HOURS=24
ECOURT_DELAY_MIN_MS=1000
ECOURT_DELAY_MAX_MS=3000
ECOURT_MAX_RETRIES=3
ECOURT_TIMEOUT_MS=30000
USE_ECOURT_SCRAPER=true
USE_MOCK_CASES=falsenpm run dev # Start both frontend and backend in development mode
npm run dev:frontend # Start only the frontend
npm run dev:backend # Start only the backend
npm run build # Build the frontend for production
npm run preview # Preview the production buildcd frontend
npm run dev # Start Vite dev server
npm run build # Build for production
npm run preview # Preview production build
npm run check # Type check with TypeScriptcd backend
npm run dev # Start with nodemon and ts-node (watches for changes)
npm run start # Start production server
npm run build # Build TypeScript to JavaScript
npm run build:ts # Compile TypeScript only
npm run clean # Remove dist folder
npm run lint # Run ESLint
npm run format # Format code with Prettier
npm run seed:admin # Seed admin user to database
npm run test # Run Jest tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Generate test coverage reportCore Framework
- React 18.3.1 - UI library
- TypeScript 5.6.3 - Type safety
- Vite 5.4.20 - Build tool and dev server
UI & Styling
- Tailwind CSS 3.4.17 - Utility-first CSS framework
- shadcn/ui - High-quality React components
- Radix UI - Unstyled, accessible components
- Lucide React - Icon library
- Framer Motion 11.13.1 - Animation library
State Management & Data Fetching
- TanStack React Query 5.60.5 - Server state management
- React Hook Form 7.55.0 - Form state management
- Zod 3.24.2 - Schema validation
Routing & Navigation
- Wouter 3.3.5 - Lightweight routing library
Authentication
- Firebase 10.7.0 - Authentication and database
Utilities
- date-fns 3.6.0 - Date manipulation
- clsx 2.1.1 - Conditional className utility
- next-themes 0.4.6 - Theme management
Core Framework
- Express 4.21.2 - Web framework
- Node.js 18+ - Runtime environment
- TypeScript 5.0.0 - Type safety
Database
- MongoDB 8.20.1 - NoSQL database
- Mongoose - MongoDB ODM
Authentication & Security
- JWT (jsonwebtoken 9.0.2) - Token-based authentication
- bcrypt 6.0.0 - Password hashing
- bcryptjs 2.4.3 - Alternative password hashing
- Helmet 7.1.0 - Security headers
- CORS 2.8.5 - Cross-origin resource sharing
- express-rate-limit 7.1.5 - Rate limiting
Validation & Error Handling
- Joi 17.13.3 - Schema validation
Logging & Monitoring
- Winston 3.11.0 - Logging library
- Morgan 1.10.0 - HTTP request logger
Web Scraping & Automation
- Playwright 1.57.0 - Browser automation for e-courts scraping
- Axios 1.6.2 - HTTP client
Task Scheduling
- node-cron 3.0.3 - Cron job scheduler
Development Tools
- nodemon 3.0.2 - Auto-restart on file changes
- ts-node 10.9.0 - TypeScript execution
- ESLint 8.0.0 - Code linting
- Prettier 3.0.0 - Code formatting
- Jest 29.7.0 - Testing framework
Type Definitions
- Zod 3.24.2 - Schema validation and type inference
POST /api/auth/register- User registrationPOST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/auth/profile- Get user profile
GET /api/cases- Get all casesGET /api/cases/:id- Get case detailsPOST /api/cases- Create new casePUT /api/cases/:id- Update caseDELETE /api/cases/:id- Delete caseGET /api/cases/search- Search cases
GET /api/notifications- Get notificationsPOST /api/notifications- Create notificationPUT /api/notifications/:id- Update notification
POST /api/sms/incoming- Twilio SMS webhook (TwiML response)
POST /api/ivr- Entry point (language selection)POST /api/ivr/language- Handles language selectionPOST /api/ivr/service- Service selection (case status / next hearing date)POST /api/ivr/court- Court-code selection via menuPOST /api/ivr/cnr- Accepts 12-digit numeric part (DTMF) and returns the requested detail
Judge explanation:
"Because CNR numbers contain letters, which are difficult to enter via IVR, we collect the numeric part via keypad and derive the court code using guided menus. The full CNR is reconstructed on the backend as COURT_CODE + NUMERIC_PART."
Configuration:
PUBLIC_BASE_URL- Public backend base URL used to build absolute Twilio webhook URLsIVR_COURT_CODE_MAP_JSON(optional) - JSON mapping for court menu digits to 4-letter court codes. Defaults to the demo mapping.- Example:
{ "1": { "name": "District Court", "code": "ABCD" }, "2": { "name": "High Court", "code": "EFGH" }, "3": { "name": "Supreme Court", "code": "IJKL" } }
- Example:
Twilio Console setup:
- Phone Numbers -> Manage -> Active Numbers -> (your number)
- Voice Configuration -> "A CALL COMES IN"
- Method:
POST - URL:
${PUBLIC_BASE_URL}/api/ivr
- Method:
POST /api/twilio/voice- Entry point (language selection)POST /api/twilio/language- Handles language selectionPOST /api/twilio/cnr- Prompts the caller to speak the CNRPOST /api/twilio/case- Looks up case by CNR and reads a short summaryPOST /api/twilio/next- Repeat / new search / endPOST /api/twilio/status- Optional call status callback (logs call status)
GET /api/admin/users- Get all usersGET /api/admin/cases- Get all casesPOST /api/admin/seed- Seed admin user
- Create MongoDB Atlas account and get connection string
- Set up Firebase project and get credentials
- Configure required third-party integrations (if any)
- Update all environment variables in
.envfiles
- Expose your backend publicly (for local demo use a tunnel like ngrok).
- Set
PUBLIC_BASE_URLinbackend/.envto the public URL. - In Twilio Console:
- Go to Phone Numbers -> Manage -> Active Numbers -> (your number)
- In "Voice Configuration" set "A CALL COMES IN" to:
- Method:
POST - URL:
${PUBLIC_BASE_URL}/api/ivr
- Method:
- (Optional) Set Status Callback to:
- Method:
POST - URL:
${PUBLIC_BASE_URL}/api/twilio/status
- Method:
Required env var:
PUBLIC_BASE_URL- Public backend base URL used to build absolute Twilio webhook URLs (example:https://xxxx.ngrok-free.app)
cd frontend
npm run build
# Deploy the dist folder to Netlify, Vercel, or any static hostingcd backend
npm run build
# Deploy to Heroku, Railway, or any Node.js hosting- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
- Ronak - Initial work - GitHub
- Indian e-courts system for case data
- Radix UI for accessible components
- TailwindCSS for styling utilities
- Firebase for authentication services