เคธเฅเคตเคเฅเค เคจเคเคฐ means "Clean City" in Hindi โ a fitting name for a platform that digitizes and streamlines urban waste collection, routing, and citizen reporting.
SwachhNagar is a full-stack web application for managing municipal waste operations. It provides a role-based dashboard for admins, field staff, and citizens to coordinate collection schedules, manage vehicles and routes, track complaints, and visualize analytics โ all in one platform.
- Overview
- Key Features
- User Roles
- Tech Stack
- Project Structure
- Getting Started
- Environment & Configuration
- Pages & Modules
- Troubleshooting
- Roadmap
- Contributing
- License
Urban waste management in Indian cities is largely undigitized โ collection schedules are inconsistent, citizens have no way to report issues, and municipal staff work without route optimization or tracking tools.
SwachhNagar addresses this by providing:
- A centralized dashboard for admins to manage routes, vehicles, and staff
- Digital scheduling so collection times are predictable and trackable
- A citizen portal to submit complaints and receive notifications
- Analytics & reports to measure collection efficiency over time
The app uses a React + TypeScript frontend and a Node.js + Express backend, with support for multiple authentication contexts and role-based access control.
| Feature | Description |
|---|---|
| ๐ Role-Based Auth | Separate access levels for Admin, Staff, and Citizen |
| ๐ Collection Scheduling | Create and manage waste pickup schedules by zone |
| ๐บ๏ธ Route Management | Define and optimize collection routes for field staff |
| ๐ Vehicle Management | Track vehicles, assign to routes, monitor availability |
| ๐ข Citizen Reporting | Citizens can submit waste-related complaints and issues |
| ๐ Notifications | Status updates sent to citizens on complaint resolution |
| ๐ Analytics Dashboard | Visual reports on collection rates, complaints, and performance |
| ๐ฅ User Management | Admin can add/remove staff and citizen accounts |
- Full access to all modules
- Manages staff accounts, routes, vehicles, and zones
- Views analytics and generates reports
- Reviews and resolves citizen complaints
- Views assigned routes and schedules
- Updates collection status (pending / in-progress / completed)
- Receives task assignments from admin
- Registers and logs in to the portal
- Submits waste collection complaints with location details
- Tracks the status of their submitted reports
- Receives notifications on resolution
| Technology | Purpose |
|---|---|
| React 18 | UI component library |
| TypeScript | Type-safe frontend code |
| Vite | Fast build tool and dev server |
| React Router DOM | Client-side routing |
| Axios | HTTP client for API calls |
| Technology | Purpose |
|---|---|
| Node.js | JavaScript runtime |
| Express.js | REST API framework |
| MongoDB (optional) | Persistent database (demo uses in-memory seeds) |
| JWT | Stateless authentication tokens |
waste_management_system/
โ
โโโ backend/ # Node.js + Express REST API
โ โโโ routes/ # API route handlers
โ โ โโโ auth.js # Login, register, token refresh
โ โ โโโ collections.js # Collection schedule CRUD
โ โ โโโ routes.js # Route management
โ โ โโโ vehicles.js # Vehicle management
โ โ โโโ complaints.js # Citizen complaint CRUD
โ โ โโโ users.js # User management
โ โโโ models/ # Data models / schemas
โ โโโ config.js # Server configuration
โ โโโ config_fixed.js # Alternate config variant
โ โโโ index.js # App entry point
โ
โโโ frontend/ # React + TypeScript + Vite SPA
โ โโโ src/
โ โ โโโ context/
โ โ โ โโโ AuthContext.tsx # Primary auth context
โ โ โ โโโ AuthContext_fixed.tsx # Fixed/stable auth variant
โ โ โ โโโ AuthContext_backend.tsx# Backend-integrated auth variant
โ โ โโโ components/
โ โ โ โโโ pages/
โ โ โ โ โโโ Dashboard.tsx # Main admin/staff home
โ โ โ โ โโโ Analytics.tsx # Charts and performance reports
โ โ โ โ โโโ Collections.tsx # Schedule management
โ โ โ โ โโโ Routes.tsx # Route management
โ โ โ โ โโโ Vehicles.tsx # Vehicle management
โ โ โ โ โโโ Complaints.tsx # Citizen complaint tracking
โ โ โ โ โโโ Users.tsx # User management (admin)
โ โ โ โ โโโ Notifications.tsx # Notification center
โ โ โ โโโ shared/ # Reusable UI components
โ โ โโโ main.tsx # App entry point
โ โ โโโ main_fixed.tsx # Alternate entry (App_fixed variant)
โ โ โโโ App_fixed.tsx # Stable app variant
โ โโโ index.html # HTML root (points to main_fixed.tsx)
โ โโโ vite.config.ts
โ
โโโ .gitignore
โโโ README.md
- Node.js v18+ โ Download
- npm or yarn
- (Optional) MongoDB for persistent storage โ demo works with in-memory seeds
# Navigate to the backend directory
cd backend
# Install dependencies
npm install
# Start the development server
npm run dev
# or
node index.jsThe backend will start on the port defined in backend/config.js. Check the terminal for the exact port (usually http://localhost:5000).
# Navigate to the frontend directory
cd frontend
# Install dependencies
npm install
# Start the Vite development server
npm run devThe app will be available at http://localhost:5173.
Note:
index.htmlcurrently points tosrc/main_fixed.tsxwhich renders theApp_fixedvariant. If you want to use the originalmain.tsx/App.tsx, update the<script>tag inindex.htmlaccordingly.
PORT=5000
MONGO_URI=mongodb://localhost:27017/swacchnagar
JWT_SECRET=your_jwt_secret_key_here
NODE_ENV=developmentDifferent AuthContext implementations use different localStorage keys. Make sure you use a consistent one across your app:
| Context File | Token Key | User Key |
|---|---|---|
AuthContext.tsx |
token |
user |
AuthContext_fixed.tsx |
auth_token |
user_data |
AuthContext_backend.tsx |
token |
user |
Use
AuthContext_fixed.tsxfor the most stable experience โ it is the default inmain_fixed.tsx.
The main landing page after login. Shows:
- Summary stats: total collections today, pending complaints, active vehicles
- Quick action buttons for common tasks
- Recent activity feed
- View, create, edit, and delete collection schedules
- Filter by zone, date, and status (Pending / In Progress / Completed)
- Assign staff and vehicles to a schedule
- Define geographic collection routes by zone
- View all routes on a list with assigned vehicle and staff
- Edit or deactivate routes
- Full vehicle inventory (truck number, type, capacity, status)
- Mark vehicles as Active / Under Maintenance / Inactive
- Assign to collection routes
- Citizens submit complaints with title, description, and location
- Admin/staff view all complaints with priority and status filters
- Status lifecycle: Submitted โ Under Review โ Resolved
- Resolution notes can be added before closing a complaint
- Charts showing collection completion rates over time
- Complaint volume and resolution time trends
- Vehicle utilization rates
- Zone-wise performance breakdown
Note: The Analytics page reads auth tokens from context. If you see a "User token not found" error, ensure you are using the same
AuthContextimplementation throughout the app (see Troubleshooting).
- System-generated notifications for key events
- Citizen notifications when their complaints are updated
- Staff notifications for new task assignments
- View all registered users by role
- Activate or deactivate accounts
- Reset passwords
Cause: A component is calling useAuth() but is rendered outside the <AuthProvider>, or the app is mixing different AuthContext implementations.
Fix:
- Check
index.htmlto see which entry file (main.tsxormain_fixed.tsx) is loaded - Ensure all components import
useAuthfrom the same context file - Confirm the root
Appis wrapped with the matching<AuthProvider>
Cause: The Analytics component reads the token using a key that doesn't match what the active AuthContext stores.
Fix: The token should come from the auth context directly:
const { token } = useAuth();instead of localStorage.getItem('token').
Cause: Hot Module Replacement can break when there are duplicate React context imports or circular dependencies.
Fix: Stop the dev server and restart:
npm run dev- Live map view for real-time vehicle tracking (GPS integration)
- Mobile-responsive PWA for field staff
- SMS/WhatsApp notifications for citizens via Twilio
- Route optimization using Google Maps / OSRM
- Multi-city / multi-zone support
- Export reports as PDF or Excel
- Hindi language UI option
Contributions are welcome!
- Fork the repository
- Create a new branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m "feat: add your feature" - Push and open a Pull Request
Please keep fixes scoped โ for example: fix(auth): normalize context imports.
เคธเฅเคตเคเฅเค เคจเคเคฐ โ เคธเฅเคตเคเฅเค เคญเคพเคฐเคคเฅค Clean City, Clean India. ๐ฎ๐ณ
Copyright (c) 2025 Atul Singh. All Rights Reserved.
This project and its source code are the exclusive intellectual property of the author.
You are NOT permitted to:
- Use, copy, or reproduce this code in any form
- Modify, adapt, or create derivative works
- Distribute, publish, or sublicense this code
- Use this project for commercial or personal purposes
- Deploy this application publicly or privately without explicit written permission from the author
You ARE permitted to:
- View the source code for educational/learning reference only
โ ๏ธ Unauthorized use, reproduction, or distribution of this project, in whole or in part, may result in legal action.
For permissions or licensing inquiries, contact the author directly via GitHub.