Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Full-Stack Role-Based Access Control (RBAC) System

Next.js NestJS Prisma TailwindCSS TypeScript Swagger

A production-grade, full-stack Role-Based Access Control (RBAC) web application featuring JWT Access & Refresh Token Authentication, granular Authorization matrix enforcement, Member Management CRUD, an interactive Admin Dashboard, Audit Logging, and a responsive glassmorphism dark/light interface.


🌟 Key Features

🛡️ Authentication & Session Management

  • JWT Access Token: Short-lived (15 minutes) bearer token for route protection.
  • JWT Refresh Token: Long-lived (7 days) token saved in database to enable seamless auto-refreshing without forcing user re-logins.
  • Token Rotation & Security: Password hashing with bcrypt (10 salt rounds), automatic token refresh interceptor on 401 Unauthorized responses.
  • Logout Session Revocation: Invalidates refresh tokens in the database upon logout.

🔑 Authorization & Permissions Matrix (RBAC)

Strictly enforced across both Backend NestJS Guards and Frontend UI components:

Action / Feature Admin Manager Member
View Members List (GET /members) ✅ Granted ✅ Granted ✅ Granted
View Member Details (GET /members/:id) ✅ Granted ✅ Granted ✅ Granted
Create Member (POST /members) ✅ Granted ✅ Granted ❌ Restricted
Edit Member (PUT /members/:id) ✅ Granted ✅ Granted ❌ Restricted
Delete Member (DELETE /members/:id) ✅ Granted ❌ Restricted ❌ Restricted
View Audit Logs (GET /audit-logs) ✅ Granted ❌ Restricted ❌ Restricted

📊 Admin Dashboard

  • Live count widgets for Total Users, Total Admins, Total Managers, and Total Members.
  • Visual Permissions Matrix Card illustrating system privileges.
  • Quick navigation links and active role status badges.

👥 Member Management Module (CRUD)

  • Data Table: Displays Name, Email, Phone, Role Badge, Status Badge, and Created Date.
  • Search: Real-time filtering by Name, Email, or Phone.
  • Filtering: Dropdown filters for Role (ADMIN, MANAGER, MEMBER) and Status (Active, Inactive).
  • Sorting: Multi-column sorting (Name, Email, Role, Created Date).
  • Pagination: Server-side paginated queries with Next/Previous controls.
  • Modal Dialogs: Contextual dialogs for Creating, Editing, and Confirming Member Deletion.

🎁 Bonus Features Included

  1. 📚 Swagger OpenAPI Documentation: Interactive API UI hosted at http://localhost:4000/api/docs.
  2. 🧪 Unit Tests: Full Jest test suite covering Auth & Member services (100% pass).
  3. 🌙 Dark & Light Mode: Dynamic theme switcher with persistent local storage preferences.
  4. 📜 Audit Logs: Database tracking of user events (Login, Member Creation, Modifications, Deletions) with timestamps and user details.

🛠️ Tech Stack

Frontend

  • Framework: Next.js 16 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS v4, Lucide Icons, Glassmorphism design system
  • HTTP Client: Axios with custom interceptors for automatic token renewal

Backend

  • Framework: NestJS 11 (TypeScript)
  • Database ORM: Prisma ORM 6 with SQLite (dev.db) & PostgreSQL support
  • Auth & Security: Passport.js, @nestjs/jwt, bcrypt, class-validator, class-transformer
  • API Docs: @nestjs/swagger

🚀 Quick Start Guide

Prerequisites

  • Node.js v18+ or v20+ or v22+
  • npm v9+ or v10+

1. Backend Setup

cd backend
npm install
npm run seed       # Seeds default Admin, Manager, Member accounts & sample data
npm run start:dev  # Runs backend on http://localhost:4000

2. Frontend Setup

cd frontend
npm install
npm run dev        # Runs frontend on http://localhost:3000

🔑 Demo Seed Credentials

For quick evaluation, use the one-click demo login cards on the /login page or use the credentials below:

Role Email Password Access Level
Admin admin@rbac.com Admin123! Full Access (CRUD + Audit Logs)
Manager manager@rbac.com Manager123! Create & Edit Members (No Delete/Audit)
Member member@rbac.com Member123! View Only Access

📄 Project Documentation Links

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages