overview
๐ง Junior MVP Frontend โ Overviewโ
๐ Objective:โ
Create a multi-role SaaS dashboard for "Junior" that enables:
- Admins to manage users/roles/settings
- Users to log in and perform role-specific tasks
- Secure internal and external communication between services (REST)
๐๏ธ Core Features in MVPโ
1. Authentication & Authorizationโ
- โ JWT-based auth with login flow
- โ Role-based UI rendering (Admin, User, etc.)
- โ Frontend reads token from localStorage
- โ
REST API call to
/api/user/me
to fetch role and details - ๐ Protect routes via role-based guards
2. Routing & Layoutโ
-
Uses
react-router-dom
with:/login
โ Login page/dashboard
โ Protected layout- Nested routes under
/dashboard/*
-
Global layout with top nav + sidebar (conditionally rendered)
3. User Dashboardโ
- ๐ค Display user profile info (name, role, etc.)
- ๐ Role-specific dashboard home screen
- โ
Fetch user data using
restTemplate
call to auth service
4. Admin Panelโ
- ๐งโ๐ผ List users with pagination
- โ Add new user (basic form)
- ๐ ๏ธ Assign/remove roles
- ๐ซ Enable/disable users
- ๐ Refresh tokens or session control
5. Common Componentsโ
- Toasts for feedback
- Modal for confirmations
- Error boundary / error pages (401, 403, 500)
๐ ๏ธ Tech Stackโ
Feature | Tool |
---|---|
UI | React + Vite + SWC |
Styling | TailwindCSS |
Routing | React Router |
State | LocalStorage + React Context |
Auth | JWT token stored in localStorage |
Build Tool | Vite |
Testing | Vitest (optional) |
Linting | ESLint |
CI/CD | GitHub Actions (provided above) |
๐ Security MVP (Frontend)โ
- โ
Token stored in
localStorage
(consider httpOnly cookie if needed later) - โ
Add token to
Authorization: Bearer <token>
header in all API calls - โ Block unauthorized routes if no valid user or token
- ๐ Token expiration handling (optional refresh logic MVP+)
- โ Disable all CORS protection on dev for local REST access
๐ Communication with Backendโ
-
Frontend fetches data from:
/api/user/me
(for auth)/api/users/*
(for admin panel)
-
Internally, backend uses
RestTemplate
to communicate between microservices. -
Youโve set allowed origin to
http://localhost:8082
from backend for dev.
๐ MVP Flowโ
- โ
Login page โ Enter credentials โ POST
/api/auth/login
- โ
On success, token saved to
localStorage
- โ
Token used to GET
/api/user/me
to retrieve user info and roles - โ Role-based dashboard UI rendered
- โ Admins can manage users
- โ Users can see their profile / perform role tasks
๐งช Bonus: Test Plan (Optional for MVP)โ
Feature | Test |
---|---|
Login | Valid/Invalid credentials |
Token | Expired/missing token redirects to /login |
Routing | Protected routes only accessible if logged in |
Roles | Only admins can access /dashboard/admin |
API Errors | Show toast + retry option |