# bricelgdb/bs-tech-cs-adminhub architecture

> Architecture diagram of the GitHub repository bricelgdb/bs-tech-cs-adminhub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bricelgdb/bs-tech-cs-adminhub
- Repository: https://github.com/bricelgdb/bs-tech-cs-adminhub

## Overview

1. **Overall shape**
   This repository is a **single-page frontend application** built with **React + TypeScript + Vite**. The UI is organized as a dashboard-style product portal with routes for **Dashboard, Products, Product Detail, Licences, Resources, Access, Reports, Login**, and a 404 page.

2. **Execution boundary**
   The app runs entirely in the browser as a SPA. There is **no custom backend code** in the repo; backend integration is done through **Supabase**. The frontend consumes either local domain data from `src/data` or Supabase-backed data depending on the feature path.

3. **Bootstrap and app shell**
   `src/main.tsx` is the entry point. It likely wires together the global providers, router, and global styles. The persistent shell is split into reusable layout pieces such as:
   - `AppLayout`
   - `AppHeader`
   - `AppSidebar`
   - `NavLink`
   
   These define the application frame around the routed page content.

4. **Routing and access control**
   The top-level pages live in `src/pages`, and auth gating is handled separately via:
   - `AuthProvider`
   - `AuthGate`
   - `RouteGuard`
   
   This suggests the architecture distinguishes between authenticated and unauthenticated routes, with login access isolated from the main app sections.

5. **Domain areas**
   The main domain concepts are visible in the data and page names:
   - **Products**
   - **Licences**
   - **Users / Access**
   - **Reports**
   - **Activity / Audit**
   - **Resources / Docs / Integrations**
   
   These are the main business objects the UI surfaces and likely the key entities in the backend schema.

6. **Product detail as a sub-application**
   `src/pages/ProductDetailPage.tsx` is decomposed into tab-specific subviews under `src/pages/tabs`:
   - Overview
   - Access
   - Audit
   - Docs
   - Integrations
   - Licences
   - Usage
   
   This indicates a **master-detail architecture** where the product list is a parent view and the detail page is a tabbed workspace with separate concerns per tab.

7. **Presentation components**
   The app uses a layer of reusable, domain-aware components in `src/components`, such as:
   - `ProductCard`, `ResourceCard`
   - `DataTable`
   - `KpiTile`
   - `Timeline`
   - `StatusBadge`, `DomainChip`
   - `Modal`, `AlertStrip`, `Skeletons`
   
   These are higher-level app widgets, distinct from the low-level UI primitives.

8. **UI primitive system**
   `src/components/ui` contains a large set of reusable primitives typical of a component library layer. These are likely generated or adapted from a design system such as **shadcn/ui** and provide the base controls for dialogs, tables, tabs, forms, tooltips, selects, etc. The architecture cleanly separates **design-system primitives** from **domain-specific composites**.

9. **Data layer**
   `src/data` contains domain datasets for:
   - `activity`
   - `licences`
   - `products`
   - `reports`
   - `users`
   
   This indicates the app has a clear in-repo data modeling layer, probably used for seeded/demo content, local rendering, or fallback data. `useDataHooks` centralizes access to this domain data for the UI.

10. **State management**
   `src/store/appStore.ts` suggests a small global store for app-level state such as selected entities, filters, UI preferences, or cross-page coordination. It is separate from component-local state and separate from the Supabase/auth layer.

11. **Supabase integration**
   The integration boundary lives under `src/integrations/supabase` with:
   - `client.ts`
   - `types.ts`
   
   The repo also includes `supabase/migrations`, which means the database schema is managed in-repo. Architecturally, Supabase serves as the external system for authentication and persisted data, while the React app is the client. The presence of generated types implies type-safe access to Supabase data.

12. **Supporting infrastructure**
   - `tailwind.config.ts`, `postcss.config.js`, and `src/index.css` indicate utility-first styling with Tailwind.
   - `vite.config.ts` and `vitest.config.ts` show Vite-based build/test tooling.
   - `src/test` contains test setup and at least one example test, so the repo includes a lightweight unit test layer.
   - `public/robots.txt` and `src/assets/products` support static public assets and product imagery.

13. **How data flows through the app**
   Typical flow is:
   - User lands on the SPA entry point.
   - Auth state is resolved through `AuthProvider` and guarded by `AuthGate` / `RouteGuard`.
   - Routed pages load domain data through hooks/store/data modules.
   - Pages render via layout components and reuse domain widgets.
   - If persistence is required, the app talks to Supabase through the typed client.

14. **Architecture summary for a diagram**
   The cleanest way to diagram this repo is as:
   - **Browser SPA shell**
   - **Authentication and route protection**
   - **Domain pages and tabbed detail views**
   - **Shared UI/design system layer**
   - **Domain data/store layer**
   - **Supabase backend boundary** with client + migrations/types

   In short, this is a **frontend-first dashboard application** with a strong separation between layout, reusable UI, domain-specific views, and Supabase-backed persistence/auth.

Main entry points: [`src/components/AppLayout.tsx`](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/components/AppLayout.tsx) (AppLayout), [`src/hooks/useDataHooks.ts`](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/hooks/useDataHooks.ts) (useDataHooks), [`src/App.tsx`](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/App.tsx) (App), [`src/pages/ProductDetailPage.tsx`](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/ProductDetailPage.tsx) (Product Detail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_shell["App Shell"]
  node_n_main(("main.tsx<br/>entry<br/>[main.tsx]"))
  node_n_app["App<br/>router<br/>[App.tsx]"]
  node_n_provider["AuthProvider<br/>auth context<br/>[AuthProvider.tsx]"]
  node_n_gate{{"AuthGate<br/>auth guard<br/>[AuthGate.tsx]"}}
  node_n_routeguard{{"RouteGuard<br/>route guard<br/>[RouteGuard.tsx]"}}
  node_n_layout["AppLayout<br/>layout shell<br/>[AppLayout.tsx]"]
  node_n_header["AppHeader<br/>layout header<br/>[AppHeader.tsx]"]
  node_n_sidebar["AppSidebar<br/>nav shell<br/>[AppSidebar.tsx]"]
end

subgraph group_group_pages["Pages"]
  node_n_index["Index<br/>landing route<br/>[Index.tsx]"]
  node_n_dashboard["Dashboard<br/>overview page<br/>[DashboardPage.tsx]"]
  node_n_products["Products<br/>catalog page<br/>[ProductsPage.tsx]"]
  node_n_product_detail["Product Detail<br/>master-detail page"]
  node_n_licences["Licences<br/>domain page<br/>[LicencesPage.tsx]"]
  node_n_resources["Resources<br/>domain page<br/>[ResourcesPage.tsx]"]
  node_n_access["Access<br/>domain page<br/>[AccessPage.tsx]"]
  node_n_reports["Reports<br/>analytics page<br/>[ReportsPage.tsx]"]
  node_n_login["Login<br/>public page<br/>[LoginPage.tsx]"]
  node_n_tabs["Product Tabs<br/>detail tabs"]
end

subgraph group_group_ui["UI Layer"]
  node_n_widgets["Domain Widgets<br/>components"]
  node_n_primitives["UI Primitives<br/>design system"]
end

subgraph group_group_data["Data & Backend"]
  node_n_datahooks["useDataHooks<br/>data access<br/>[useDataHooks.ts]"]
  node_n_store["appStore<br/>global state<br/>[appStore.ts]"]
  node_n_data[("Domain Data<br/>seed data")]
  node_n_supabase[("Supabase<br/>backend boundary")]
end

node_n_main -->|"boots"| node_n_app
node_n_app -->|"wraps"| node_n_provider
node_n_app -->|"uses"| node_n_layout
node_n_app -->|"routes"| node_n_login
node_n_provider -->|"auth state"| node_n_gate
node_n_gate -->|"protects"| node_n_routeguard
node_n_routeguard -->|"permits"| node_n_layout
node_n_layout -->|"includes"| node_n_header
node_n_layout -->|"includes"| node_n_sidebar
node_n_sidebar -->|"navigates"| node_n_index
node_n_index -->|"lands on"| node_n_dashboard
node_n_layout -->|"hosts"| node_n_dashboard
node_n_layout -->|"hosts"| node_n_products
node_n_layout -->|"hosts"| node_n_product_detail
node_n_layout -->|"hosts"| node_n_licences
node_n_layout -->|"hosts"| node_n_resources
node_n_layout -->|"hosts"| node_n_access
node_n_layout -->|"hosts"| node_n_reports
node_n_product_detail -->|"decomposes"| node_n_tabs
node_n_dashboard -->|"renders"| node_n_widgets
node_n_products -->|"renders"| node_n_widgets
node_n_product_detail -->|"renders"| node_n_widgets
node_n_widgets -->|"built on"| node_n_primitives
node_n_dashboard -->|"loads"| node_n_datahooks
node_n_products -->|"loads"| node_n_datahooks
node_n_product_detail -->|"loads"| node_n_datahooks
node_n_datahooks -->|"reads"| node_n_data
node_n_datahooks -->|"coordinates"| node_n_store
node_n_datahooks -->|"syncs"| node_n_supabase
node_n_supabase -.->|"auth"| node_n_provider
node_n_supabase -.->|"persists"| node_n_data

click node_n_main "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/main.tsx"
click node_n_app "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/App.tsx"
click node_n_provider "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/providers/AuthProvider.tsx"
click node_n_gate "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/components/AuthGate.tsx"
click node_n_routeguard "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/components/RouteGuard.tsx"
click node_n_layout "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/components/AppLayout.tsx"
click node_n_header "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/components/AppHeader.tsx"
click node_n_sidebar "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/components/AppSidebar.tsx"
click node_n_index "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/Index.tsx"
click node_n_dashboard "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/DashboardPage.tsx"
click node_n_products "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/ProductsPage.tsx"
click node_n_product_detail "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/ProductDetailPage.tsx"
click node_n_licences "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/LicencesPage.tsx"
click node_n_resources "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/ResourcesPage.tsx"
click node_n_access "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/AccessPage.tsx"
click node_n_reports "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/ReportsPage.tsx"
click node_n_login "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/LoginPage.tsx"
click node_n_tabs "https://github.com/bricelgdb/bs-tech-cs-adminhub/tree/main/src/pages/tabs"
click node_n_widgets "https://github.com/bricelgdb/bs-tech-cs-adminhub/tree/main/src/components"
click node_n_primitives "https://github.com/bricelgdb/bs-tech-cs-adminhub/tree/main/src/components/ui"
click node_n_datahooks "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/hooks/useDataHooks.ts"
click node_n_store "https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/store/appStore.ts"
click node_n_data "https://github.com/bricelgdb/bs-tech-cs-adminhub/tree/main/src/data"
click node_n_supabase "https://github.com/bricelgdb/bs-tech-cs-adminhub/tree/main/src/integrations/supabase"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n_main,node_n_app,node_n_provider,node_n_gate,node_n_routeguard,node_n_layout,node_n_header,node_n_sidebar toneBlue
class node_n_index,node_n_dashboard,node_n_products,node_n_product_detail,node_n_licences,node_n_resources,node_n_access,node_n_reports,node_n_login,node_n_tabs toneAmber
class node_n_widgets,node_n_primitives toneMint
class node_n_datahooks,node_n_store,node_n_data,node_n_supabase toneRose
```

## Components

### App Shell

Browser SPA entry, routing, auth, and layout framing.

- [main.tsx](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/main.tsx): entry · Browser entry point that boots the React app. · `src/main.tsx`
- [App](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/App.tsx): router · Top-level app composition and route wiring. · `src/App.tsx`
- [AuthProvider](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/providers/AuthProvider.tsx): auth context · Provides authentication state to the app. · `src/providers/AuthProvider.tsx`
- [AuthGate](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/components/AuthGate.tsx): auth guard · Controls access to authenticated areas. · `src/components/AuthGate.tsx`
- [RouteGuard](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/components/RouteGuard.tsx): route guard · Protects routes and handles unauthenticated access. · `src/components/RouteGuard.tsx`
- [AppLayout](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/components/AppLayout.tsx): layout shell · Persistent application frame around routed content. · `src/components/AppLayout.tsx`
- [AppHeader](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/components/AppHeader.tsx): layout header · Top navigation and global actions. · `src/components/AppHeader.tsx`
- [AppSidebar](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/components/AppSidebar.tsx): nav shell · Primary navigation for the dashboard sections. · `src/components/AppSidebar.tsx`

### Pages

Top-level routes and product detail subviews.

- [Index](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/Index.tsx): landing route · Default landing route for the authenticated app. · `src/pages/Index.tsx`
- [Dashboard](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/DashboardPage.tsx): overview page · High-level dashboard and KPI entry page. · `src/pages/DashboardPage.tsx`
- [Products](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/ProductsPage.tsx): catalog page · Product listing and discovery surface. · `src/pages/ProductsPage.tsx`
- [Product Detail](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/ProductDetailPage.tsx): master-detail page · Tabbed workspace for a single product. · `src/pages/ProductDetailPage.tsx`
- [Licences](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/LicencesPage.tsx): domain page · Licence management and status view. · `src/pages/LicencesPage.tsx`
- [Resources](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/ResourcesPage.tsx): domain page · Resources, docs, and supporting materials. · `src/pages/ResourcesPage.tsx`
- [Access](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/AccessPage.tsx): domain page · User access and permissions surface. · `src/pages/AccessPage.tsx`
- [Reports](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/ReportsPage.tsx): analytics page · Reporting and activity insights surface. · `src/pages/ReportsPage.tsx`
- [Login](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/pages/LoginPage.tsx): public page · Unauthenticated sign-in route. · `src/pages/LoginPage.tsx`
- [Product Tabs](https://github.com/bricelgdb/bs-tech-cs-adminhub/tree/main/src/pages/tabs): detail tabs · Product-specific subviews for overview, access, audit, docs, integrations, licences, and usage. · `src/pages/tabs`

### UI Layer

Reusable domain widgets and design-system primitives.

- [Domain Widgets](https://github.com/bricelgdb/bs-tech-cs-adminhub/tree/main/src/components): components · App-specific reusable cards, tables, badges, and charts. · `src/components`
- [UI Primitives](https://github.com/bricelgdb/bs-tech-cs-adminhub/tree/main/src/components/ui): design system · Reusable low-level controls and layout primitives. · `src/components/ui`

### Data & Backend

Local domain data, global store, and Supabase integration.

- [useDataHooks](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/hooks/useDataHooks.ts): data access · Central hook layer for reading domain data. · `src/hooks/useDataHooks.ts`
- [appStore](https://github.com/bricelgdb/bs-tech-cs-adminhub/blob/main/src/store/appStore.ts): global state · Shared app-level state for selections, filters, or UI coordination. · `src/store/appStore.ts`
- [Domain Data](https://github.com/bricelgdb/bs-tech-cs-adminhub/tree/main/src/data): seed data · In-repo datasets for activity, licences, products, reports, and users. · `src/data`
- [Supabase](https://github.com/bricelgdb/bs-tech-cs-adminhub/tree/main/src/integrations/supabase): backend boundary · External auth and persistence boundary backed by typed client and migrations. · `src/integrations/supabase`

## Connections

- main.tsx → App: boots · Main entry mounts the app shell.
- App → AuthProvider: wraps · App composes the auth context around routes.
- App → AppLayout: uses · Authenticated content renders inside the layout shell.
- App → Login: routes · Public sign-in route is separated from the protected app.
- AuthProvider → AuthGate: auth state · Auth provider supplies session state to access gating.
- AuthGate → RouteGuard: protects · Route guard enforces route-level access control.
- RouteGuard → AppLayout: permits · Protected routes enter the main application frame.
- AppLayout → AppHeader: includes · Persistent header is part of the shell.
- AppLayout → AppSidebar: includes · Persistent sidebar provides section navigation.
- AppSidebar → Index: navigates · Primary nav reaches the landing route.
- Index → Dashboard: lands on · Default route resolves to the dashboard.
- AppLayout → Dashboard: hosts · Dashboard is rendered within the app shell.
- AppLayout → Products: hosts · Products page is rendered within the app shell.
- AppLayout → Product Detail: hosts · Product detail is rendered within the app shell.
- AppLayout → Licences: hosts · Licences page is rendered within the app shell.
- AppLayout → Resources: hosts · Resources page is rendered within the app shell.
- AppLayout → Access: hosts · Access page is rendered within the app shell.
- AppLayout → Reports: hosts · Reports page is rendered within the app shell.
- Product Detail → Product Tabs: decomposes · Tabbed subviews make up the product detail workspace.
- Dashboard → Domain Widgets: renders · Dashboard uses reusable domain widgets.
- Products → Domain Widgets: renders · Catalog views reuse shared widgets.
- Product Detail → Domain Widgets: renders · Detail tabs rely on reusable widgets.
- Domain Widgets → UI Primitives: built on · App widgets compose design-system primitives.
- Dashboard → useDataHooks: loads · Pages read domain data through centralized hooks.
- Products → useDataHooks: loads · Catalog pages read domain data through centralized hooks.
- Product Detail → useDataHooks: loads · Detail tabs read domain data through centralized hooks.
- useDataHooks → Domain Data: reads · Hooks consume local domain datasets as a source of truth or fallback.
- useDataHooks → appStore: coordinates · Hooks coordinate with shared app state.
- useDataHooks → Supabase: syncs · Hooks bridge the UI to typed Supabase data when persistence is needed.
- Supabase → AuthProvider: auth · Supabase underpins authentication state.
- Supabase → Domain Data: persists · Database-backed data maps to the app's domain models.
