https://github.com/rajjitlai/rbac_project
Dynamic RBAC System with Multi-App Integration
https://github.com/rajjitlai/rbac_project
Last synced: 2 months ago
JSON representation
Dynamic RBAC System with Multi-App Integration
- Host: GitHub
- URL: https://github.com/rajjitlai/rbac_project
- Owner: rajjitlai
- License: mit
- Created: 2025-07-24T19:06:16.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-07-25T09:42:25.000Z (2 months ago)
- Last Synced: 2025-07-25T10:53:54.427Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 317 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License
Awesome Lists containing this project
README
# Dynamic RBAC System with Multi-App Integration
## π Introduction
This project implements a **Dynamic Role-Based Access Control (RBAC) System** that provides authentication and fine-grained access control. It supports integration with multiple applicationsβin this case, a **Shopping App** and a **Todo App**βand was developed over a 4-day period as part of a technical assessment.
---
## π Table of Contents
* [Introduction](#-introduction)
* [Technology Stack](#-technology-stack)
* [Features](#-features)* [Authentication](#authentication)
* [Role & Permission Management](#role--permission-management)
* [Access Control](#access-control)
* [Shopping App Endpoints](#shopping-app-endpoints)
* [Todo App Endpoints](#todo-app-endpoints)
* [Bonus Features](#bonus-features)
* [Project Structure](#-project-structure)
* [Setup Instructions](#-setup-instructions)* [Backend Setup](#backend-setup)
* [Frontend Setup](#frontend-setup)
* [Docker Setup (Optional)](#docker-setup-optional)
* [API Testing](#-api-testing)
* [Database Schema](#-database-schema)
* [Evaluation Criteria](#-evaluation-criteria)
* [Contributors](#-contributors)
* [License](#-license)---
## π οΈ Technology Stack
* **Frontend**: React.js + Tailwind CSS (Vite)
* **Backend**: Node.js + Express.js
* **Database**: SQLite (managed via Sequelize ORM)
* **Authentication**: JSON Web Tokens (JWT)---
## π Features
### Authentication
* `POST /register`: Register new users.
* `POST /login`: Authenticate and issue JWT tokens.### Role & Permission Management
* `POST /roles`: Create new roles.
* `POST /permissions`: Create permissions (e.g., `todo:create`, `product:delete`).
* `POST /assign-role`: Assign a role to a user.
* `POST /assign-permission`: Assign permissions to a role.### Access Control
Implemented via Express middleware:
* Decodes JWT to identify user.
* Fetches assigned roles and permissions.
* Verifies permission for each route.### Shopping App Endpoints
* `GET /products`: Public access.
* `POST /products`: Requires `product:create`.
* `POST /cart`: Requires `cart:modify`.
* `POST /checkout`: Requires `checkout:perform`.### Todo App Endpoints
* `POST /todos`: Requires `todo:create`.
* `GET /todos`: Requires `todo:read`.
* `PUT /todos/:id`: Requires `todo:update`.
* `DELETE /todos/:id`: Requires `todo:delete`.### Bonus Features
* Admin Panel (React + Tailwind CSS)
* Swagger/OpenAPI documentation
* Docker support---
## π§± Project Structure
```
rbac_project/
βββ auth/ # JWT auth logic
βββ models/ # Sequelize models
βββ routes/ # API routes
βββ middleware/ # RBAC enforcement
βββ db/ # SQLite config and setup
βββ app.js # Main app entry
βββ frontend/ # React frontend (Vite)
βββ postman_collection.json
βββ README.md
```---
## π§° Setup Instructions
### Backend Setup
1. **Clone the Repository**
```bash
git clone https://github.com/rajjitlai/rbac_project
cd rbac_project
```2. **Install Dependencies**
```bash
npm install
```3. **Run Migrations and Seeders**
```bash
npx sequelize-cli db:migrate
npx sequelize-cli db:seed:all
```4. **Environment Setup**
Create a `.env` file:
```env
DB=./db/db_name
JWT_SECRET=your-secret-key
PORT=3000
```5. **Initialize and Run Backend**
```bash
node ./db/setup.js
npm start
```Backend will run at: `http://localhost:3000`
---
### Frontend Setup
1. **Navigate to Frontend Directory**
```bash
cd frontend
```2. **Install Dependencies**
```bash
npm install
```3. **Run the Frontend**
```bash
npm run dev
```Access at: `http://localhost:5173`
---
### Docker Setup (Optional)
1. **Build Docker Image**
```bash
docker build -t rbac-system .
```2. **Run Container**
```bash
docker run -p 3000:3000 -p 5173:5173 -e JWT_SECRET=your-secret-key rbac-system
```---
## π§ͺ API Testing
* Import `postman_collection.json` into Postman.
* Access Swagger docs at: `http://localhost:3000/api-docs`---
## ποΈ Database Schema
Sequelize Models:
| Model | Attributes |
| ---------- | ------------------------------------- |
| User | `id`, `username`, `password` |
| Role | `id`, `name` |
| Permission | `id`, `name` |
| Todo | `id`, `title` |
| Cart | `id`, `userId` |
| CartItem | `id`, `userId`, `productId`, `cartId` |
| Product | `id`, `name` |Sequelize associations manage relationships like `belongsTo`, `hasMany`, and `belongsToMany`.
---
## π Evaluation Criteria
| Criteria | Weight | Status |
| ------------------- | ------ | ---------------------- |
| API Functionality | 30% | β Fully implemented |
| RBAC Logic & Design | 25% | β Dynamic & reusable |
| Code Quality | 15% | β Clean & maintainable |
| API Usability | 15% | β Postman tested |
| Project Structure | 10% | β Organized |
| Bonus Features | 5% | β Included |---
## π₯ Contributors
* [Rajjit Laishram](https://github.com/rajjitlai/)
---
## π License
This project is licensed under the **MIT License**.
---