Skip to content

Latest commit

Β 

History

History
364 lines (285 loc) Β· 9.8 KB

File metadata and controls

364 lines (285 loc) Β· 9.8 KB

πŸ›οΈ CivicIssue Admin Panel

License Version Build Status Node

πŸš€ AI-Powered Municipal Issue Management Dashboard

A modern, real-time administrative dashboard for managing civic issues with integrated AI capabilities, built with Next.js, TypeScript, and Claude AI integration.

CivicIssue Admin Panel Screenshot

✨ Features

Core Functionality

  • πŸ“Š Real-time Dashboard - Live statistics and metrics
  • πŸ—ΊοΈ Interactive Issue Map - Visualize civic issues geographically
  • πŸ€– AI Assistant - Claude AI-powered chat for intelligent insights
  • πŸ“ˆ Analytics & Reporting - Comprehensive data visualization
  • πŸ”” Smart Notifications - Real-time alerts for critical issues
  • πŸ‘₯ Department Management - Efficient task routing and assignment

AI-Powered Features

  • 🧠 Automatic issue classification and severity scoring
  • πŸ“Š Predictive analytics for resource allocation
  • πŸ’¬ Natural language query processing
  • 🎯 Smart routing recommendations
  • ⚠️ Escalation prediction
  • πŸ“ Automated report generation

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • UI Library: Material-UI (MUI) v5
  • State Management: Zustand
  • Data Fetching: React Query + SWR
  • Maps: Mapbox GL JS
  • Charts: Recharts + D3.js
  • Real-time: Socket.io Client
  • Styling: Tailwind CSS + Emotion

Backend Integration

  • API: RESTful + GraphQL
  • WebSockets: Real-time updates
  • AI Services: Claude API, OpenAI
  • Authentication: JWT + OAuth2

πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v18.0.0 or higher)
  • npm or yarn
  • Git

πŸš€ Quick Start

1. Clone the Repository

git clone https://github.com/SadiqueCodes/CivicIssue_adminpanel.git
cd CivicIssue_adminpanel

2. Install Dependencies

npm install
# or
yarn install

3. Environment Setup

Create a .env.local file in the root directory:

# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:3000/api/v1
NEXT_PUBLIC_WS_URL=ws://localhost:3000
NEXT_PUBLIC_GRAPHQL_URL=http://localhost:3000/graphql

# Map Configuration
NEXT_PUBLIC_MAPBOX_TOKEN=your_mapbox_token_here

# AI Services
ANTHROPIC_API_KEY=your_anthropic_api_key
OPENAI_API_KEY=your_openai_api_key

# Authentication
NEXTAUTH_URL=http://localhost:3001
NEXTAUTH_SECRET=your_secret_key_here
JWT_SECRET=your_jwt_secret

# Database (if connecting directly)
DATABASE_URL=postgresql://user:password@localhost:5432/civic_db

# Analytics
NEXT_PUBLIC_GA_ID=your_google_analytics_id
NEXT_PUBLIC_SENTRY_DSN=your_sentry_dsn

4. Run Development Server

npm run dev
# or
yarn dev

Open http://localhost:3001 to view the application.

πŸ“ Project Structure

CivicIssue_adminpanel/
β”œβ”€β”€ app/                      # Next.js 14 App Directory
β”‚   β”œβ”€β”€ (auth)/              # Authentication routes
β”‚   β”‚   β”œβ”€β”€ login/           # Login page
β”‚   β”‚   └── register/        # Registration page
β”‚   β”œβ”€β”€ dashboard/           # Main dashboard
β”‚   β”‚   β”œβ”€β”€ page.tsx         # Dashboard home
β”‚   β”‚   β”œβ”€β”€ issues/          # Issues management
β”‚   β”‚   β”œβ”€β”€ analytics/       # Analytics views
β”‚   β”‚   β”œβ”€β”€ departments/     # Department management
β”‚   β”‚   └── ai-insights/     # AI insights page
β”‚   β”œβ”€β”€ api/                 # API routes
β”‚   β”‚   β”œβ”€β”€ auth/           # Authentication endpoints
β”‚   β”‚   β”œβ”€β”€ issues/         # Issue management
β”‚   β”‚   └── ai/             # AI service endpoints
β”‚   └── layout.tsx          # Root layout
β”œβ”€β”€ components/              # React components
β”‚   β”œβ”€β”€ Dashboard/          # Dashboard components
β”‚   β”œβ”€β”€ Map/               # Map components
β”‚   β”œβ”€β”€ Charts/            # Data visualization
β”‚   β”œβ”€β”€ AIChat/            # AI assistant chat
β”‚   └── common/            # Shared components
β”œβ”€β”€ lib/                    # Utility functions
β”‚   β”œβ”€β”€ api/               # API client
β”‚   β”œβ”€β”€ hooks/             # Custom React hooks
β”‚   β”œβ”€β”€ utils/             # Helper functions
β”‚   └── validators/        # Form validation
β”œβ”€β”€ public/                # Static assets
β”œβ”€β”€ styles/                # Global styles
β”œβ”€β”€ types/                 # TypeScript definitions
└── config/                # Configuration files

πŸ”§ Available Scripts

# Development
npm run dev               # Start development server
npm run build            # Build for production
npm run start            # Start production server
npm run lint             # Run ESLint
npm run type-check       # Run TypeScript compiler

# Testing
npm run test             # Run unit tests
npm run test:watch       # Run tests in watch mode
npm run test:coverage    # Generate coverage report
npm run e2e              # Run E2E tests

# Database
npm run db:migrate       # Run database migrations
npm run db:seed          # Seed database with sample data

# Code Quality
npm run format           # Format code with Prettier
npm run analyze          # Analyze bundle size

🎨 UI Components

Dashboard Components

  • StatCard - Display key metrics
  • IssueTable - Manage issues with filtering
  • PriorityQueue - View high-priority items
  • DepartmentGrid - Department overview

Map Features

  • HeatmapLayer - Visualize issue density
  • ClusterMarkers - Group nearby issues
  • RouteOptimization - Optimal path planning
  • LiveTracking - Real-time team locations

AI Integration

  • ChatInterface - Conversational AI assistant
  • InsightCards - AI-generated insights
  • PredictionCharts - Forecast visualizations
  • AutoSuggestions - Smart recommendations

πŸ” Authentication & Authorization

The admin panel supports multiple authentication methods:

  • Email/Password - Traditional authentication
  • OAuth2 - Google, GitHub, Microsoft
  • SSO - Single Sign-On for enterprises
  • Role-Based Access - Admin, Manager, Operator roles

πŸ“Š API Integration

REST Endpoints

// Issues
GET    /api/v1/issues          // List all issues
POST   /api/v1/issues          // Create new issue
GET    /api/v1/issues/:id      // Get issue details
PUT    /api/v1/issues/:id      // Update issue
DELETE /api/v1/issues/:id      // Delete issue

// Analytics
GET    /api/v1/analytics/dashboard   // Dashboard metrics
GET    /api/v1/analytics/trends      // Trend analysis
GET    /api/v1/analytics/heatmap     // Heatmap data

// AI Services
POST   /api/v1/ai/classify          // Classify issue
POST   /api/v1/ai/chat             // AI chat
GET    /api/v1/ai/predictions      // Get predictions

GraphQL Queries

# Get issues with filters
query GetIssues($filter: IssueFilter) {
  issues(filter: $filter) {
    id
    title
    description
    status
    priority
    location {
      lat
      lng
    }
  }
}

# Real-time subscription
subscription IssueUpdates {
  issueUpdated {
    id
    status
    assignedTo
  }
}

🚒 Deployment

Docker

# Build Docker image
docker build -t civic-admin-panel .

# Run container
docker run -p 3001:3000 \
  -e NEXT_PUBLIC_API_URL=http://api.example.com \
  civic-admin-panel

Vercel

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel --prod

AWS Deployment

# Build and deploy to AWS
npm run build
aws s3 sync .next/static s3://your-bucket/static
aws cloudfront create-invalidation --distribution-id YOUR_DIST_ID --paths "/*"

πŸ§ͺ Testing

Unit Tests

npm run test

Integration Tests

npm run test:integration

E2E Tests

npm run e2e

πŸ“ˆ Performance Optimization

  • Code Splitting - Automatic route-based splitting
  • Image Optimization - Next.js Image component
  • Lazy Loading - Components loaded on demand
  • Caching Strategy - SWR for data caching
  • Bundle Analysis - Regular bundle size monitoring

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

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

πŸ™ Acknowledgments

πŸ“ž Support

πŸš€ Roadmap

  • Mobile responsive improvements
  • Offline mode support
  • Advanced AI predictions
  • Multi-language support
  • Dark mode enhancement
  • Export functionality
  • Webhook integrations
  • Performance monitoring dashboard

Built with ❀️ by SadiqueCodes

⭐ Star us on GitHub