# gwaliorkilla-ctrl/grievance-portal-backend architecture

> Architecture diagram of the GitHub repository gwaliorkilla-ctrl/grievance-portal-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gwaliorkilla-ctrl/grievance-portal-backend
- Repository: https://github.com/gwaliorkilla-ctrl/grievance-portal-backend

## Overview

This is a grievance-portal API for submitting complaints with PDF documents, listing complaints with filters and pagination, retrieving a complaint, and resolving it by deletion. The principal submission flow validates request fields and the uploaded PDF, stores the document, then records its URL and complaint details. Listing, lookup, and deletion are separate service operations. The README provides no implementation details; the map follows the sampled source, with external Supabase resources shown as dependencies.

Main entry points: [`src/services/complaint.service.js`](https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/services/complaint.service.js) (Complaint service), [`src/routes/complaint.routes.js`](https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/routes/complaint.routes.js) (Complaint routes), [`src/controllers/complaint.controller.js`](https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/controllers/complaint.controller.js) (Request handling), [`src/app.js`](https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/app.js) (Express app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_server["Server entry<br/>[index.js]"]
  node_app["Express app<br/>[app.js]"]
  node_routes["Complaint routes"]
  node_upload["PDF upload filter<br/>[upload.js]"]
end

subgraph group_complaints["Complaint operations"]
  node_controller["Request handling"]
  node_service["Complaint service"]
end

subgraph group_persistence["Persistence"]
  node_supabase_client["Supabase client<br/>[supabase.js]"]
  node_db[("Complaints table")]
  node_storage[("Complaint documents")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_server -->|"starts"| node_app
node_app -->|"mounts routes"| node_routes
node_routes -->|"filters PDF"| node_upload
node_routes -->|"dispatches"| node_controller
node_controller -->|"calls operations"| node_service
node_service -->|"uses client"| node_supabase_client
node_service -->|"uploads and removes files"| node_storage
node_service -->|"creates, queries, deletes"| node_db
node_controller -->|"returns responses"| node_client

click node_server "https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/index.js"
click node_app "https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/app.js"
click node_routes "https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/routes/complaint.routes.js"
click node_upload "https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/middlewares/upload.js"
click node_controller "https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/controllers/complaint.controller.js"
click node_service "https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/services/complaint.service.js"
click node_supabase_client "https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/config/supabase.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_app,node_routes,node_upload,node_client toneBlue
class node_controller,node_service toneAmber
class node_supabase_client,node_db,node_storage toneMint
```

## Components

### HTTP API

- [Server entry](https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/index.js): `index.js`
- [Express app](https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/app.js): `src/app.js`
- [Complaint routes](https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/routes/complaint.routes.js): `src/routes/complaint.routes.js`
- [PDF upload filter](https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/middlewares/upload.js): `src/middlewares/upload.js`

### Complaint operations

- [Request handling](https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/controllers/complaint.controller.js): `src/controllers/complaint.controller.js`
- [Complaint service](https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/services/complaint.service.js): `src/services/complaint.service.js`

### Persistence

- [Supabase client](https://github.com/gwaliorkilla-ctrl/grievance-portal-backend/blob/main/src/config/supabase.js): `src/config/supabase.js`
- **Complaints table**
- **Complaint documents**

### Other components

- **API client**

## Connections

- API client → Express app: sends requests
- Server entry → Express app: starts
- Express app → Complaint routes: mounts routes
- Complaint routes → PDF upload filter: filters PDF
- Complaint routes → Request handling: dispatches
- Request handling → Complaint service: calls operations
- Complaint service → Supabase client: uses client
- Complaint service → Complaint documents: uploads and removes files
- Complaint service → Complaints table: creates, queries, deletes
- Request handling → API client: returns responses
