CaseTrack is a full-stack, enterprise-grade Smart Complaint Management System designed to streamline, categorize, and track grievances within organizations. Featuring role-based dashboards, automated AI-powered complaint classification, email updates, and real-time in-app notifications, CaseTrack turns manual ticket resolution into an automated, transparent, and structured workflow.
CaseTrack implements a highly secure, role-restricted dashboard for three distinct types of users:
- Users (Complainants): Can register, log in, submit complaints with text descriptions, and track the status/resolution of their tickets in real time.
- Staff (Resolvers): Assigned to specific departments. They can view tickets assigned to them, manage ticket states (
in-progress,resolved,rejected), and write resolution notes. - Admins (Managers): Complete overview of all complaints. Admins assign pending tickets to appropriate staff members, manage system-wide users, create new admin accounts, and view global analytics.
graph TD
User([User]) -->|Submits Complaint| App[React Frontend]
App -->|POST /api/complaints| Server[Express Backend]
Server -->|Processes with| AI[Gemini API / Keyword Fallback]
AI -->|Determines Category, Priority, Dept| DB[(PostgreSQL Database)]
DB -->|Triggers Alert| Admin([Admin Dashboard])
Admin -->|Assigns Staff Member| Staff([Staff Resolver])
Staff -->|Updates Status / Adds Note| DB
DB -->|Triggers Email Notification| Nodemailer[Nodemailer Email Service]
Nodemailer -->|Status Update Alert| User
DB -->|Updates In-App Feed| Bell[Notification Bell]
erDiagram
USERS {
SERIAL id PK
TEXT name
TEXT email UK
TEXT password
TEXT role "user | staff | admin"
TEXT department
BOOLEAN isActive
TIMESTAMP lastLogin
TIMESTAMP createdAt
TIMESTAMP updatedAt
}
COMPLAINTS {
SERIAL id PK
TEXT title
TEXT description
TEXT category
TEXT priority
TEXT status "pending | in-progress | resolved | rejected"
TEXT aiCategory
TEXT aiPriority
TEXT aiSuggestedDepartment
TEXT aiSentiment
TEXT aiSummary
INTEGER submittedBy FK
INTEGER assignedTo FK
TEXT resolutionNote
TIMESTAMP createdAt
TIMESTAMP updatedAt
}
NOTIFICATIONS {
SERIAL id PK
INTEGER recipient FK
TEXT title
TEXT message
TEXT type
BOOLEAN isRead
INTEGER relatedComplaint FK
TIMESTAMP createdAt
}
USERS ||--o{ COMPLAINTS : "submits"
USERS ||--o{ COMPLAINTS : "is assigned to"
USERS ||--o{ NOTIFICATIONS : "receives"
COMPLAINTS ||--o{ NOTIFICATIONS : "triggers"
- Core Engine: Node.js, Express.js
- Database: PostgreSQL (using
pgpool, automatic schema setup and key camelization on boot) - Authentication & Security: JSON Web Tokens (JWT), BcryptJS for password hashing, Helmet for secure HTTP headers, Express-Rate-Limit for API rate limiting
- AI Core: Google Gemini API (
@google/generative-ai) with a robust keyword-based local classifier fallback to ensure 100% uptime even if API quotas are exhausted - Notification Services: Nodemailer (SMTP integration for automated confirmation, assignment, and resolution alerts)
- Framework & Build Tool: React 19, Vite, ES6+ JavaScript
- Styling Engine: Tailwind CSS v4 (offering high-speed layouts and clean, modern themes)
- Navigation: React Router DOM (v7)
- Analytics & Data Vis: Recharts (rendering dynamic charts for complaint categories, priority shares, resolution rates)
- User Alerts: React Hot Toast (beautiful responsive notifications)
- HTTP Client: Axios (configured with global interceptors for JWT injection and automated 401 session logout)
CaseTrack/
βββ backend/
β βββ config/
β β βββ db.js # PostgreSQL config, table schema initialization & key camelization
β βββ controllers/
β β βββ authController.js # Auth routines: Login, register, profile, user managers
β β βββ complaintController.js # Complaint management: submit, assign, status update, delete
β β βββ dashboardController.js # Aggregations for Recharts visualizations
β β βββ notificationController.js # Read/delete operations for user alert feed
β βββ middleware/
β β βββ auth.js # JWT verification & role protection middleware
β βββ models/ # Deprecated (moved to database configuration setup)
β βββ routes/
β β βββ authRoutes.js
β β βββ complaintRoutes.js
β β βββ dashboardRoutes.js
β β βββ notificationRoutes.js
β βββ utils/
β β βββ emailService.js # SMTP config & html layout handlers
β β βββ geminiAI.js # Gemini API interface with local fallback rules
β βββ .env.example # Template configuration for environment settings
β βββ package.json
β βββ server.js # Entry point: Server settings, limits, helmet & health check
βββ frontend/
β βββ public/ # Static client resources
β βββ src/
β β βββ components/
β β β βββ ComplaintForm.jsx # Standardized user form for submitting cases
β β β βββ Navbar.jsx # Dynamic role-responsive header navigation bar
β β β βββ NotificationBell.jsx # Sidebar dropdown with current notifications
β β β βββ ProtectedRoute.jsx # Guard routing wrapper
β β βββ context/
β β β βββ AuthContext.jsx # Top-level global auth session state provider
β β βββ pages/
β β β βββ AdminDashboard.jsx # Admin control board, assignments panel, user controls, charts
β β β βββ Login.jsx
β β β βββ Register.jsx
β β β βββ StaffPanel.jsx # Staff resolver terminal
β β β βββ UserDashboard.jsx # Complainant portal to review status
β β β βββ NotFound.jsx # Fallback 404 page
β β βββ utils/
β β β βββ api.js # Axios client setup (interceptor-wrapped)
β β βββ App.jsx # Application route mappings & styles wrapper
β β βββ index.css # Tailwind v4 import & global styles
β βββ package.json
β βββ vite.config.js
βββ README.md # Project documentation
Follow these steps to set up CaseTrack on your local environment:
- Node.js (v18.x or higher)
- PostgreSQL instance (local server or cloud host like Neon / Supabase)
- Google Gemini API Key (optional, fallback is automatically used if absent)
- SMTP Server / Credentials (e.g., Gmail App Password for email dispatches)
git clone https://github.com/your-username/CaseTrack.git
cd CaseTrack- Navigate to the
backendfolder:cd backend - Copy the example environment template:
cp .env.example .env
- Open
.envand fill in your details:PORT=5000 DATABASE_URL=postgresql://<user>:<password>@<host>:<port>/<dbname>?sslmode=require JWT_SECRET=your_jwt_secret_here GEMINI_API_KEY=your_gemini_api_key_here EMAIL_USER=your_email_user@gmail.com EMAIL_PASS=your_gmail_app_password NODE_ENV=development
- Install backend dependencies:
npm install
- Start the development server (runs auto-watch modes):
Note: Upon successful connection, the tables will be created automatically in your PostgreSQL database.
npm run dev
- Open a new terminal window and navigate to the
frontendfolder:cd frontend - Install frontend dependencies:
npm install
- Start the Vite development server:
npm run dev
- Open http://localhost:5173 in your web browser.
| HTTP Method | Endpoint | Access Level | Description |
|---|---|---|---|
| POST | /api/auth/register |
Public | Register a new User account |
| POST | /api/auth/login |
Public | Authenticate user & return JWT token |
| GET | /api/auth/profile |
Authenticated | Fetch active user credentials |
| PUT | /api/auth/profile |
Authenticated | Edit user personal information |
| GET | /api/auth/users |
Admin | Retrieve all registered users |
| PUT | /api/auth/users/:id |
Admin | Edit roles, activation state or details of a user |
| GET | /api/auth/staff |
Admin | Retrieve all members with 'staff' role |
| POST | /api/auth/create-admin |
Admin (only) | Provision a new Admin account |
| HTTP Method | Endpoint | Access Level | Description |
|---|---|---|---|
| POST | /api/complaints |
User | Submit a new complaint (auto-analyzed) |
| GET | /api/complaints/my |
User | Fetch complaints submitted by active user |
| GET | /api/complaints |
Admin, Staff | Retrieve all system complaints (Staff: only assigned) |
| GET | /api/complaints/:id |
Authenticated | Retrieve specific complaint details |
| PUT | /api/complaints/:id/status |
Admin, Staff | Update status & add resolution notes |
| PUT | /api/complaints/:id/assign |
Admin | Assign a complaint to a specific Staff resolver |
| DELETE | /api/complaints/:id |
Admin | Permanently delete a complaint |
| HTTP Method | Endpoint | Access Level | Description |
|---|---|---|---|
| GET | /api/notifications |
Authenticated | Retrieve notification feed for active user |
| PUT | /api/notifications/read-all |
Authenticated | Mark all notifications as read |
| PUT | /api/notifications/:id/read |
Authenticated | Mark a specific notification as read |
| DELETE | /api/notifications |
Authenticated | Wipe notification feed completely |
| DELETE | /api/notifications/:id |
Authenticated | Delete a single notification from feed |
| HTTP Method | Endpoint | Access Level | Description |
|---|---|---|---|
| GET | /api/dashboard/stats |
Authenticated | Returns analytics & aggregation datasets |
- XSS & HTTP Header Protections: Configured through Helmet middleware.
- DDoS/Brute-Force Shielding: Standard endpoints restricted to 200 requests/15 mins; Authentication endpoints capped at 50 requests/15 mins.
- SQL Injection Prevention: Parameterized SQL queries utilized across all database operations.
- Access Route Guards: Custom Router wrapper (
ProtectedRoute) on client and middleware check validation (protect,authorize) on the API layer.
This project is licensed under the ISC License. Feel free to fork, modify, and distribute as needed.