Skip to content

kushal281/UrbanPatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

UrbanPatch Frontend

Community-driven micro-improvement platform for neighborhoods. Report, track, and fix local issues with real-time updates and interactive maps.

Features

  • πŸ—ΊοΈ Interactive Map - View and report issues on an interactive map with clustering
  • πŸ“ Geolocation - Automatically center map on your current location
  • πŸ“Έ Photo Uploads - Attach photos to issue reports
  • πŸ‘ Upvoting System - Support issues that matter to you
  • πŸ’¬ Real-time Comments - Discuss issues with other community members
  • πŸ”” Live Updates - See new issues and updates in real-time via WebSocket
  • 🎯 Advanced Filtering - Filter by severity, status, and tags
  • πŸ“Š Admin Dashboard - Verify, close, and manage issues
  • πŸ“€ Export Data - Export issues as CSV or GeoJSON
  • πŸ“± Responsive Design - Works on desktop, tablet, and mobile

Tech Stack

  • React 18 - UI library
  • React Router - Navigation
  • React Bootstrap - UI components
  • Leaflet - Interactive maps
  • Socket.io Client - Real-time communication
  • Axios - HTTP client
  • React Toastify - Notifications
  • React Dropzone - File uploads
  • date-fns - Date formatting

Prerequisites

  • Node.js 16+ and npm
  • Backend server running (see backend README)

Installation

  1. Navigate to frontend directory

    cd frontend
  2. Install dependencies

    npm install
  3. Create environment file

    cp .env.example .env
  4. Configure environment variables Edit .env file:

    REACT_APP_API_URL=http://localhost:5000/api
    REACT_APP_SOCKET_URL=http://localhost:5000
  5. Start development server

    npm start

    The app will open at http://localhost:3000

Available Scripts

  • npm start - Start development server
  • npm run build - Build for production
  • npm test - Run tests
  • npm run eject - Eject from Create React App (irreversible)

Project Structure

frontend/
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ index.html          # HTML template
β”‚   └── manifest.json       # PWA manifest
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/         # React components
β”‚   β”‚   β”œβ”€β”€ AdminPanel.js   # Admin dashboard
β”‚   β”‚   β”œβ”€β”€ CommentSection.js
β”‚   β”‚   β”œβ”€β”€ FilterSidebar.js
β”‚   β”‚   β”œβ”€β”€ IssueCard.js
β”‚   β”‚   β”œβ”€β”€ IssueForm.js
β”‚   β”‚   β”œβ”€β”€ IssueList.js
β”‚   β”‚   β”œβ”€β”€ Loader.js
β”‚   β”‚   β”œβ”€β”€ MapView.js      # Map component
β”‚   β”‚   └── Navbar.js
β”‚   β”œβ”€β”€ context/
β”‚   β”‚   └── AuthContext.js  # Authentication state
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ Home.js         # Main map view
β”‚   β”‚   β”œβ”€β”€ IssuePage.js    # Issue details
β”‚   β”‚   β”œβ”€β”€ Login.js        # Auth page
β”‚   β”‚   └── Profile.js      # User profile
β”‚   β”œβ”€β”€ styles/
β”‚   β”‚   └── main.css        # Global styles
β”‚   β”œβ”€β”€ api.js              # API configuration
β”‚   β”œβ”€β”€ socket.js           # Socket.io setup
β”‚   β”œβ”€β”€ App.js              # Main app component
β”‚   └── index.js            # Entry point
β”œβ”€β”€ package.json
└── README.md

Features Guide

For Users

  1. Browse Issues

    • View all reported issues on the interactive map
    • Click clusters to zoom in and see individual issues
    • Click markers to see issue details
  2. Report an Issue

    • Click "Report Issue" button
    • Click on the map to select location
    • Fill in title, description, severity, and tags
    • Upload photos (optional)
    • Submit
  3. Engage with Issues

    • Upvote issues you care about
    • Add comments and suggestions
    • View issue history and updates
  4. Track Your Activity

    • View your reported issues in your profile
    • See issues you've upvoted
    • Track resolution status

For Admins/Moderators

  1. Access Admin Dashboard

    • Navigate to /admin (link appears in navbar for admins)
  2. Manage Issues

    • Verify legitimate issues
    • Close resolved or invalid issues
    • Delete spam or inappropriate content
  3. Export Data

    • Export issues as CSV for spreadsheet analysis
    • Export as GeoJSON for GIS software

Environment Variables

Variable Description Default
REACT_APP_API_URL Backend API URL http://localhost:5000/api
REACT_APP_SOCKET_URL Socket.io server URL http://localhost:5000

Real-time Features

The app uses Socket.io for real-time updates:

  • New Issues - See new issues appear on the map instantly
  • Upvotes - Vote counts update in real-time
  • Comments - New comments appear immediately
  • Status Changes - See when issues are verified or closed

Customization

Map Settings

Edit src/components/MapView.js:

  • Change default center coordinates
  • Adjust zoom levels
  • Customize marker icons

Styling

Edit src/styles/main.css:

  • Update color scheme (CSS variables)
  • Modify spacing and layout
  • Customize component styles

Issue Categories

Edit src/components/FilterSidebar.js:

  • Add or remove severity levels
  • Customize available tags
  • Modify status options

Production Build

  1. Build the app

    npm run build
  2. Serve static files

    • The build folder contains optimized production files
    • Serve with any static hosting service (Netlify, Vercel, etc.)
    • Or serve from your backend server

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)
  • Mobile browsers

Troubleshooting

Map not loading

  • Check that Leaflet CSS is properly loaded
  • Verify tile server URLs are accessible
  • Check browser console for errors

Real-time updates not working

  • Ensure backend Socket.io server is running
  • Check CORS settings on backend
  • Verify Socket.io connection in browser console

Authentication issues

  • Clear localStorage and try again
  • Check token expiration settings
  • Verify backend auth endpoints

Images not uploading

  • Check file size limits (max 5MB)
  • Verify upload endpoint configuration
  • Check backend storage configuration

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

MIT License - See LICENSE file for details

Support

For issues and questions:

  • Open an issue on GitHub
  • Contact the development team
  • Check documentation

Built with ❀️ for better neighborhoods

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors