This guide covers the technical setup required to get Nyay Saarthi running locally, including database configuration, environment variables, and Docker orchestration.
- Prerequisites
- Environment Variables
- Google OAuth Setup
- Option A: Docker Deployment (Recommended)
- Option B: Manual Local Setup
- Database Structure
- Troubleshooting
Ensure you have the following installed before proceeding:
- Node.js
>= 20.x - Java
17 - Maven
3.9+ - PostgreSQL
15+ - Python
3.12+(for NLP Orchestrator) - Docker & Docker Compose (highly recommended)
You will also need a Groq API Key for the AI features. You can get one for free at console.groq.com.
Copy the provided .env.example file to create your own .env file at the root of the project:
cp .env.example .envThe root .env.example file is the source of truth for local configuration. It includes safe sample values for the backend, frontend, NLP orchestrator, LawGPT service, Docker Compose, and optional integrations such as Gemini, Indian Kanoon, Azure, Bhashini, and Hugging Face.
At minimum, set these values before starting the full stack:
DB_USERNAME=postgres
DB_PASSWORD=your_secure_password
JWT_SECRET=replace_with_a_long_random_256_bit_secret
GROQ_API_KEY=your_groq_api_key_here
FRONTEND_URL=http://localhost:5173
CORS_ALLOWED_ORIGINS=http://localhost:5173,http://localhost
# ── Google OAuth2 Configuration ──────────────
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# ── Frontend Environment Variables ──────────────
VITE_API_BASE_URL=http://localhost:8080
VITE_GOOGLE_CLIENT_ID=your_google_client_id
CORS_ALLOWED_ORIGINS=http://localhost:5173,http://localhost:4174,http://localhost:3000Optional providers can be left blank unless you are using those features. Do not commit a filled .env file.
Production requirement: When running with
SPRING_PROFILES_ACTIVE=prod, you must setJWT_SECRETas an environment variable. The backend now fails fast at startup in production ifJWT_SECRETis missing or falls back to the default development secret.
-
Open Google Cloud Console
-
Create OAuth Client ID
-
Add Redirect URI
http://localhost:8080/login/oauth2/code/google
- Add Frontend Origin
http://localhost:5173
- Add credentials in
.env
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
VITE_GOOGLE_CLIENT_ID=
The easiest way to run the entire stack (Database, Spring Boot Backend, Python NLP Orchestrator, and React Frontend) is via Docker Compose.
- Ensure Docker Desktop is running.
- Verify your
.envfile is properly configured. - Run the following command from the root directory:
docker-compose up --build -d| Service | URL |
|---|---|
| Frontend (React) | http://localhost (Port 80) |
| Backend API (Spring Boot) | http://localhost:8080 |
| NLP Orchestrator (FastAPI) | http://localhost:8001 |
| PostgreSQL Database | localhost:5432 |
To view logs:
docker-compose logs -fIf you prefer to run the services individually for development, follow these steps in order.
Ensure PostgreSQL is running locally on port 5432. Create the database:
psql -U postgres -c "CREATE DATABASE nyaysetu;"This service handles AI prompt generation and processing.
cd nlp-orchestrator
pip install -r requirements.txt
# Requires GROQ_API_KEY to be set in your terminal or .env
uvicorn main:app --reload --port 8001The Spring Boot backend will automatically run Flyway migrations to set up the database tables on startup.
cd backend/nyaysetu-backend
# Ensure the backend can read the root .env file, or export the vars manually
mvn spring-boot:runRuns on http://localhost:8080
cd frontend/nyaysetu-frontend
npm install
npm run devRuns on http://localhost:5173
When the backend starts successfully, it will create several tables. Key tables include:
users: Core user accounts and roles.cases: Case details, status, and assignments.evidence: Hashed evidence metadata.firs: Police first information reports.court_hearings: Scheduled virtual hearings.
If you have the development DataLoader enabled, these test accounts are seeded on startup:
- Admin:
admin@nyaysetu.com/admin123 - Judge:
judge@nyaysetu.com/judge123 - Lawyer:
lawyer@nyaysetu.com/lawyer123
| Issue | Solution |
|---|---|
| Database Connection Refused | Ensure PostgreSQL is running and credentials match your .env file. |
| JWT Signature Exception | Your JWT_SECRET is too short or changed. It must be at least 256 bits. |
| CORS Errors on Login | Ensure CORS_ALLOWED_ORIGINS in your .env matches your exact frontend URL (including the port). |
| AI Features Not Working | Verify GROQ_API_KEY is valid and the NLP Orchestrator is running on port 8001. |