# otonar/adviser-shift-app-public architecture

> Architecture diagram of the GitHub repository otonar/adviser-shift-app-public, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/otonar/adviser-shift-app-public
- Repository: https://github.com/otonar/adviser-shift-app-public

## Overview

This is a staff shift-management PWA for a university co-op team. Staff submit availability for targeted shift slots, then administrators create slots, auto-assign roles, adjust assignments, and publish confirmed roles for sharing. The product also covers products and inventory, member settings, surveys, suggestions, and LINE notifications. The graph distinguishes UI, route handlers, domain helpers, and Supabase state. Edges are limited to README-described capabilities and relationships visible in sampled source or the source index; unsampled UI-to-API wiring is left unverified.

Main entry points: [`src/app/admin`](https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/admin) (Admin console), [`src/lib/supabase.ts`](https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/supabase.ts) (Supabase database), [`src/app/dashboard`](https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/dashboard) (Staff dashboard), [`src/app/api/assignments`](https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/assignments) (Assignment APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_people["People and UI"]
  node_staff_ui["Staff dashboard"]
  node_admin_ui["Admin console"]
end

subgraph group_shifts["Shift operations"]
  node_shift_entry["Shift submission<br/>[StaffShifts.tsx]"]
  node_shift_routes["Shift APIs"]
  node_assignment_routes["Assignment APIs"]
  node_role_engine["Role assignment<br/>[role-assignment.ts]"]
  node_shift_changes["Assignment changes"]
  node_absence_logic["Absence handling<br/>[absence.ts]"]
end

subgraph group_features["Staff features"]
  node_products["Products and stock"]
  node_members["Member management"]
  node_surveys["Surveys and analytics"]
  node_suggestions["Suggestions"]
  node_notifications["LINE notifications<br/>[route.ts]"]
  node_line_webhook["LINE webhook<br/>[route.ts]"]
end

subgraph group_platform["Server platform"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_route_auth["Route authorization<br/>[middleware.ts]"]
  node_staff_queries["Staff queries<br/>[staff-queries.ts]"]
  node_database[("Supabase database<br/>[supabase.ts]")]
end

node_staff(("Staff"))
node_admins(("Administrators"))
node_line_service["LINE Messaging API"]

node_staff -->|"uses"| node_staff_ui
node_admins -->|"uses"| node_admin_ui
node_staff_ui -->|"submits availability"| node_shift_entry
node_admin_ui -.->|"manages slots"| node_shift_routes
node_admin_ui -.->|"manages assignments"| node_assignment_routes
node_assignment_routes -->|"computes roles"| node_role_engine
node_assignment_routes -->|"reads and saves"| node_database
node_assignment_routes -->|"records changes"| node_shift_changes
node_shift_routes -->|"checks absence window"| node_absence_logic
node_shift_routes -->|"reads and writes"| node_database
node_shift_entry -->|"uses"| node_absence_logic
node_staff_ui -.->|"browses products"| node_products
node_admin_ui -->|"manages inventory"| node_products
node_admin_ui -->|"manages members"| node_members
node_staff_ui -.->|"views and answers"| node_surveys
node_admin_ui -.->|"manages surveys"| node_surveys
node_staff_ui -.->|"posts suggestions"| node_suggestions
node_admin_ui -.->|"manages suggestions"| node_suggestions
node_admin_ui -->|"sends notifications"| node_notifications
node_notifications -->|"sends messages"| node_line_service
node_line_webhook -.->|"receives events"| node_line_service
node_shift_routes -->|"authenticates requests"| node_route_auth
node_assignment_routes -->|"authenticates requests"| node_route_auth
node_route_auth -->|"verifies tokens"| node_auth
node_staff_queries -->|"queries staff data"| node_database
node_staff_queries -.->|"provides dashboard data"| node_staff_ui
node_surveys -->|"reads and writes"| node_database
node_products -->|"reads and writes"| node_database
node_suggestions -->|"reads and writes"| node_database
node_notifications -.->|"records logs"| node_database

click node_staff_ui "https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/dashboard"
click node_admin_ui "https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/admin"
click node_shift_entry "https://github.com/otonar/adviser-shift-app-public/blob/main/src/components/dashboard/StaffShifts.tsx"
click node_shift_routes "https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/shifts"
click node_assignment_routes "https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/assignments"
click node_role_engine "https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/role-assignment.ts"
click node_shift_changes "https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/assignment-change.ts"
click node_absence_logic "https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/absence.ts"
click node_products "https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/products"
click node_members "https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/users"
click node_surveys "https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/surveys"
click node_suggestions "https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/suggestions"
click node_notifications "https://github.com/otonar/adviser-shift-app-public/blob/main/src/app/api/notifications/route.ts"
click node_line_webhook "https://github.com/otonar/adviser-shift-app-public/blob/main/src/app/api/line/webhook/route.ts"
click node_auth "https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/auth.ts"
click node_route_auth "https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/middleware.ts"
click node_staff_queries "https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/staff-queries.ts"
click node_database "https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/supabase.ts"

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_staff_ui,node_admin_ui toneBlue
class node_shift_entry,node_shift_routes,node_assignment_routes,node_role_engine,node_shift_changes,node_absence_logic toneAmber
class node_products,node_members,node_surveys,node_suggestions,node_notifications,node_line_webhook,node_line_service toneMint
class node_auth,node_route_auth,node_staff_queries,node_database toneRose
class node_staff,node_admins toneIndigo
```

## Components

### People and UI

- [Staff dashboard](https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/dashboard): `src/app/dashboard`
- [Admin console](https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/admin): `src/app/admin`

### Shift operations

- [Shift submission](https://github.com/otonar/adviser-shift-app-public/blob/main/src/components/dashboard/StaffShifts.tsx): `src/components/dashboard/StaffShifts.tsx`
- [Shift APIs](https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/shifts): `src/app/api/shifts`
- [Assignment APIs](https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/assignments): `src/app/api/assignments`
- [Role assignment](https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/role-assignment.ts): `src/lib/role-assignment.ts`
- [Assignment changes](https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/assignment-change.ts): `src/lib/assignment-change.ts`
- [Absence handling](https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/absence.ts): `src/lib/absence.ts`

### Staff features

- [Products and stock](https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/products): `src/app/api/products`
- [Member management](https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/users): `src/app/api/users`
- [Surveys and analytics](https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/surveys): `src/app/api/surveys`
- [Suggestions](https://github.com/otonar/adviser-shift-app-public/tree/main/src/app/api/suggestions): `src/app/api/suggestions`
- [LINE notifications](https://github.com/otonar/adviser-shift-app-public/blob/main/src/app/api/notifications/route.ts): `src/app/api/notifications/route.ts`
- [LINE webhook](https://github.com/otonar/adviser-shift-app-public/blob/main/src/app/api/line/webhook/route.ts): `src/app/api/line/webhook/route.ts`

### Server platform

- [Authentication](https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Route authorization](https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/middleware.ts): `src/lib/middleware.ts`
- [Staff queries](https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/staff-queries.ts): `src/lib/staff-queries.ts`
- [Supabase database](https://github.com/otonar/adviser-shift-app-public/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`

### Other components

- **Staff**
- **Administrators**
- **LINE Messaging API**

## Connections

- Staff → Staff dashboard: uses
- Administrators → Admin console: uses
- Staff dashboard → Shift submission: submits availability
- Admin console → Shift APIs: manages slots
- Admin console → Assignment APIs: manages assignments
- Assignment APIs → Role assignment: computes roles (evidence: `src/app/api/assignments/route.ts`)
- Assignment APIs → Supabase database: reads and saves (evidence: `src/app/api/assignments/route.ts`)
- Assignment APIs → Assignment changes: records changes (evidence: `src/app/api/assignments/[shiftId]/swap/route.ts`)
- Shift APIs → Absence handling: checks absence window (evidence: `src/app/api/shifts/route.ts`)
- Shift APIs → Supabase database: reads and writes (evidence: `src/app/api/shifts/route.ts`)
- Shift submission → Absence handling: uses (evidence: `src/components/dashboard/StaffShifts.tsx`)
- Staff dashboard → Products and stock: browses products
- Admin console → Products and stock: manages inventory
- Admin console → Member management: manages members
- Staff dashboard → Surveys and analytics: views and answers
- Admin console → Surveys and analytics: manages surveys
- Staff dashboard → Suggestions: posts suggestions
- Admin console → Suggestions: manages suggestions
- Admin console → LINE notifications: sends notifications
- LINE notifications → LINE Messaging API: sends messages
- LINE webhook → LINE Messaging API: receives events
- Shift APIs → Route authorization: authenticates requests (evidence: `src/app/api/shifts/route.ts`)
- Assignment APIs → Route authorization: authenticates requests (evidence: `src/app/api/assignments/route.ts`)
- Route authorization → Authentication: verifies tokens (evidence: `src/lib/middleware.ts`)
- Staff queries → Supabase database: queries staff data (evidence: `src/lib/staff-queries.ts`)
- Staff queries → Staff dashboard: provides dashboard data
- Surveys and analytics → Supabase database: reads and writes (evidence: `src/app/api/surveys/[id]/route.ts`)
- Products and stock → Supabase database: reads and writes (evidence: `src/app/api/products/route.ts`)
- Suggestions → Supabase database: reads and writes (evidence: `src/app/api/suggestions/route.ts`)
- LINE notifications → Supabase database: records logs (evidence: `src/app/api/notifications/route.ts`)
