Skip to Content
HomeLink Hub
Admin Panel

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.

RouteView / componentAccess
/src/layouts/RootLayout.tsx (redirects to /dashboard)Anyone; lands on sign-in if not signed in
/authsrc/routes/auth.routes.tsx (redirects to /auth/signin)Public
/auth/signinsrc/views/auth/Signin.tsxPublic; a signed-in admin is redirected to /dashboard
/auth/signupsrc/routes/auth.routes.tsx (redirects to /auth/signin)Public; there is no sign-up
/auth/forgot-passwordsrc/views/auth/Forgot-password.tsxPublic; a signed-in admin is redirected to /dashboard
/auth/reset-passwordsrc/views/auth/Reset-password.tsxPublic, even when signed in
/dashboardsrc/views/dashboard/Dashboard.tsxAdmin only
/dashboard/userssrc/views/users/Users.tsxAdmin only
/dashboard/site-visitssrc/views/site-visits/SiteVisits.tsxAdmin only
/dashboard/duplicatessrc/views/duplicates/Duplicates.tsxAdmin only
/dashboard/earningssrc/views/earnings/Earnings.tsxAdmin only
/dashboard/settingssrc/views/settings/settings.tsxAdmin only

Supporting files:

ConcernFile
Routersrc/routes/router.tsx, src/routes/protected.routes.tsx, src/routes/dashboard.routes.tsx
Auth screens shellsrc/layouts/AuthLayout.tsx
Dashboard shell (guard, sidebar, header)src/layouts/DashboardLayout.tsx, src/components/app-sidebar.tsx
HTTP client and token refreshsrc/config/axios.ts
Session storagesrc/services/auth/session.ts, src/services/auth/auth-slice.ts
Role rulessrc/config/roles.ts
Redux storesrc/config/store.ts
Shared tablesrc/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:
    1. service/scripts/create-admin.js creates one seeded admin user (role ADMIN, active, email verified) if it does not already exist. The credentials are set in the script and are not documented here.
    2. service/scripts/make-admin.js takes an email as its argument and changes that existing user's role to ADMIN.
    3. An existing admin can change any user's role to ADMIN from the user detail dialog (see Users).
  • The API base URL comes from the VITE_API_URL build variable. Links out to listings and to the other sign-in pages use VITE_CONSUMER_APP_URL and VITE_CLIENT_APP_URL.

Flow

Layout and navigation

  1. After sign-in you land on /dashboard. Every page under /dashboard is wrapped in DashboardLayout.
  2. The left sidebar shows the logo with "HomeLinkHub" and "Admin Panel" (clicking it goes to /dashboard), then a "Navigation" group:
Sidebar labelGoes toHeader title on that page
Dashboard/dashboardDashboard
Users/dashboard/usersUser Management
Site Visits/dashboard/site-visitsSite Visits
Duplicates/dashboard/duplicatesDuplicate Listings
Earnings/dashboard/earningsPlatform Earnings
Propertiesnothing (disabled, tagged "Soon")not applicable
Settings/dashboard/settingsSettings
  1. The sidebar collapses to icons with the trigger button at the left of the header; labels then show as tooltips.
  2. The header shows the page title and a light/dark toggle on the right (see Appearance in Platform settings).
  3. "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 keyHolds
userJSON of the signed-in user: id, firstName, lastName, email, role, avatar
tokenThe access token, sent as Authorization: Bearer ... on every request
refreshTokenThe refresh token, used to renew the access token
admin-themeThe 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

  1. DashboardLayout checks the Redux auth state on every render. If there is no token, or the stored user's role is not ADMIN, it redirects to /auth/signin and remembers the page you were on, so sign-in returns you there.
  2. AuthLayout does the reverse: with a token and an ADMIN user, /auth/signin and /auth/forgot-password redirect to /dashboard. /auth/reset-password is left open so a reset link from an email still works on a signed-in machine.
  3. These guards are a convenience only. Every /api/v1/admin/* request is checked on the server by authenticateUser and authorizeRoles(ADMIN).

Token refresh and expiry

  1. Any API call that returns 401 (other than the auth endpoints themselves) triggers one POST /api/v1/auth/refresh-token with the stored refreshToken. Requests that fail at the same moment share that one refresh.
  2. On success the new access token is written to localStorage key token and to the auth slice, and the original request is retried once.
  3. If the refresh fails, or there is no refresh token, the three session keys are cleared and the auth slice is flagged sessionExpired. DashboardLayout then redirects to /auth/signin, which shows "Your session expired. Sign in again to continue."

Signing out

  1. Click "Sign Out" in the sidebar.
  2. The app calls POST /api/v1/auth/signout with the stored refresh token so the server revokes it.
  3. 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=20 when 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.ts exists but nothing imports it; every screen reads live API data.

What happens next

On this page