เคธเฅเคตเคเฅเค เคจเคเคฐ 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.
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:
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 |
| 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
# Navigate to the backend directory
cd backend
# Install dependencies
npm install
# Start the development server
npm run dev
# or
node index.js
The 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 dev
The 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.
backend/config.js)PORT=5000
MONGO_URI=mongodb://localhost:27017/swacchnagar
JWT_SECRET=your_jwt_secret_key_here
NODE_ENV=development
Different 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:
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).
useAuth must be used within an AuthProviderCause: A component is calling useAuth() but is rendered outside the <AuthProvider>, or the app is mixing different AuthContext implementations.
Fix:
index.html to see which entry file (main.tsx or main_fixed.tsx) is loadeduseAuth from the same context fileApp is wrapped with the matching <AuthProvider>"User token not found"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
Contributions are welcome!
git checkout -b feature/your-featuregit commit -m "feat: add your feature"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:
You ARE permitted to:
โ ๏ธ 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.