Skip to content

deepaksoni47/CityCare

Repository files navigation

Typing SVG

πŸ™οΈ CityCare

Intelligent Urban Infrastructure Management Platform

Data-driven visibility into city systems. Predictive maintenance powered by AI. Community engagement that makes a difference.


GitHub License Status


🎯 The Challenge

Cities face an infrastructure crisis that's invisible until something breaks.

The Current Reality:

  • πŸ“‰ No visibility into system health across the city
  • πŸ”§ Maintenance teams react to crises instead of preventing them
  • πŸ“± Community reports scattered across multiple channels, easily lost
  • πŸ“Š Data siloedβ€”no way to identify patterns or recurring problems
  • ⚠️ Budget decisions made without data backing
  • πŸŒ† Millions spent on avoidable emergencies

The Cost of Reactive Management: When water pipes burst, electrical systems fail, and roads deteriorate without warning, the city pays in emergency repairs, business disruptions, and reduced quality of life.

What if you could see problems forming before they became catastrophic? What if every citizen report became actionable intelligence? What if your maintenance budget was guided by data, not crisis?


πŸ’‘ The CityCare Solution

CityCare transforms city infrastructure from reactive chaos into intelligent, data-driven management.

We combine real-time geospatial visualization, predictive AI analysis, and community-powered reporting to give cities complete visibility into infrastructure health and predictive insights for maintenance planning.

How It Works

πŸ“± Citizens Report Issues β†’ πŸ—ΊοΈ Live Heatmap Visualization β†’
πŸ“Š Pattern Detection & Analysis β†’ πŸ€– AI Risk Assessment β†’
🎯 Smart Prioritization β†’ βœ… Accelerated Resolution

✨ Core Capabilities

πŸ—ΊοΈ Spatial Intelligence

  • Real-time geospatial heatmaps showing issue density and severity
  • Zone-based clustering and risk zones identification
  • Historical pattern visualization overlays
  • Custom city boundary mapping

πŸ€– AI-Powered Insights

  • Gemini AI analyzes trends across all infrastructure data
  • Automatic root cause detection and pattern recognition
  • Predictive alerts for high-risk zones
  • Natural language reports: "Downtown has 5x more pothole reports than average"

πŸ“Š Comprehensive Analytics

  • Mean Time To Resolution (MTTR) tracking
  • Issue category trends and seasonal patterns
  • Recurring issue detection
  • Multi-zone comparative analysis

πŸ† Community Engagement

  • Points and rewards system for active reporters
  • Public leaderboards and achievement badges
  • Community voting on critical issues
  • Recognition for city improvement advocates

πŸ‘₯ Admin Command Center

  • Complete user and issue management dashboard
  • System-wide analytics and health overview
  • Bulk operations and workflow management
  • Export reports in multiple formats (CSV, JSON, PDF)

πŸ“§ Smart Notifications

  • Beautiful HTML email templates
  • Instant alerts on issue reports
  • Resolution confirmations
  • Stakeholder updates
  • OAuth welcome communications

�️ Technology Stack

Tech Stack

πŸ’» Frontend

Next.js TypeScript Tailwind CSS Leaflet

  • ⚑ Next.js 14 with App Router
  • 🎨 Tailwind CSS + Shadcn UI
  • πŸ—ΊοΈ Leaflet + OpenStreetMap
  • πŸ“Š Recharts for analytics
  • πŸ”” React Hot Toast notifications

βš™οΈ Backend

Node.js Express TypeScript MongoDB

  • πŸ”’ Express + TypeScript APIs
  • πŸ—„οΈ MongoDB with geospatial indexes
  • πŸ“§ Nodemailer for emails
  • 🐳 Docker containerization
  • πŸš‚ Railway deployment

πŸ’Ύ Database & Storage

MongoDB Cloudinary

  • πŸ“„ MongoDB NoSQL database
  • πŸ—ΊοΈ Geospatial indexes for location queries
  • πŸ–ΌοΈ Cloudinary for image storage
  • ⚑ Real-time data sync via WebSocket/SSE
  • πŸ” Compound indexes for analytics

πŸ€– AI & Intelligence

Gemini Firebase Auth

  • 🧠 Gemini 1.5 Flash API
  • πŸ” Firebase Authentication
  • πŸ“Š AI-powered insights
  • 🎯 Risk scoring algorithms
  • πŸ“ Natural language reports

πŸ—οΈ System Architecture

%%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#1976d2','primaryTextColor':'#fff','primaryBorderColor':'#0d47a1','lineColor':'#424242','secondaryColor':'#388e3c','tertiaryColor':'#f57c00','noteBkgColor':'#fff9c4','noteTextColor':'#000'}}}%%
graph TB
    subgraph Frontend["πŸ–₯️ Frontend - Vercel"]
        NextJS["Next.js 14<br/>App Router + RSC"]
        Leaflet["Leaflet Maps<br/>Real-time Heatmaps"]
        AdminUI["Admin Dashboard<br/>Charts & Analytics"]
    end

    subgraph Backend["βš™οΈ Backend - Railway"]
        Express["Express + TypeScript<br/>REST API"]
        AdminModule["Admin Module<br/>User/Issue Management"]
        EmailService["Nodemailer<br/>HTML Templates"]
    end

    subgraph Data["πŸ’Ύ Data Layer"]
        Firestore["Firebase Firestore<br/>GeoPoint Queries"]
        FirebaseAuth["Firebase Auth<br/>JWT Tokens"]
    end

    subgraph AI["πŸ€– AI Layer"]
        Gemini["Gemini 1.5 Flash<br/>Natural Language Insights"]
    end

    NextJS --> Express
    Leaflet --> NextJS
    AdminUI --> AdminModule
    Express --> Firestore
    Express --> FirebaseAuth
    Express --> Gemini
    EmailService --> Express
    AdminModule --> Firestore

    style Frontend fill:#1976d2,stroke:#0d47a1,stroke-width:2px,color:#fff
    style Backend fill:#388e3c,stroke:#2e7d32,stroke-width:2px,color:#fff
    style Data fill:#7b1fa2,stroke:#6a1b9a,stroke-width:2px,color:#fff
    style AI fill:#f57c00,stroke:#e65100,stroke-width:2px,color:#fff
Loading

Architecture Layers

🎨 Frontend

Next.js 14

  • App Router
  • React Server Components
  • Leaflet heatmaps
  • Admin dashboard

βš™οΈ Backend

Express API

  • TypeScript
  • Railway deployment
  • 40+ endpoints
  • Email service

πŸ’½ Database

Firestore

  • GeoPoint queries
  • Composite indexes
  • Real-time sync
  • Role-based access

πŸ€– AI

Gemini AI

  • Plain-English reports
  • Pattern analysis
  • Trend insights
  • 1500 req/day

πŸ› οΈ Technology Stack

Tech Stack

πŸ’» Frontend Stack

Next.js TypeScript Tailwind CSS React

Features:

  • πŸš€ Server-side rendering for performance
  • 🎨 Modern UI with Tailwind CSS
  • πŸ“± Responsive design
  • ⚑ Optimized for speed
  • πŸ—ΊοΈ OpenStreetMap + Leaflet integration

βš™οΈ Backend Stack

Node.js Express MongoDB Docker

Features:

  • πŸ”’ Type-safe APIs with TypeScript
  • πŸ—„οΈ MongoDB with geospatial support
  • 🐳 Containerized deployment
  • πŸ” JWT authentication
  • πŸ“Š RESTful architecture
  • πŸ’° 100% Free hosting

☁️ Modern Cloud Stack

Railway

Backend
Deployment

MongoDB

NoSQL +
Geospatial

Leaflet

Interactive
Maps

Gemini

AI
Insights

JWT

Auth &
Security

OpenStreetMap

Open Source
Maps


πŸ“Š Data Model

Infrastructure Issue Entity

Field Type Description
issue_id UUID Unique identifier
category Enum Water, Electricity, WiFi, Sanitation, etc.
latitude Float Geographic latitude
longitude Float Geographic longitude
severity Integer Severity level (1-5)
timestamp DateTime Issue creation time
status Enum Open, In Progress, Resolved
description Text Issue details
building_id String Associated zone identifier (optional)

πŸš€ Quick Start

Getting Started

Setup Difficulty

πŸ“‹ Prerequisites

Node.js

v18 or higher

MongoDB

Free tier cluster

Gemini

From AI Studio

⚑ 3-Step Setup

1️⃣ Firebase Setup

# Create Firebase project
# (console.firebase.google.com)

# Enable Firestore
# Enable Authentication
# Download service account key

Get:

  • Project ID
  • Service account JSON
  • Web app config

πŸ“– Full Guide

2️⃣ Backend Deploy

cd backend
npm install

# Add .env file
MONGODB_URI='mongodb+srv://user:pass@cluster.mongodb.net'
GOOGLE_GEMINI_API_KEY='your_key'
EMAIL_USER='your@gmail.com'
EMAIL_PASS='app_password'

# Deploy to Railway
npm run build

πŸ“– Railway Guide

3️⃣ Frontend Deploy

cd frontend
npm install

# Add .env.local
NEXT_PUBLIC_API_URL='https://your-api.railway.app'

# Run locally
npm run dev

# Deploy to Vercel
vercel --prod

πŸ“– Integration Guide

🌐 Access Points

Service URL Description
🎨 Frontend http://localhost:3000 Next.js app with heatmaps
βš™οΈ Backend http://localhost:3001 Express API on Railway
πŸ”₯ Firestore Firebase Console Database & authentication
πŸ“§ Admin Panel /admin/dashboard User/issue management

πŸ”‘ Get API Keys (All Free!)

πŸ€– Gemini API Key (1500 requests/day)
  1. Visit aistudio.google.com
  2. Click "Create API Key"
  3. Copy to GOOGLE_GEMINI_API_KEY in .env
πŸ”₯ Firebase Config (No credit card)
  1. Go to Firebase Console
  2. Create new project
  3. Enable Firestore Database
  4. Enable Authentication (Email & Google)
  5. Project Settings β†’ Service Accounts β†’ Generate new private key
  6. Copy JSON to FIREBASE_SERVICE_ACCOUNT_KEY
πŸ“§ Gmail SMTP (For email notifications)
  1. Enable 2FA on your Google account
  2. Generate App Password: myaccount.google.com/apppasswords
  3. Add to .env:
    EMAIL_USER=your@gmail.com
    EMAIL_PASS=your_16_char_app_password
    

πŸ“„ Environment Variables

Backend (.env):

MONGODB_URI='mongodb+srv://user:pass@cluster.mongodb.net/citycare'
GOOGLE_GEMINI_API_KEY='AIzaSy...'
EMAIL_USER='your@gmail.com'
EMAIL_PASS='your_app_password'
PORT=3001
FRONTEND_URL='http://localhost:3000'

Frontend (.env.local):

NEXT_PUBLIC_API_URL='http://localhost:3001'

πŸ“ Project Structure

citycare/
β”œβ”€β”€ πŸ“„ README.md                    # You are here!
β”œβ”€β”€ 🐳 docker-compose.yml           # Multi-service orchestration
β”œβ”€β”€ πŸ“š docs/                        # Comprehensive documentation
β”‚   β”œβ”€β”€ DATABASE_ARCHITECTURE.md   # MongoDB schema guide
β”‚   β”œβ”€β”€ architecture/              # System design docs
β”‚   β”œβ”€β”€ api/                       # API specifications
β”‚   └── prompts/                   # AI prompt templates
β”‚
β”œβ”€β”€ βš™οΈ backend/                     # Node.js + Express + TypeScript
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/                # MongoDB & Cloudinary setup
β”‚   β”‚   β”œβ”€β”€ modules/               # Feature modules
β”‚   β”‚   β”‚   β”œβ”€β”€ issues/           # Issue management
β”‚   β”‚   β”‚   β”œβ”€β”€ analytics/        # Data analytics
β”‚   β”‚   β”‚   β”œβ”€β”€ ai/               # Gemini integration
β”‚   β”‚   β”‚   └── auth/             # JWT authentication
β”‚   β”‚   β”œβ”€β”€ middlewares/          # Express middleware
β”‚   β”‚   β”œβ”€β”€ types/                # TypeScript definitions
β”‚   β”‚   └── utils/                # Helper functions
β”‚   └── package.json              # Dependencies (MongoDB, Express)
β”‚
β”œβ”€β”€ 🎨 frontend/                    # Next.js 14 + TypeScript
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/                  # Next.js app router
β”‚   β”‚   β”œβ”€β”€ components/           # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ Map/             # Leaflet + OpenStreetMap
β”‚   β”‚   β”‚   β”œβ”€β”€ Charts/          # Data visualization
β”‚   β”‚   β”‚   └── Dashboard/       # Admin interface
β”‚   β”‚   β”œβ”€β”€ lib/                 # Utilities & API client
β”‚   β”‚   └── styles/              # Tailwind CSS
β”‚   └── public/                  # Static assets
β”‚
β”œβ”€β”€ πŸ“Š analytics/                   # Analytics Scripts
β”‚   └── bigquery/              # Data analysis queries
β”‚
└── πŸ—οΈ infra/                       # Infrastructure as Code
    β”œβ”€β”€ cloudrun.yaml             # Cloud Run deployment
    └── sql/                      # Database initialization

πŸ§ͺ Testing

# Backend tests
cd backend
npm test
npm run test:coverage

# Frontend tests
cd frontend
npm test

πŸ“¦ Deployment

Deployment

Deploy to Railway in Minutes

Railway Vercel CI/CD

βš™οΈ Backend (Railway)

# Build and deploy
cd backend
railway link
railway up

Auto-configured:

  • βœ… MongoDB Atlas integration
  • βœ… Environment variables
  • βœ… Health checks
  • βœ… Auto-scaling
  • βœ… Free tier: 5GB bandwidth

🎨 Frontend (Vercel)

# Build Next.js app
cd frontend
npm run build

# Deploy to Vercel
vercel --prod

Features:

  • βœ… Global CDN
  • βœ… Automatic SSL
  • βœ… Optimized builds
  • βœ… Preview deployments
  • βœ… Analytics included

πŸ”’ Security & Best Practices

πŸ›‘οΈ Authentication

JWT Auth

  • Email/password login
  • Google OAuth
  • JWT token validation
  • Session management
  • Role-based access control

πŸ” Data Protection

Security

  • SQL injection prevention
  • XSS protection
  • CORS security
  • Input sanitization
  • Environment encryption

⚑ Rate Limiting

Rate Limit

  • API throttling
  • DDoS protection
  • Request validation
  • IP whitelisting
  • Quota management

πŸ“ˆ Scalability & Future Roadmap

Built to Scale: City β†’ Multi-City β†’ Global Smart Infrastructure

🏒 Multi-Campus

Status

Extend to multiple institutions with tenant isolation

πŸ“± IoT Integration

Status

Connect real-time sensors for automated monitoring

πŸ“² Mobile Apps

Status

Native iOS/Android apps for field staff

πŸŒ† Smart City

Status

Scale to public infrastructure management


🀝 Contributing

Contributing

Contributors PRs Issues

graph LR
    A[🍴 Fork] --> B[🌿 Branch]
    B --> C[πŸ’» Code]
    C --> D[βœ… Test]
    D --> E[πŸ“ Commit]
    E --> F[πŸš€ Push]
    F --> G[πŸ”„ Pull Request]

    style A fill:#e3f2fd
    style G fill:#c8e6c9
Loading

Quick Steps:

  1. 🍴 Fork the repository
  2. 🌿 Create feature branch (git checkout -b feature/AmazingFeature)
  3. πŸ’» Make your changes
  4. βœ… Add tests
  5. πŸ“ Commit (git commit -m 'Add AmazingFeature')
  6. πŸš€ Push to branch (git push origin feature/AmazingFeature)
  7. πŸ”„ Open a Pull Request

πŸ“„ License

License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

MongoDB

Document Database

Flexible schema and powerful query language

Gemini

AI Intelligence

Natural language insights and automated report generation

Leaflet

Interactive Maps

Open source mapping with no API key required

OpenStreetMap

Open Source Maps

Free, unlimited map tiles with no API key required


πŸ“ž Contact & Support


🌟 Star this repository if you find it useful! 🌟

GitHub stars

Made with Love MongoDB Gemini

Footer

Β© 2025 CityCare Team | MIT License

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors