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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CitizenCare ๐๏ธ
|
| 2 |
+
|
| 3 |
+
An intelligent AI-powered citizen grievance classification and tracking portal that enables seamless complaint submission, real-time status tracking, and efficient authority dashboard management.
|
| 4 |
+
|
| 5 |
+
## ๐ฏ Features
|
| 6 |
+
|
| 7 |
+
- **Multi-Language Support**: Submit complaints in 10 Indian languages (English, Hindi, Telugu, Tamil, Kannada, Marathi, Bengali, Gujarati, Punjabi, Odia)
|
| 8 |
+
- **Voice & Text Input**: Record complaints directly or type them in
|
| 9 |
+
- **Smart Classification**: AI-powered keyword parser automatically categorizes complaints and assigns departments
|
| 10 |
+
- **Urgency Detection**: System intelligently identifies critical issues and triggers instant alerts
|
| 11 |
+
- **Real-Time Tracking**: Citizens can track complaint status with unique complaint IDs
|
| 12 |
+
- **Authority Dashboard**: Comprehensive dashboard for government officials to manage and resolve complaints
|
| 13 |
+
- **Visual Analytics**: Charts and filters to analyze complaint patterns by department and urgency
|
| 14 |
+
- **Secure Authentication**: Role-based access control with Supabase Auth
|
| 15 |
+
- **Responsive Design**: Beautiful, mobile-friendly UI with vibrant color scheme
|
| 16 |
+
|
| 17 |
+
## ๐ ๏ธ Tech Stack
|
| 18 |
+
|
| 19 |
+
- **Frontend**: Next.js, React, Tailwind CSS
|
| 20 |
+
- **Backend**: Next.js API Routes
|
| 21 |
+
- **Database**: Supabase (PostgreSQL) with real-time subscriptions
|
| 22 |
+
- **Authentication**: Supabase Auth
|
| 23 |
+
- **Voice Recognition**: Browser Web Speech API + OpenAI Whisper fallback
|
| 24 |
+
- **Email Alerts**: SendGrid (for critical complaints)
|
| 25 |
+
- **Charts**: Chart.js + react-chartjs-2
|
| 26 |
+
- **Hosting**: Vercel (recommended)
|
| 27 |
+
|
| 28 |
+
## ๐ System Architecture
|
| 29 |
+
|
| 30 |
+
```
|
| 31 |
+
โโโโโโโโโโโโโโโโโโโ
|
| 32 |
+
โ Citizen Portal โ (index.jsx, support.jsx)
|
| 33 |
+
โโโโโโโโโโโโโโโโโโโค
|
| 34 |
+
โ Voice/Text โ
|
| 35 |
+
โ Input Handler โ
|
| 36 |
+
โโโโโโโโโโฌโโโโโโโโโ
|
| 37 |
+
โ
|
| 38 |
+
โผ
|
| 39 |
+
โโโโโโโโโโโโโโโโโโโ
|
| 40 |
+
โ API Processor โ (api/process.js)
|
| 41 |
+
โ - Keywords โ
|
| 42 |
+
โ - Scoring โ
|
| 43 |
+
โ - Department โ
|
| 44 |
+
โ - Urgency โ
|
| 45 |
+
โโโโโโโโโโฌโโโโโโโโโ
|
| 46 |
+
โ
|
| 47 |
+
โผ
|
| 48 |
+
โโโโโโโโโโโโโโโโโโโ
|
| 49 |
+
โ Database โ (Supabase)
|
| 50 |
+
โ - Store โ
|
| 51 |
+
โ - Realtime โ
|
| 52 |
+
โโโโโโโโโโฌโโโโโโโโโ
|
| 53 |
+
โ
|
| 54 |
+
โผ
|
| 55 |
+
โโโโโโโโโโโโโโโโโโโ
|
| 56 |
+
โ Authority โ (dashboard.jsx)
|
| 57 |
+
โ Dashboard โ
|
| 58 |
+
โ - View โ
|
| 59 |
+
โ - Filter โ
|
| 60 |
+
โ - Update โ
|
| 61 |
+
โโโโโโโโโโโโโโโโโโโ
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
## ๐ Getting Started
|
| 65 |
+
|
| 66 |
+
### Prerequisites
|
| 67 |
+
- Node.js 16+ and npm
|
| 68 |
+
- Supabase account
|
| 69 |
+
- SendGrid account (for alerts)
|
| 70 |
+
- Git
|
| 71 |
+
|
| 72 |
+
### Installation
|
| 73 |
+
|
| 74 |
+
1. **Clone the repository**
|
| 75 |
+
```bash
|
| 76 |
+
git clone https://github.com/SAI-RAHUL-ROKKAM/CitizenCare.git
|
| 77 |
+
cd CitizenCare
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
2. **Install dependencies**
|
| 81 |
+
```bash
|
| 82 |
+
npm install
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
3. **Create environment file**
|
| 86 |
+
```bash
|
| 87 |
+
cp .env.example .env.local
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
4. **Fill in your environment variables in `.env.local`**
|
| 91 |
+
```
|
| 92 |
+
ANTHROPIC_API_KEY=your_key_here
|
| 93 |
+
OPENAI_API_KEY=your_key_here
|
| 94 |
+
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
|
| 95 |
+
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_key
|
| 96 |
+
SENDGRID_API_KEY=your_sendgrid_key
|
| 97 |
+
ALERT_EMAIL=authority@yourcity.gov.in
|
| 98 |
+
LOCATIONIQ_KEY=your_locationiq_key
|
| 99 |
+
NEXT_PUBLIC_BASE_URL=http://localhost:3000
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
5. **Run the development server**
|
| 103 |
+
```bash
|
| 104 |
+
npm run dev
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
6. **Open in browser**
|
| 108 |
+
```
|
| 109 |
+
http://localhost:3000
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
## ๐ฑ Usage
|
| 113 |
+
|
| 114 |
+
### For Citizens
|
| 115 |
+
1. Visit `http://localhost:3000`
|
| 116 |
+
2. Type or record a complaint in any supported language
|
| 117 |
+
3. Click "Submit complaint"
|
| 118 |
+
4. View generated complaint summary, department, and urgency
|
| 119 |
+
5. Copy complaint ID to track status
|
| 120 |
+
6. Use "Track complaint" tab to check real-time updates
|
| 121 |
+
|
| 122 |
+
### For Authorities
|
| 123 |
+
1. Visit `http://localhost:3000/login`
|
| 124 |
+
2. Sign up or use test credentials:
|
| 125 |
+
- Email: `authority-test@citizencare.test`
|
| 126 |
+
- Password: `Test@1234`
|
| 127 |
+
3. View dashboard with:
|
| 128 |
+
- Statistics (total, pending, resolved, critical)
|
| 129 |
+
- Charts by department and urgency
|
| 130 |
+
- Complaint list with filters
|
| 131 |
+
- Click any complaint to view details and update status
|
| 132 |
+
|
| 133 |
+
## ๐ Security
|
| 134 |
+
|
| 135 |
+
- โ
Environment variables protected in `.env.local` (excluded from Git)
|
| 136 |
+
- โ
`.env.example` contains only dummy keys
|
| 137 |
+
- โ
Supabase Row Level Security (RLS) for database access control
|
| 138 |
+
- โ
Role-based authentication for authority dashboard
|
| 139 |
+
- โ
No API keys exposed in source code
|
| 140 |
+
- โ
SendGrid alerts only for critical complaints
|
| 141 |
+
|
| 142 |
+
## ๐ Project Structure
|
| 143 |
+
|
| 144 |
+
```
|
| 145 |
+
CitizenCare/
|
| 146 |
+
โโโ pages/
|
| 147 |
+
โ โโโ _app.jsx # App wrapper
|
| 148 |
+
โ โโโ index.jsx # Citizen portal (submit/track)
|
| 149 |
+
โ โโโ dashboard.jsx # Authority dashboard
|
| 150 |
+
โ โโโ login.jsx # Authentication
|
| 151 |
+
โ โโโ support.jsx # FAQ & help center
|
| 152 |
+
โ โโโ api/
|
| 153 |
+
โ โโโ process.js # Complaint parser & classifier
|
| 154 |
+
โ โโโ status.js # Track complaint status
|
| 155 |
+
โ โโโ alert.js # Send critical alerts
|
| 156 |
+
โ โโโ transcribe.js # Voice transcription
|
| 157 |
+
โโโ lib/
|
| 158 |
+
โ โโโ supabase.js # Supabase client config
|
| 159 |
+
โโโ styles/
|
| 160 |
+
โ โโโ globals.css # Global styles & animations
|
| 161 |
+
โโโ .env.example # Environment template
|
| 162 |
+
โโโ .gitignore # Git ignore rules
|
| 163 |
+
โโโ package.json # Dependencies
|
| 164 |
+
โโโ tailwind.config.js # Tailwind configuration
|
| 165 |
+
โโโ postcss.config.js # PostCSS configuration
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
## ๐ง How It Works
|
| 169 |
+
|
| 170 |
+
### Complaint Processing Flow
|
| 171 |
+
|
| 172 |
+
1. **Input**: Citizen submits text/voice in any language
|
| 173 |
+
2. **Detection**: System detects language from Unicode script
|
| 174 |
+
3. **Scoring**: Multi-keyword scoring system finds best department match
|
| 175 |
+
4. **Rules**: Override rules for critical medical/safety terms
|
| 176 |
+
5. **Extraction**: Location parsing using regex patterns
|
| 177 |
+
6. **Classification**: Department, urgency, and action items assigned
|
| 178 |
+
7. **Storage**: Complaint saved to Supabase with `status: pending`
|
| 179 |
+
8. **Alerts**: If critical โ SendGrid email sent to authority
|
| 180 |
+
9. **Tracking**: Citizen gets unique ID to track status
|
| 181 |
+
|
| 182 |
+
### Department Keywords
|
| 183 |
+
|
| 184 |
+
System supports keywords in 10 languages for:
|
| 185 |
+
- Health, Hospital
|
| 186 |
+
- Police
|
| 187 |
+
- Sanitation
|
| 188 |
+
- Roads, Water, Electricity
|
| 189 |
+
- Education
|
| 190 |
+
- Transport
|
| 191 |
+
- Municipal
|
| 192 |
+
- Environment
|
| 193 |
+
- Rescue
|
| 194 |
+
- Other (fallback)
|
| 195 |
+
|
| 196 |
+
## ๐ Example Test Cases
|
| 197 |
+
|
| 198 |
+
### Test 1: Health Emergency โ
|
| 199 |
+
**Input**: "my teacher got a heart attack our school is at lalitha nagar , rajahmundry"
|
| 200 |
+
**Result**:
|
| 201 |
+
- Department: Health
|
| 202 |
+
- Urgency: Critical
|
| 203 |
+
- ETA: 12 hours
|
| 204 |
+
|
| 205 |
+
### Test 2: Road Issue โ
|
| 206 |
+
**Input**: "large pothole near Ramaiah School on MG Road. Two bikes fell last week"
|
| 207 |
+
**Result**:
|
| 208 |
+
- Department: Roads
|
| 209 |
+
- Urgency: High
|
| 210 |
+
- ETA: 24-48 hours
|
| 211 |
+
|
| 212 |
+
### Test 3: Sanitation โ
|
| 213 |
+
**Input**: "เคเคเคฆเคเฅ เคเคฐ เคเคเคฐเฅ เคเฅ เคขเฅเคฐ เคนเคฎเคพเคฐเฅ เคเคฒเคพเคเฅ เคฎเฅเค"
|
| 214 |
+
**Result**:
|
| 215 |
+
- Department: Sanitation
|
| 216 |
+
- Urgency: Medium
|
| 217 |
+
- ETA: 3-5 days
|
| 218 |
+
|
| 219 |
+
## ๐ Deployment
|
| 220 |
+
|
| 221 |
+
### Deploy to Vercel (Recommended)
|
| 222 |
+
|
| 223 |
+
1. Push code to GitHub
|
| 224 |
+
2. Connect repo to Vercel
|
| 225 |
+
3. Add environment variables in Vercel dashboard
|
| 226 |
+
4. Deploy automatically on push
|
| 227 |
+
|
| 228 |
+
```bash
|
| 229 |
+
git push origin main
|
| 230 |
+
# Vercel auto-deploys
|
| 231 |
+
```
|
| 232 |
+
|
| 233 |
+
### Environment Variables for Production
|
| 234 |
+
Set these in your hosting platform (Vercel, Netlify, etc.):
|
| 235 |
+
- `ANTHROPIC_API_KEY`
|
| 236 |
+
- `OPENAI_API_KEY`
|
| 237 |
+
- `NEXT_PUBLIC_SUPABASE_URL`
|
| 238 |
+
- `NEXT_PUBLIC_SUPABASE_ANON_KEY`
|
| 239 |
+
- `SENDGRID_API_KEY`
|
| 240 |
+
- `ALERT_EMAIL`
|
| 241 |
+
- `LOCATIONIQ_KEY`
|
| 242 |
+
- `NEXT_PUBLIC_BASE_URL` (your domain)
|
| 243 |
+
|
| 244 |
+
## ๐ Performance
|
| 245 |
+
|
| 246 |
+
- **Processing Time**: < 3 seconds for complaint classification
|
| 247 |
+
- **Database**: Real-time sync using Supabase subscriptions
|
| 248 |
+
- **Voice Input**: Supports 10 languages with offline fallback
|
| 249 |
+
- **Responsive**: Mobile, tablet, and desktop optimized
|
| 250 |
+
|
| 251 |
+
## ๐ฎ Future Enhancements
|
| 252 |
+
|
| 253 |
+
- [ ] ML/NLP model for intent classification
|
| 254 |
+
- [ ] Map-based geo-visualization of complaints
|
| 255 |
+
- [ ] SMS/WhatsApp citizen notifications
|
| 256 |
+
- [ ] Advanced admin dashboard with SLA tracking
|
| 257 |
+
- [ ] Automated translation to English
|
| 258 |
+
- [ ] Chat support interface
|
| 259 |
+
- [ ] Gamification (badges/credits for citizens)
|
| 260 |
+
- [ ] Photo/video attachments
|
| 261 |
+
- [ ] Integration with government databases
|
| 262 |
+
- [ ] Analytics and reporting tools
|
| 263 |
+
|
| 264 |
+
## ๐ค Contributing
|
| 265 |
+
|
| 266 |
+
Contributions are welcome! Please:
|
| 267 |
+
1. Fork the repository
|
| 268 |
+
2. Create a feature branch (`git checkout -b feature/AmazingFeature`)
|
| 269 |
+
3. Commit changes (`git commit -m 'Add AmazingFeature'`)
|
| 270 |
+
4. Push to branch (`git push origin feature/AmazingFeature`)
|
| 271 |
+
5. Open a Pull Request
|
| 272 |
+
|
| 273 |
+
## ๐ License
|
| 274 |
+
|
| 275 |
+
This project is open source and available under the MIT License.
|
| 276 |
+
|
| 277 |
+
## ๐ Support
|
| 278 |
+
|
| 279 |
+
For issues or questions:
|
| 280 |
+
- Create an issue on GitHub
|
| 281 |
+
- Check the FAQ in `/support` page
|
| 282 |
+
- Visit help center at `http://localhost:3000/support`
|
| 283 |
+
|
| 284 |
+
## ๐จโ๐ป Authors
|
| 285 |
+
|
| 286 |
+
- **SAI RAHUL ROKKAM** - Initial development
|
| 287 |
+
|
| 288 |
+
Built for the National Hackathon 2026
|
| 289 |
+
|
| 290 |
+
---
|
| 291 |
+
|
| 292 |
+
**Made with โค๏ธ for better citizen-government communication**
|