# googie08/fablabs architecture

> Architecture diagram of the GitHub repository googie08/fablabs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/googie08/fablabs
- Repository: https://github.com/googie08/fablabs

## Overview

1. This repository’s main system is a Next.js App Router application at the repo root. It combines the frontend UI and backend API in one codebase, with server-side route handlers under `src/app/api` acting as the application backend.

2. The app is organized around multiple user personas and workspaces: public pages, user/student/service reservation flows, staff pages, cashier pages, and several admin dashboards. The route structure under `src/app/*` is the clearest diagram boundary for the presentation layer.

3. The public-facing UI includes the landing page, services, contact, sign-in, and sign-up flows. Shared layout and styling live in `src/app/layout.tsx`, `globals.css`, and the reusable component library under `src/components/ui`.

4. The core business workflows are reservation-centric. Users can create machine/service reservations, EVC reservations, and related schedules from pages like `user-services`, `student-schedule`, `msme-schedule`, and `survey/*`. These flows are implemented with form components in `src/components/student-forms` and `src/components/msme-forms`, plus calendar/reservation widgets in `src/components/custom` and `src/components/user`.

5. Administrative operations are split into separate dashboards and feature modules. The admin area includes review/approval, machine management, user management, staff tools, report generation, and history views. These are backed by components in `src/components/admin*` and pages in `src/app/admin-dashboard/*`.

6. The backend API is fairly granular and domain-driven. Route groups exist for account management, auth checks, admin approval/status updates, cashier payment queues, machine/tool/service CRUD, user profile updates, reservations, EVC reservations, blocked dates, surveys, teacher-email workflows, and uploads. In architecture terms, the frontend does not talk directly to the database; it calls these route handlers.

7. Persistence is handled through Prisma with a SQLite database (`prisma/schema.prisma` and `prisma/dev.db`). The schema models the business domain explicitly: accounts, client and business profile info, utilization requests, machine utilization logs, EVC reservations, survey results, and job/payment records. Most workflows are relational and centered on `AccInfo`, `UtilReq`, and `EVCReservation`.

8. The data model shows two major reservation tracks: external client utilization requests and EVC/lab reservations. Each track has its own sub-records, approval flags, satisfaction/evaluation records, and nested child entities such as times, process details, materials, students, and machine utilization breakdowns.

9. A notable operational boundary is notifications and document generation. Email-related route handlers under `src/app/api/admin-email` and `src/app/api/teacher-email` suggest outbound notifications for approvals, rejections, cancellations, and contact messages. Printable artifacts are generated from components under `src/components/admin-functions/pdf` and `src/components/admin-reports`, covering forms, machine utilization reports, dashboard reports, and payment/job documents.

10. Access control is enforced at the application layer. `src/middleware.ts`, auth-related API routes, and the role-guard component indicate that route access and UI visibility depend on user role rather than a separate backend gateway.

11. Static assets are part of the architecture because the app depends on many branded resources: fonts, logos, machine images, and slider assets live under `public/`. This matters because several pages and PDFs likely depend on those assets for presentation and generated documents.

12. There is also a separate `my-app` directory containing a standalone Create React App scaffold. It appears isolated from the main Next.js application and should be treated as a separate legacy/demo frontend unless intentionally wired in elsewhere. For an architecture diagram of the active system, the root Next.js app is the primary focus.

Main entry points: [`src/lib/prisma.ts`](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/lib/prisma.ts) (Prisma client), [`src/middleware.ts`](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/middleware.ts) (Route guard), [`src/components/admin/review-reservation.tsx`](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/admin/review-reservation.tsx) (Admin tools), [`src/components/msme-forms/utilization-info.tsx`](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/msme-forms/utilization-info.tsx) (MSME forms)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Next.js app"]
  node_node_app_shell["App shell<br/>[layout.tsx]"]
  node_node_public_home["Home<br/>public page<br/>[page.tsx]"]
  node_node_public_info["Public info<br/>public pages<br/>[page.tsx]"]
  node_node_public_auth["Auth entry<br/>auth routes<br/>[page.tsx]"]
  node_node_user_workflows["User flows<br/>reservation pages<br/>[page.tsx]"]
  node_node_msme_flow["MSME flow<br/>reservation page<br/>[page.tsx]"]
  node_node_survey_flow["Survey flow<br/>survey pages<br/>[page.tsx]"]
  node_node_admin_dash["Admin dashboard<br/>admin pages<br/>[page.tsx]"]
  node_node_user_dash["User dashboard<br/>account pages<br/>[page.tsx]"]
  node_node_staff_cashier["Ops dashboards<br/>staff/cashier pages<br/>[page.tsx]"]
  node_node_api_reservations["Reservation API<br/>api routes<br/>[route.ts]"]
  node_node_api_evc["EVC API<br/>api routes<br/>[route.ts]"]
  node_node_api_admin["Admin API<br/>api routes<br/>[route.ts]"]
  node_node_api_catalog["Catalog API<br/>api routes<br/>[route.ts]"]
  node_node_api_account["Account API<br/>api routes<br/>[route.ts]"]
  node_node_api_comms["Comms API<br/>api routes<br/>[route.ts]"]
end

subgraph group_components["UI components"]
  node_node_front_nav["Navbar<br/>shared layout<br/>[navbar.tsx]"]
  node_node_form_student["Student forms<br/>workflow components"]
  node_node_form_msme["MSME forms<br/>workflow components"]
  node_node_admin_tools["Admin tools<br/>admin components"]
  node_node_reports_pdf["Reports & PDF<br/>reporting components"]
  node_node_auth_ui["Role guard UI<br/>auth component<br/>[role-guard.tsx]"]
  node_node_user_profile["Profile UI<br/>user components"]
end

subgraph group_data["Data layer"]
  node_node_auth_boundary{{"Route guard<br/>middleware/auth<br/>[middleware.ts]"}}
  node_node_prisma["Prisma client<br/>db client<br/>[prisma.ts]"]
  node_node_schema[("Domain schema<br/>sqlite schema<br/>[schema.prisma]")]
end

subgraph group_legacy["Legacy app"]
  node_node_legacy_app["Legacy app<br/>CRA frontend<br/>[App.js]"]
end

node_node_public_home -->|"renders"| node_node_front_nav
node_node_public_info -->|"renders"| node_node_front_nav
node_node_user_workflows -->|"uses"| node_node_form_student
node_node_msme_flow -->|"uses"| node_node_form_msme
node_node_survey_flow -.->|"feeds"| node_node_user_workflows
node_node_admin_dash -->|"uses"| node_node_admin_tools
node_node_admin_dash -->|"uses"| node_node_reports_pdf
node_node_user_dash -->|"uses"| node_node_user_profile
node_node_staff_cashier -->|"uses"| node_node_admin_tools
node_node_form_student -->|"calls"| node_node_api_reservations
node_node_form_msme -->|"calls"| node_node_api_reservations
node_node_form_msme -->|"calls"| node_node_api_evc
node_node_admin_tools -->|"calls"| node_node_api_admin
node_node_admin_tools -->|"calls"| node_node_api_catalog
node_node_user_profile -->|"calls"| node_node_api_account
node_node_api_reservations -->|"persists"| node_node_prisma
node_node_api_evc -->|"persists"| node_node_prisma
node_node_api_admin -->|"persists"| node_node_prisma
node_node_api_catalog -->|"persists"| node_node_prisma
node_node_api_account -->|"persists"| node_node_prisma
node_node_api_comms -.->|"persists"| node_node_prisma
node_node_auth_boundary -->|"guards"| node_node_public_auth
node_node_auth_boundary -->|"guards"| node_node_admin_dash
node_node_auth_boundary -->|"guards"| node_node_staff_cashier
node_node_schema -->|"backed by"| node_node_prisma
node_node_legacy_app -.->|"isolated"| node_node_auth_boundary

click node_node_app_shell "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/layout.tsx"
click node_node_public_home "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/page.tsx"
click node_node_public_info "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/services/page.tsx"
click node_node_public_auth "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/sign-in/[[...sign-in]]/page.tsx"
click node_node_user_workflows "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/student-schedule/page.tsx"
click node_node_msme_flow "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/msme-schedule/page.tsx"
click node_node_survey_flow "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/survey/page.tsx"
click node_node_admin_dash "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/admin-dashboard/page.tsx"
click node_node_user_dash "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/user-dashboard/page.tsx"
click node_node_staff_cashier "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/staff-dashboard/page.tsx"
click node_node_api_reservations "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/api/user/create-reservation/route.ts"
click node_node_api_evc "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/api/user/create-evc-reservation/route.ts"
click node_node_api_admin "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/api/admin/reservation-review/[id]/route.ts"
click node_node_api_catalog "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/api/machines/route.ts"
click node_node_api_account "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/api/account/[userId]/route.ts"
click node_node_api_comms "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/api/admin-email/contact/route.ts"
click node_node_auth_boundary "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/middleware.ts"
click node_node_prisma "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/lib/prisma.ts"
click node_node_schema "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/prisma/schema.prisma"
click node_node_front_nav "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/custom/navbar.tsx"
click node_node_form_student "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/student-forms/lab-reservation.tsx"
click node_node_form_msme "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/msme-forms/utilization-info.tsx"
click node_node_admin_tools "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/admin/review-reservation.tsx"
click node_node_reports_pdf "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/admin-reports/report-generator-dialog.tsx"
click node_node_auth_ui "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/auth/role-guard.tsx"
click node_node_user_profile "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/user/personal-info-edit-modal.tsx"
click node_node_legacy_app "https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/my-app/src/App.js"

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_node_app_shell,node_node_public_home,node_node_public_info,node_node_public_auth,node_node_user_workflows,node_node_msme_flow,node_node_survey_flow,node_node_admin_dash,node_node_user_dash,node_node_staff_cashier,node_node_api_reservations,node_node_api_evc,node_node_api_admin,node_node_api_catalog,node_node_api_account,node_node_api_comms toneBlue
class node_node_front_nav,node_node_form_student,node_node_form_msme,node_node_admin_tools,node_node_reports_pdf,node_node_auth_ui,node_node_user_profile toneAmber
class node_node_auth_boundary,node_node_prisma,node_node_schema toneMint
class node_node_legacy_app toneRose
```

## Components

### Next.js app

Primary App Router frontend plus route handlers

- [App shell](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/layout.tsx): next app shell · Global layout and styling for the App Router application · `src/app/layout.tsx`
- [Home](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/page.tsx): public page · Landing page for the main application · `src/app/page.tsx`
- [Public info](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/services/page.tsx): public pages · Public-facing services and contact routes · `src/app/services/page.tsx`
- [Auth entry](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/sign-in/[[...sign-in]]/page.tsx): auth routes · Sign-in and sign-up entry points · `src/app/sign-in/[[...sign-in]]/page.tsx`
- [User flows](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/student-schedule/page.tsx): reservation pages · Student and client scheduling flows · `src/app/student-schedule/page.tsx`
- [MSME flow](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/msme-schedule/page.tsx): reservation page · Machine/service utilization workflow for MSME users · `src/app/msme-schedule/page.tsx`
- [Survey flow](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/survey/page.tsx): survey pages · Public and internal survey entry points · `src/app/survey/page.tsx`
- [Admin dashboard](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/admin-dashboard/page.tsx): admin pages · Main admin console and related dashboards · `src/app/admin-dashboard/page.tsx`
- [User dashboard](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/user-dashboard/page.tsx): account pages · User account and reservation history views · `src/app/user-dashboard/page.tsx`
- [Ops dashboards](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/staff-dashboard/page.tsx): staff/cashier pages · Staff and cashier operational consoles · `src/app/staff-dashboard/page.tsx`
- [Reservation API](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/api/user/create-reservation/route.ts): api routes · Create, fetch, review, and status-update reservation handlers · `src/app/api/user/create-reservation/route.ts`
- [EVC API](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/api/user/create-evc-reservation/route.ts): api routes · EVC reservation and status handlers · `src/app/api/user/create-evc-reservation/route.ts`
- [Admin API](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/api/admin/reservation-review/[id]/route.ts): api routes · Administrative approval, reporting, and management handlers · `src/app/api/admin/reservation-review/[id]/route.ts`
- [Catalog API](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/api/machines/route.ts): api routes · Machines, tools, and services CRUD handlers · `src/app/api/machines/route.ts`
- [Account API](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/api/account/[userId]/route.ts): api routes · Account, profile, and user-management handlers · `src/app/api/account/[userId]/route.ts`
- [Comms API](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/app/api/admin-email/contact/route.ts): api routes · Email and contact notification handlers · `src/app/api/admin-email/contact/route.ts`

### UI components

Reusable presentation and workflow components

- [Navbar](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/custom/navbar.tsx): shared layout · Top-level navigation shared across pages · `src/components/custom/navbar.tsx`
- [Student forms](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/student-forms/lab-reservation.tsx): workflow components · Student reservation forms and calendar widgets · `src/components/student-forms/lab-reservation.tsx`
- [MSME forms](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/msme-forms/utilization-info.tsx): workflow components · MSME utilization forms and selectors · `src/components/msme-forms/utilization-info.tsx`
- [Admin tools](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/admin/review-reservation.tsx): admin components · Admin review, machine, and role-management UI · `src/components/admin/review-reservation.tsx`
- [Reports & PDF](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/admin-reports/report-generator-dialog.tsx): reporting components · PDF generation and reporting utilities · `src/components/admin-reports/report-generator-dialog.tsx`
- [Role guard UI](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/auth/role-guard.tsx): auth component · Client-side role-based visibility control · `src/components/auth/role-guard.tsx`
- [Profile UI](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/components/user/personal-info-edit-modal.tsx): user components · Personal and business information editing widgets · `src/components/user/personal-info-edit-modal.tsx`

### Data layer

Prisma client and schema-backed persistence

- [Route guard](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/middleware.ts): middleware/auth · Application-layer access control and role checks · `src/middleware.ts`
- [Prisma client](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/src/lib/prisma.ts): db client · Shared database access helper · `src/lib/prisma.ts`
- [Domain schema](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/prisma/schema.prisma): sqlite schema · Prisma schema and SQLite persistence model · `prisma/schema.prisma`

### Legacy app

Standalone Create React App scaffold kept separate

- [Legacy app](https://github.com/googie08/fablabs/blob/MAINFROMDEFENSE/my-app/src/App.js): CRA frontend · Standalone Create React App scaffold separate from the Next.js system · `my-app/src/App.js`

## Connections

- Home → Navbar: renders · Landing page uses shared navigation
- Public info → Navbar: renders · Public pages share the app shell and nav
- User flows → Student forms: uses · Student scheduling pages are built from reservation forms
- MSME flow → MSME forms: uses · MSME scheduling pages are built from utilization forms
- Survey flow → User flows: feeds · Survey flows relate to reservation and evaluation journeys
- Admin dashboard → Admin tools: uses · Admin dashboard pages are composed from admin feature components
- Admin dashboard → Reports & PDF: uses · Admin reporting and exports rely on PDF/report components
- User dashboard → Profile UI: uses · Account pages expose profile editing and user history
- Ops dashboards → Admin tools: uses · Operational dashboards reuse admin-style controls
- Student forms → Reservation API: calls · Reservation forms submit to backend route handlers
- MSME forms → Reservation API: calls · MSME workflow ultimately writes reservation records
- MSME forms → EVC API: calls · MSME and lab flows can create EVC reservations
- Admin tools → Admin API: calls · Approval and management actions go through admin APIs
- Admin tools → Catalog API: calls · Machine and service management use catalog APIs
- Profile UI → Account API: calls · Profile editing and account actions use account APIs
- Reservation API → Prisma client: persists · Reservation handlers read and write through Prisma
- EVC API → Prisma client: persists · EVC handlers persist reservation state through Prisma
- Admin API → Prisma client: persists · Admin review and reporting handlers use the database
- Catalog API → Prisma client: persists · Catalog CRUD is backed by the shared database client
- Account API → Prisma client: persists · Account and user-management handlers update persisted profiles
- Comms API → Prisma client: persists · Notification workflows likely record or read domain records
- Route guard → Auth entry: guards · Route access depends on application-layer auth and roles
- Route guard → Admin dashboard: guards · Role checks restrict dashboard access
- Route guard → Ops dashboards: guards · Staff and cashier views are role-gated
- Domain schema → Prisma client: backed by · Prisma client is generated from the schema
- Legacy app → Route guard: isolated · Legacy CRA frontend is separate from the main Next.js runtime
