Admin Panel overview
What the internal admin panel is, who can get in, how it is laid out, and how sessions and route guards work.
The admin panel is the internal back office for HomeLink Hub. It is a single-page app (React 19, Vite, react-router, Redux Toolkit, axios, TanStack Table, shadcn UI) that talks to the same API as the other apps, using the /api/v1/admin/* endpoints plus /api/v1/settings and /api/v1/auth/*.
Only accounts with the role ADMIN can use it. Agents, landlords and lawyers have their own portal (the client app); tenants and developers use the consumer app. The sign-in screen sends anyone else to the right place.
Where it lives
All paths are relative to the admin repo.
| Route | View / component | Access |
|---|---|---|
/ | src/layouts/RootLayout.tsx (redirects to /dashboard) | Anyone; lands on sign-in if not signed in |
/auth | src/routes/auth.routes.tsx (redirects to /auth/signin) | Public |
/auth/signin | src/views/auth/Signin.tsx | Public; a signed-in admin is redirected to /dashboard |
/auth/signup | src/routes/auth.routes.tsx (redirects to /auth/signin) | Public; there is no sign-up |
/auth/forgot-password | src/views/auth/Forgot-password.tsx | Public; a signed-in admin is redirected to /dashboard |
/auth/reset-password | src/views/auth/Reset-password.tsx | Public, even when signed in |
/dashboard | src/views/dashboard/Dashboard.tsx | Admin only |
/dashboard/users | src/views/users/Users.tsx | Admin only |
/dashboard/site-visits | src/views/site-visits/SiteVisits.tsx | Admin only |
/dashboard/duplicates | src/views/duplicates/Duplicates.tsx | Admin only |
/dashboard/earnings | src/views/earnings/Earnings.tsx | Admin only |
/dashboard/settings | src/views/settings/settings.tsx | Admin only |
Supporting files:
| Concern | File |
|---|---|
| Router | src/routes/router.tsx, src/routes/protected.routes.tsx, src/routes/dashboard.routes.tsx |
| Auth screens shell | src/layouts/AuthLayout.tsx |
| Dashboard shell (guard, sidebar, header) | src/layouts/DashboardLayout.tsx, src/components/app-sidebar.tsx |
| HTTP client and token refresh | src/config/axios.ts |
| Session storage | src/services/auth/session.ts, src/services/auth/auth-slice.ts |
| Role rules | src/config/roles.ts |
| Redux store | src/config/store.ts |
| Shared table | src/components/data-table/* |
Before you start
- You need an account whose role is
ADMIN, with a verified email and active status. - There is no public sign-up. Admin accounts come from one of three places:
service/scripts/create-admin.jscreates one seeded admin user (roleADMIN, active, email verified) if it does not already exist. The credentials are set in the script and are not documented here.service/scripts/make-admin.jstakes an email as its argument and changes that existing user's role toADMIN.- An existing admin can change any user's role to
ADMINfrom the user detail dialog (see Users).
- The API base URL comes from the
VITE_API_URLbuild variable. Links out to listings and to the other sign-in pages useVITE_CONSUMER_APP_URLandVITE_CLIENT_APP_URL.
Flow
Layout and navigation
- After sign-in you land on
/dashboard. Every page under/dashboardis wrapped inDashboardLayout. - The left sidebar shows the logo with "HomeLinkHub" and "Admin Panel" (clicking it goes to
/dashboard), then a "Navigation" group:
| Sidebar label | Goes to | Header title on that page |
|---|---|---|
| Dashboard | /dashboard | Dashboard |
| Users | /dashboard/users | User Management |
| Site Visits | /dashboard/site-visits | Site Visits |
| Duplicates | /dashboard/duplicates | Duplicate Listings |
| Earnings | /dashboard/earnings | Platform Earnings |
| Properties | nothing (disabled, tagged "Soon") | not applicable |
| Settings | /dashboard/settings | Settings |
- The sidebar collapses to icons with the trigger button at the left of the header; labels then show as tooltips.
- The header shows the page title and a light/dark toggle on the right (see Appearance in Platform settings).
- "Sign Out" sits at the bottom of the sidebar.
Properties is not built yet
The sidebar has a "Properties" item pointing at /dashboard/properties, but it is disabled and no such route is registered in the router. Listings are currently reviewed per user, from the Properties tab of the user detail dialog.
Session storage
Signing in stores three localStorage keys, mirrored in the Redux auth slice (user, token, refreshToken):
| localStorage key | Holds |
|---|---|
user | JSON of the signed-in user: id, firstName, lastName, email, role, avatar |
token | The access token, sent as Authorization: Bearer ... on every request |
refreshToken | The refresh token, used to renew the access token |
admin-theme | The Appearance choice (light, dark or system); not part of the session |
On page load the auth slice rehydrates from these keys, so a refresh keeps you signed in. An expired access token is kept as long as a refresh token exists.
Route guards
DashboardLayoutchecks the Reduxauthstate on every render. If there is notoken, or the stored user's role is notADMIN, it redirects to/auth/signinand remembers the page you were on, so sign-in returns you there.AuthLayoutdoes the reverse: with a token and anADMINuser,/auth/signinand/auth/forgot-passwordredirect to/dashboard./auth/reset-passwordis left open so a reset link from an email still works on a signed-in machine.- These guards are a convenience only. Every
/api/v1/admin/*request is checked on the server byauthenticateUserandauthorizeRoles(ADMIN).
Token refresh and expiry
- Any API call that returns
401(other than the auth endpoints themselves) triggers onePOST /api/v1/auth/refresh-tokenwith the storedrefreshToken. Requests that fail at the same moment share that one refresh. - On success the new access token is written to
localStoragekeytokenand to theauthslice, and the original request is retried once. - If the refresh fails, or there is no refresh token, the three session keys are cleared and the
authslice is flaggedsessionExpired.DashboardLayoutthen redirects to/auth/signin, which shows "Your session expired. Sign in again to continue."
Signing out
- Click "Sign Out" in the sidebar.
- The app calls
POST /api/v1/auth/signoutwith the stored refresh token so the server revokes it. - Whether or not that call succeeds, the local session is cleared and you are taken to
/auth/signin.
States and edge cases
- A stale session that belongs to a non-admin (for example left over from before admin-only login) is treated as signed out.
- An unknown URL under
/dashboard(including/dashboard/properties) has no matching route and no catch-all page.src/error-page.tsx("Error!", "Something went wrong") is attached to the/route only. - The app has no toast notifications. Results show as inline messages, banner errors, or simply as the data changing on screen.
- Tables keep the current page in the URL (
?page=3, and?pageSize=20when not the default), so a refresh or a shared link lands on the same page. Search text, filters, sorting and row selection are not kept in the URL. src/lib/mock-data.tsexists but nothing imports it; every screen reads live API data.
What happens next
- Sign in and password reset covers getting in.
- Dashboard explains each headline number.
- Users, Site visits, Duplicate listings, Earnings and payouts and Platform settings cover the day-to-day work.
HomeLink Hub