Skip to content

ronakranjan/nyaysetu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Nyaya Setu Platform

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.

πŸ“‹ Table of Contents

✨ Features

  • 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

πŸ“ Project Structure

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

πŸ›  Prerequisites

  • 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

πŸ“¦ Installation

1. Clone the Repository

git clone https://github.com/RonaK699/nyaysetu.git
cd nyaya-setu

2. Install Dependencies

# Install root dependencies
npm install

# Install frontend dependencies
cd frontend
npm install

# Install backend dependencies
cd ../backend
npm install

# Return to root
cd ..

3. Set Up Environment Variables

Frontend (.env in frontend/ directory):

VITE_API_URL=http://localhost:5000
VITE_FIREBASE_API_KEY=your_firebase_key
VITE_FIREBASE_PROJECT_ID=your_project_id

Backend (.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=false

πŸš€ Available Scripts

Root Level

npm 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 build

Frontend

cd 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 TypeScript

Backend

cd 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 report

πŸ›  Tech Stack

Frontend

Core 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

Backend

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

Shared

Type Definitions

  • Zod 3.24.2 - Schema validation and type inference

πŸ“‘ API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • POST /api/auth/logout - User logout
  • GET /api/auth/profile - Get user profile

Cases

  • GET /api/cases - Get all cases
  • GET /api/cases/:id - Get case details
  • POST /api/cases - Create new case
  • PUT /api/cases/:id - Update case
  • DELETE /api/cases/:id - Delete case
  • GET /api/cases/search - Search cases

Notifications

  • GET /api/notifications - Get notifications
  • POST /api/notifications - Create notification
  • PUT /api/notifications/:id - Update notification

SMS

  • POST /api/sms/incoming - Twilio SMS webhook (TwiML response)

Twilio IVR (Voice)

IVR (Twilio, DTMF-only, production)

  • POST /api/ivr - Entry point (language selection)
  • POST /api/ivr/language - Handles language selection
  • POST /api/ivr/service - Service selection (case status / next hearing date)
  • POST /api/ivr/court - Court-code selection via menu
  • POST /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 URLs
  • IVR_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" } }

Twilio Console setup:

  • Phone Numbers -> Manage -> Active Numbers -> (your number)
  • Voice Configuration -> "A CALL COMES IN"
    • Method: POST
    • URL: ${PUBLIC_BASE_URL}/api/ivr

Twilio IVR (Voice) (Legacy)

  • POST /api/twilio/voice - Entry point (language selection)
  • POST /api/twilio/language - Handles language selection
  • POST /api/twilio/cnr - Prompts the caller to speak the CNR
  • POST /api/twilio/case - Looks up case by CNR and reads a short summary
  • POST /api/twilio/next - Repeat / new search / end
  • POST /api/twilio/status - Optional call status callback (logs call status)

Admin

  • GET /api/admin/users - Get all users
  • GET /api/admin/cases - Get all cases
  • POST /api/admin/seed - Seed admin user

πŸ” Environment Setup

  1. Create MongoDB Atlas account and get connection string
  2. Set up Firebase project and get credentials
  3. Configure required third-party integrations (if any)
  4. Update all environment variables in .env files

Twilio IVR Setup (Live Demo)

  1. Expose your backend publicly (for local demo use a tunnel like ngrok).
  2. Set PUBLIC_BASE_URL in backend/.env to the public URL.
  3. 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
    • (Optional) Set Status Callback to:
      • Method: POST
      • URL: ${PUBLIC_BASE_URL}/api/twilio/status

Required env var:

  • PUBLIC_BASE_URL - Public backend base URL used to build absolute Twilio webhook URLs (example: https://xxxx.ngrok-free.app)

πŸš€ Deployment

Frontend

cd frontend
npm run build
# Deploy the dist folder to Netlify, Vercel, or any static hosting

Backend

cd backend
npm run build
# Deploy to Heroku, Railway, or any Node.js hosting

πŸ“ Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the ISC License - see the LICENSE file for details.

πŸ‘₯ Authors

  • Ronak - Initial work - GitHub

πŸ™ Acknowledgments

  • Indian e-courts system for case data
  • Radix UI for accessible components
  • TailwindCSS for styling utilities
  • Firebase for authentication services

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors