How mb-111-3/role-based-access-control-rbac-system works
This is a React and Go RBAC application for managing accounts and content under admin, editor, and viewer roles. A user registers or logs in through the client; the client stores the returned identity and JWT, then uses the token for protected API requests. Gin routes apply authentication and role checks before dispatching account or content operations, which use GORM and MySQL. The README documents dashboard, content, and admin capabilities; some page and handler wiring is represented from that documentation because those sources were not sampled.
Main entry points: App.jsx Route application · axios.js API client · routes.go API routes · auth.go Authentication
Components 18
React client
- Route application
client/src/App.jsx - Auth state
client/src/context/AuthContext.jsx - API client
client/src/api/axios.js - Login page
client/src/pages/Login.jsx - Registration page
client/src/pages/Register.jsx - Dashboard
client/src/pages/Dashboard.jsx - Content page
client/src/pages/ContentPage.jsx - Admin panel
client/src/pages/AdminPanel.jsx
API and security
- Gin server
server/main.go - API routes
server/routes/routes.go - JWT and roles
server/middleware/auth.go
Account and content
- Authentication
server/handlers/auth.go - User management
server/handlers/users.go - Content management
server/handlers/content.go
Persistence
- DB setup and seeds
server/config/database.go - User and content models
server/models/models.go - MySQL
Other components
- User
Connections 28
- User → Route application: uses
- Route application → Login page: routes to
- Route application → Registration page: routes to
- Route application → Dashboard: routes to
- Route application → Content page: routes to
- Route application → Admin panel: admin route
- Route application → Auth state: reads auth state
- Login page → API client: requests login
- Registration page → API client: requests registration
- API client → Gin server: sends API requests
- API client → Auth state: uses stored token
- Admin panel → API client: manages users
- Content page → API client: content requests
- Gin server → DB setup and seeds: connects, migrates, seeds
- Gin server → API routes: registers routes
- API routes → JWT and roles: guards protected routes
- API routes → Authentication: dispatches auth
- API routes → User management: dispatches user actions
- API routes → Content management: dispatches content actions
- Authentication → JWT and roles: signs JWT
- Authentication → MySQL: reads and writes accounts
- User management → MySQL: manages accounts
- Content management → MySQL: manages content
- DB setup and seeds → MySQL: connects and seeds
- DB setup and seeds → User and content models: migrates
- Authentication → User and content models: uses user model
- User management → User and content models: uses user model
- Content management → User and content models: uses content model