Skip to content

The system uses data structures like queues to prioritize urgent complaints, stacks to store historical data of resolved complaints, and file handling to maintain logs of actions for transparency and audit purposes.

Notifications You must be signed in to change notification settings

msranjana/Waste-Management-and-Prioritised-Complaint-Handling-System-Backend

Repository files navigation

Waste Management & Prioritized Complaint Handling System Backend

Project Overview

This project aims to streamline the process of managing waste collection complaints in Mangalore (or similar urban areas) by providing an efficient system for handling, prioritizing, and resolving complaints. The system uses data structures like queues to prioritize urgent complaints, stacks to store historical data of resolved complaints, and file handling to maintain logs of actions for transparency and audit purposes. Complaints are categorized and processed based on their priority, such as health hazards or missed pickups in sensitive areas (e.g., near hospitals or schools).


Features

  • Complaint Prioritization: Complaints are handled based on urgency. For example, complaints near hospitals or schools are prioritized.
  • Historical Tracking: Resolved complaints are stored in a stack for potential reversion or review.
  • Log Generation: A CSV file of resolved complaints is generated for auditing purposes.
  • RESTful API: The backend exposes API endpoints for submitting complaints, viewing complaints, resolving complaints, and generating logs.
  • Scalable System: Built using Node.js and Express, it provides an extensible architecture for future improvements.

Project Structure

waste-management-system/
├── models/
│   ├── complaintsQueue.js        # Handles the complaint queue logic (priority-based)
│   ├── resolvedStack.js          # Manages resolved complaints stack
├── routes/
│   ├── complaints.js             # API routes for complaints
│   ├── logs.js                   # API routes for logs (e.g., CSV generation)
│   ├── resolved.js               # API routes for resolving complaints
├── utils/
│   ├── csvWriter.js              # Utility to write data to CSV files
├──  resolved_complaints_log.csv  # CSV file to store resolved complaints
├── index.js                        # Main server entry point
├── README.md                     # Documentation for the project
├── .gitignore                    # Git ignored files (e.g., node_modules/, logs, etc.)
├── package.json                  # Project metadata and dependencies
├── package-lock.json             # Lock file for npm

API Endpoints

1. POST /complaints

  • Description: Submit a new complaint to the system.
  • Request Body Example:
    {
      "complaintId": "C001",
      "description": "Missed garbage pickup near hospital",
      "priority": 1
    }
    

Response Example:

{
  "message": "Complaint submitted successfully!"
}

2. GET /complaints

  • Description: Fetch all active complaints in the system.

Response Example:

json
[
  {
    "complaintId": "C001",
    "description": "Missed garbage pickup near hospital",
    "priority": 1
  },
  {
    "complaintId": "C002",
    "description": "Overflowing garbage bin in park",
    "priority": 2
  }
]

3. POST /resolve

  • Description: Resolve the highest-priority complaint and move it to the resolved stack.

Response Example:

json
{
  "message": "Complaint C001 resolved and moved to history."
}

4. GET /resolved

  • Description: Fetch all resolved complaints stored in the stack.

Response Example:

json
[
  {
    "complaintId": "C001",
    "description": "Missed garbage pickup near hospital",
    "resolvedAt": "2024-12-01T12:00:00Z"
  }
]

5. GET /generate-log

  • Description: Generate a .csv file of resolved complaints.

Response Example:

json
{
  "message": "Resolved complaints log generated successfully."
}


Setup Instructions

1. Clone the Repository

To begin, clone the repository to your local machine by running the following command in your terminal or command prompt:

git clone /~https://github.com/msranjana/Waste-Management-and-Prioritised-Complaint-Handling-System.git

Next, navigate into the project directory using the command:

cd Waste-Management-and-Prioritised-Complaint-Handling-System

2. Install Dependencies

Before you can run the project, you need to install the necessary dependencies. Make sure you have Node.js installed on your system. If not, you can download it from the official Node.js website.

Once Node.js is installed, run the following command to install the required packages:

npm install

3. Start the Server

After the dependencies are installed, you can start the backend server by running the following command:

node app.js

Once the server is started, it will listen on http://localhost:3000. You can check if the server is running by visiting this URL in your browser or using Postman to test the endpoints.

4. Acess the application

After starting the server, it will be accessible locally on http://localhost:3000. You can now test the API endpoints using tools like Postman or cURL. Follow the instructions in the API Endpoints section to test each API route.


About

The system uses data structures like queues to prioritize urgent complaints, stacks to store historical data of resolved complaints, and file handling to maintain logs of actions for transparency and audit purposes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published