How bensonmacharia/jwt-go-rbac works
Main Components
A. Authentication Layer
• JWT Token Management (from util/jwt.go and util/jwtAuth.go)
• Login/Register Handlers
• Token Validation & Authorization Middleware
B. API Controllers Layer
• User Controller
• Role Controller
• Room Controller
• Booking Controller
C. Model Layer
• User Model
• Role Model
• Room Model
• Booking Model
• Authentication Models (Login/Register)
D. Database Layer
• Database Connection & Management
• [Client/External Requests]
• ↓
• [Authentication Layer]
• ↓
• [API Controllers Layer]
• ↓
• [Model Layer]
• ↓
• [Database Layer]
Specific Component Relationships to Highlight
• How JWT authentication flow works:
• Client → Login/Register → JWT Generation → Token Storage
• Demonstrate RBAC flow:
• Request → JWT Auth Middleware → Role Verification → Controller Access
• Database interactions:
• Controller → Model → Database
Implementation Details
• JWT Token Flow:
• Token Generation
• Token Validation
• Role Extraction
• Authorization Checks
• API Endpoints Groups:
• Authentication endpoints
• User management endpoints
• Room management endpoints
• Booking management endpoints
Technical Stack Indicators
• Go (Golang)
• JWT-Go package
• Database system (from database.go)
• HTTP routing system
Remember to:
• Keep the authentication flow clear and prominent
• Role-based access control checkpoints
• Clear separation between public and protected resources
• Where and how JWT tokens are validated
• Demonstrate the relationship between roles and accessible resources