Single Next.js application with API routes, NextAuth, Prisma (PostgreSQL), and Tailwind CSS.
- Authentication with credentials (NextAuth, JWT sessions)
- Roles: Admin, Officer, Public
- Grievances: submit, view, update status, assign
- Dashboard stats
- Categories API
- Prisma migrations and seed
- Node.js 18+
- PostgreSQL running locally or remote
- Create
.envin project root:
DATABASE_URL=postgresql://postgres:password@localhost:5432/grievance_db
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=dev-secret-change- Install dependencies and run dev:
npm install
npx prisma generate
npm run devThe dev script will ensure the database exists, run migrations, and seed initial data.
Default users:
- admin@example.com / password123 (ADMIN)
- officer@example.com / password123 (OFFICER)
- public@example.com / password123 (PUBLIC)
GET /api/dashboard/statsGET /api/categoriesGET /api/grievancesPOST /api/grievancesGET /api/grievances/:idPUT /api/grievances/:id
npm run dev– ensure DB, migrate, seed, start Next.jsnpm run build– build appnpm run start– start production servernpm run seed– seed database
- Environment variable
NEXT_PUBLIC_API_URLdefaults tohttp://localhost:3000for client requests. - The older nested
backend/andweb/apps are not required to run; this root app is self-contained.