# yongsoo-cho/lims-demo architecture

> Architecture diagram of the GitHub repository yongsoo-cho/lims-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yongsoo-cho/lims-demo
- Repository: https://github.com/yongsoo-cho/lims-demo

## Overview

##### Main Components
- The overall Next.js Application layer (web pages, navigation, layout components like AuthLayout, Navbar, etc.).
- Dedicated pages such as the calendar, login, projects, and supplies pages.
- UI Components: Show a sub-layer for the UI elements (e.g., AuthForm, LabDayCard, Loading, and specialized project and supplies components).
- Authentication & User Context: Mark the AuthContext and hooks (useAuth, useAuthGuard) which handle user state and guarded routes.
- External Services & Backend: Note the integration with Supabase that provides:
- User authentication (via email + Slack OAuth).
- API / database interactions with PostgreSQL.
- File storage for uploads.
- Configuration & Utilities: Include configuration components like the Supabase client, environment variables, and utility functions from the utils directory.
- CSS & Global Styles: Note that TailwindCSS is in play, influencing the UI and theming.

##### Relationships and Interactions
- UI Flow: Illustrate the separation between various pages (login, dashboard, calendar, projects, supplies) and how navigation/layout components like Navbar propagate across them.
- Component Hierarchy: Emphasize that layout components wrap the pages and that modals (for new project creation, discard warnings, etc.) overlay the core application.
- Context and Hooks: Show how the AuthContext communicates with various components to guard routes and manage session states.

##### Architectural Patterns
- Next.js App Router and File-based Routing: Indicate that pages (.tsx files under src/app) correspond to routes which the Next.js router manages.
- Component-Based UI: The layered directory structure (components/ui, components/ui/projects, etc.) suggests a modular and reusable design.
- Third-Party Integration: Supabase plays a central role as the backend-as-a-service for authentication, database CRUD operations, and storage. The use of React Flow for the protocol builder and Headless UI for the UI elements should be highlighted.
- Separation of Concerns: Differentiate between view logic (React Components), data fetching (hooks, utility functions) and backend integration (config/supabaseClient).

##### Relevant Technologies
- Frontend Framework: Next.js 14
- Styling: TailwindCSS
- Backend Integration: Supabase (Authentication, PostgreSQL, Storage)
- Development Tools: ESLint, PostCSS, TypeScript (tsconfig.json)

- Components are clearly labelled.

## Diagram (Mermaid)

```mermaid
graph TD
    Browser["Browser"]:::client
    App["Next.js Application"]:::app
    External["Supabase Service"]:::external

    Browser -->|"requests"| App

    subgraph "Pages"
        Calendar["Calendar Page"]:::page
        Login["Login Page"]:::page
        Projects["Projects Page"]:::page
        Supplies["Supplies Page"]:::page
    end

    subgraph "Layout Components"
        AuthLayout["AuthLayout"]:::layout
        Navbar["Navbar"]:::layout
    end

    subgraph "UI Components"
        AuthForm["AuthForm"]:::ui
        LabDayCard["LabDayCard"]:::ui
        Loading["Loading"]:::ui
        OtherUI["Other UI Elements"]:::ui
    end

    subgraph "Projects Feature"
        ProjectFlow["ProjectFlow"]:::feature
        FlowParts["Flow Parts"]:::feature
        ProjectModals["Project Modals"]:::feature
    end

    subgraph "Supplies Feature"
        CsvUploader["CSV Uploader"]:::feature
        SuppliesTable["Supplies Table"]:::feature
        TablePreviewModal["Table Preview Modal"]:::feature
    end

    subgraph "Authentication & User Context"
        AuthContext["AuthContext"]:::auth
        AuthHooks["Auth Hooks"]:::auth
    end

    subgraph "Configuration & Utilities"
        SupabaseClient["Supabase Client"]:::config
        Utilities["Utilities"]:::config
        GlobalCSS["Global CSS"]:::config
    end

    %% Connect Next.js Application to core sub-components
    App --> Calendar
    App --> Login
    App --> Projects
    App --> Supplies
    App --> AuthLayout
    App --> Navbar
    App --> AuthForm
    App --> LabDayCard
    App --> Loading
    App --> OtherUI
    App --> ProjectFlow
    App --> CsvUploader
    App --> AuthContext
    App --> SupabaseClient

    %% Page specific renderings
    Login -->|"renders"| AuthForm
    Projects -->|"renders"| ProjectFlow
    Supplies -->|"renders"| CsvUploader

    %% Projects Feature internal flow
    ProjectFlow -->|"composes"| FlowParts
    ProjectFlow -->|"triggers"| ProjectModals

    %% Authentication flow
    AuthForm -->|"updates"| AuthContext
    AuthContext -->|"manages"| AuthHooks
    AuthContext -->|"calls"| SupabaseClient
    SupabaseClient -->|"connects"| External

    %% Additional flows (optional)
    Projects -->|"integrates"| ProjectFlow
    Supplies -->|"integrates"| SuppliesTable
    SuppliesTable -->|"opens"| TablePreviewModal

    %% Styles
    classDef client fill:#cde,stroke:#333,stroke-width:2px;
    classDef app fill:#bbf,stroke:#333,stroke-width:2px;
    classDef page fill:#ddf,stroke:#333,stroke-width:2px;
    classDef layout fill:#ffd,stroke:#333,stroke-width:2px;
    classDef ui fill:#efe,stroke:#333,stroke-width:2px;
    classDef feature fill:#fdd,stroke:#333,stroke-width:2px;
    classDef auth fill:#fde,stroke:#333,stroke-width:2px;
    classDef config fill:#cff,stroke:#333,stroke-width:2px;
    classDef external fill:#fcc,stroke:#333,stroke-width:2px;

    %% Click Events
    click App "https://github.com/yongsoo-cho/lims-demo/tree/main/src/app"
    click Calendar "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/calendar/page.tsx"
    click Login "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/login/page.tsx"
    click Projects "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/projects/page.tsx"
    click Supplies "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/supplies/page.tsx"
    click AuthLayout "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/components/layouts/AuthLayout.tsx"
    click Navbar "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/components/ui/Navbar.tsx"
    click AuthForm "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/components/ui/AuthForm.tsx"
    click LabDayCard "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/components/ui/LabDayCard.tsx"
    click Loading "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/components/ui/Loading.tsx"
    click OtherUI "https://github.com/yongsoo-cho/lims-demo/tree/main/src/app/components/ui/"
    click ProjectFlow "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/components/ui/projects/ProjectFlow.tsx"
    click FlowParts "https://github.com/yongsoo-cho/lims-demo/tree/main/src/app/components/ui/projects/flowparts/"
    click ProjectModals "https://github.com/yongsoo-cho/lims-demo/tree/main/src/app/components/ui/projects/modals/"
    click CsvUploader "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/components/ui/supplies/CsvUploader.tsx"
    click SuppliesTable "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/components/ui/supplies/SuppliesTable.tsx"
    click TablePreviewModal "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/components/ui/supplies/TablePreviewModal.tsx"
    click AuthContext "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/context/AuthContext.tsx"
    click AuthHooks "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/hooks/useAuth.ts"
    click SupabaseClient "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/config/supabaseClient.ts"
    click Utilities "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/utils/tableUtils.ts"
    click GlobalCSS "https://github.com/yongsoo-cho/lims-demo/blob/main/src/app/globals.css"
```
