Skip to content

pari-dubey1/Civix

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

๐Ÿšง Civix โ€“ Local Civic Issue Reporting App

Domain: Governance / Public Welfare
Tagline: Empowering citizens, enabling better governance.

Issues Forks Stars

๐Ÿง  Overview

Civix is a full-stack web application designed to streamline the process of reporting, tracking, and resolving local civic issues such as potholes, broken streetlights, and uncollected garbage. It provides a bridge between citizens and municipal authorities, bringing accountability and transparency to local issue resolution.

Image Caption: Citizen view showing issue reporting interface

๐Ÿšจ Problem Addressed

Local civic issues often go unnoticed or unresolved due to:

  • Lack of structured, user-friendly reporting systems
  • No transparent status tracking
  • Difficulty in community prioritization

โœจ Features

Image Caption: Step-by-step issue reporting process

๐Ÿง Citizens

  • ๐Ÿ“ Report Issues: Submit problems with description, live location (via map), and image
  • ๐Ÿ” Track Status: View transitions from Open โ†’ In Progress โ†’ Resolved
  • ๐Ÿ‘ Upvote Issues: Support others' reports to highlight common concerns

๐Ÿง‘โ€๐Ÿ’ผ Admins (City Workers)

  • ๐Ÿ“Š Dashboard: View, filter, and manage all reported issues
  • ๐Ÿ”ง Status Management: Update progress and mark resolutions
  • ๐Ÿ”’ Role-Based Access: Secure login for Citizens and Admins

๐Ÿ“˜ Civic Education & Rights

Civix now includes a fully frontend civic learning module to educate usersโ€”especially students and first-time votersโ€”about their rights and responsibilities.

Route: /civic-education
File: src/Pages/CivicEducation.jsx

โœจ Highlights

  • ๐Ÿง  Interactive Quiz System with progress tracking and localStorage-based scores
  • ๐Ÿ† Gamified XP system, achievements, and level-ups
  • ๐Ÿ—‚๏ธ Tabbed layout for Overview, Learn, Quiz, and Resources
  • ๐Ÿ”– Bookmark favorite sections and save them locally
  • ๐Ÿ“Š Reading Progress Bar and Civic Journey visualization
  • ๐Ÿ’ก Animated โ€œDid You Know?โ€ facts carousel
  • ๐Ÿ“ฅ Downloadable PDFs and curated civic resources
  • ๐ŸŽ‰ Celebration animations on milestone completions

๐Ÿงญ Civic Simulator

Civix now includes a standalone interactive simulator that allows users to step into civic leadership roles. Through animated dilemmas and slider-based decisions, users make trade-offs and explore the consequences of their choicesโ€”all within a frontend-only experience.

Route: /civic-simulator
File: src/Pages/CivicSimulator.jsx

โœจ Highlights

  • ๐ŸŽฎ Scenario Cards โ€“ Solve dilemmas like budget allocation or policy conflicts using sliders and toggles
  • ๐Ÿง  Outcome Feedback โ€“ Dynamic responses based on user choices (public satisfaction, resource balance)
  • ๐Ÿ“Š Civic Style Profiling โ€“ Discover civic personas like โ€œPlannerโ€ or โ€œAdvocateโ€ based on decisions
  • ๐Ÿ” Replayable Challenges โ€“ Rerun scenarios to improve your score and try alternate outcomes
  • ๐Ÿ… XP & Badges โ€“ Earn experience points and unlock achievement badges locally
  • ๐Ÿ’ก Frontend-Only Logic โ€“ Built entirely in React with localStorage persistence for decision history and XP tracking

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React.js
  • Tailwind CSS โ€“ Modern responsive UI
  • Leaflet.js โ€“ Interactive maps for location tagging

Backend

  • Node.js + Express.js
  • PostgreSQL โ€“ Relational DB for reports and user data
  • JWT Authentication โ€“ Secure role-based access
  • Multer โ€“ File upload handling
  • Swagger โ€“ API documentation
  • Helmet.js โ€“ Security middleware
  • Express Rate Limit โ€“ API protection

Integrations

  • Cloudinary โ€“ Image uploads and hosting
  • JWT Authentication โ€“ Secure role-based access

๐Ÿ”ง Backend API Features

๐Ÿ” Authentication System

  • JWT-based authentication with role management
  • Admin/User role separation for different access levels
  • Secure password hashing using bcrypt
  • Token expiration and refresh handling

๐Ÿ“ก RESTful API Endpoints

  • GET /api/issues - Retrieve all civic issues
  • POST /api/issues - Create new issue with file upload
  • PATCH /api/issues/:id/status - Update issue status (Admin only)
  • POST /api/auth/signup - User registration
  • POST /api/auth/login - User authentication

๐Ÿ›ก๏ธ Security Features

  • Rate limiting (100 requests per 15 minutes)
  • Input validation using express-validator
  • XSS protection and security headers
  • CORS configuration for frontend integration
  • File upload security with type validation

๐Ÿ“Š API Documentation

  • Interactive Swagger UI at /api-docs
  • Complete endpoint documentation with examples
  • Schema definitions for request/response objects
  • Authentication testing directly in browser

๐Ÿ—„๏ธ Database Integration

  • PostgreSQL for reliable data storage
  • Optimized queries with proper indexing
  • User management with secure credential storage
  • Issue tracking with status management

๐Ÿ“ File Management

  • Image upload support for issue reporting
  • File validation and security checks
  • Organized storage in uploads directory
  • Efficient file handling with Multer middleware

๐ŸŒ— Dark Mode Toggle

Implementation:

  • darkMode: 'class' in tailwind.config.js
  • User preference saved via localStorage
  • Toggle switch: src/ThemeToggle.jsx (used in Home.jsx)

How to Use:

  1. Locate the toggle button (๐ŸŒ™/โ˜€๏ธ) in the header
  2. Click to switch between:
    • Light Mode: White/light gray backgrounds (bg-slate-50) with dark text (text-gray-900)
    • Dark Mode: Dark gray backgrounds (dark:bg-gray-800) with light text (dark:text-gray-100)

๐Ÿš€ Getting Started

Image Caption: Admin dashboard with issue management tools

Prerequisites

  • Node.js 16+
  • npm 8+
  • PostgreSQL 14+
  • Cloudinary account (for image uploads)

๐Ÿ“ก API Usage Examples

Authentication

# Register new user
curl -X POST http://localhost:5000/api/auth/signup \
  -H "Content-Type: application/json" \
  -d '{"username":"john_doe","email":"[email protected]","password":"password123"}'

# Login user
curl -X POST http://localhost:5000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","password":"password123"}'

Issue Management

# Get all issues
curl -X GET http://localhost:5000/api/issues

# Create new issue with image
curl -X POST http://localhost:5000/api/issues \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -F "title=Pothole on Main Street" \
  -F "description=Large pothole causing traffic issues" \
  -F "location=Main Street & 5th Ave" \
  -F "category=road" \
  -F "file=@/path/to/image.jpg"

# Update issue status (Admin only)
curl -X PATCH http://localhost:5000/api/issues/1/status \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"status":"in-progress"}'

API Documentation

  • Swagger UI: http://localhost:5000/api-docs
  • Interactive testing of all endpoints
  • Complete schema documentation
  • Authentication examples

Testing

  • Backend Testing: Jest, Supertest, MongoDB Memory Server
  • Frontend Unit/Component Testing: Vitest, React Testing Library
  • Frontend E2E Testing: Cypress

โœ… Running Tests

We have a comprehensive testing suite to ensure code quality and stability.

Backend Tests (Jest & Supertest)

These tests cover the API endpoints. They run against an in-memory MongoDB database to ensure a clean, isolated environment for each test run, preventing any impact on your development database.

To run all backend tests, navigate to the /backend directory and run:

npm test

Frontend Unit & Component Tests (Vitest)

These tests verify that individual React components render and behave correctly in isolation. We use Vitest and React Testing Library for this.

To run all frontend unit tests, navigate to the /frontend directory and run:

npm test

Frontend End-to-End (E2E) Tests (Cypress)

E2E tests simulate real user workflows in a browser from start to finish. This helps catch bugs in critical user journeys like logging in, creating a post, or navigating the application.

To open the Cypress Test Runner, navigate to the /frontend directory and run:

npm run cypress:open

### ๐Ÿ“ฅ Installation  
๐Ÿ“ฆ 1.**Clone the repository**:  
   ```bash
   git clone https://github.com/Harshs16/civix.git
   cd Civix
  
๐Ÿ“ฆ 2. **Install Dependencies**

Make sure you have **Node.js** and **npm** installed.  
Then, install the project dependencies:

```bash

npm install

๐ŸŒฑ 3. Create a New Branch

Use a meaningful branch name:

git checkout -b your-feature-name

Example:

git checkout -b improve-readme

๐Ÿ› ๏ธ 4. Make Your Changes

  • Improve the code, fix bugs, or update docs.
  • If you're running the project:
    npm start
    

โœ… 5. Stage and Commit

git add .
git commit -m "feat: your clear and concise commit message"

๐Ÿš€ 6. Push Your Branch

git push origin your-feature-name

๐Ÿ” 7. Create a Pull Request

  • Go to your forked repo on GitHub
  • Click โ€œCompare & pull requestโ€
  • Add a helpful description of what you changed and why

๐Ÿ“Œ Roadmap / Future Enhancements

  • ๐Ÿ”” Push notifications for issue updates
  • ๐Ÿ“ˆ Analytics for civic issue trends
  • ๐ŸŒ Multilingual support
  • ๐Ÿ“ฑ Mobile app (React Native)

๐Ÿค Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss your ideas.


๐ŸŒŸ Our Awesome Contributors


๐Ÿ“„ License

MIT License. See LICENSE file for more details.

โฌ†๏ธ Back to Top

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 93.2%
  • CSS 6.4%
  • Other 0.4%