smart-city/
├── backend/
│ ├── config/aws.js ← AWS SDK clients
│ ├── routes/auth.js ← Cognito auth APIs
│ ├── routes/complaints.js ← Complaint CRUD + AI
│ ├── server.js ← Express server
│ ├── .env ← Fill YOUR AWS values here
│ └── package.json
├── frontend/
│ └── src/
│ ├── pages/citizen/ ← Citizen Dashboard
│ ├── pages/admin/ ← Admin Dashboard
│ ├── pages/service/ ← Service Team Dashboard
│ ├── pages/Login.js, Register.js etc.
│ └── App.js ← Routes + Role-based redirect
├── lambda/index.mjs ← Paste this in AWS Lambda
├── START-WINDOWS.bat ← Windows: double-click to run
└── start.sh ← Mac/Linux: bash start.sh
- AWS Console → Cognito →
smart-city-users - Sign-in experience → Custom attributes → Add custom attributes
- Name:
role, Type: String, Min: 1, Max: 50, Mutable: Yes - Save changes
- Cognito →
smart-city-users→ App clients →smart-city-web→ Edit - Enable:
ALLOW_USER_PASSWORD_AUTH+ALLOW_REFRESH_TOKEN_AUTH - Save changes
- Copy the Client ID → paste into
backend/.env→COGNITO_CLIENT_ID
- DynamoDB → Create table
- Name:
complaints, Partition key:complaintId(String) - Capacity: On-demand → Create table
- Lambda →
incidentProcessor→ Configuration → Permissions → click role link - Attach policies:
AmazonRekognitionFullAccess,AmazonDynamoDBFullAccess,AmazonS3ReadOnlyAccess,AmazonSQSFullAccess,AmazonSNSFullAccess
- Lambda →
incidentProcessor→ Code tab → openindex.mjs - Select all → delete → paste contents of
lambda/index.mjs→ Deploy
- SNS →
cityEmergencyAlerts→ Create subscription - Protocol: Email → your email → Create → Confirm in inbox
- S3 →
smart-city-incident-images→ Permissions → CORS → Edit → paste:
[{"AllowedHeaders":["*"],"AllowedMethods":["GET","PUT","POST","DELETE"],"AllowedOrigins":["*"],"ExposeHeaders":[]}]Open backend/.env — only 2 values need to be filled:
AWS_ACCESS_KEY_ID— from your IAM CSV fileAWS_SECRET_ACCESS_KEY— from your IAM CSV fileCOGNITO_CLIENT_ID— from Cognito App Client page
Everything else is pre-filled from your AWS setup!
# Terminal 1 - Backend
cd backend
npm install
npm run dev
# Terminal 2 - Frontend
cd frontend
npm install
npm startOpen: http://localhost:3000
| Role | Auto-redirects to | Features |
|---|---|---|
| citizen | /citizen | Report, track, view AI results |
| admin | /admin | Manage all, assign teams, analytics |
| service_team | /service | View tasks, update work status |
Select role during Register — automatic redirect after login, no AWS config needed.
- Login fails → Register first, confirm email, then login
- Image upload fails → Add S3 CORS config (Step 7 above)
- Cognito error → Make sure custom:role attribute added + auth flow enabled
- Lambda error → Check IAM permissions in Step 4