# harshau007/attendify-web architecture

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

- Interactive diagram: https://gitdiagram.com/harshau007/attendify-web
- Repository: https://github.com/harshau007/attendify-web

## Overview

##### And Represent the Main Components
- Next.js Application Core – Represent the entire Next.js app as a central block, since it handles routing, server-side processing, and client-side rendering.
- Pages & Routes – Highlight the pages directory under “src/app”. For example, the primary page (app/page.tsx), the login page (app/login/page.tsx), and records page (app/records/page.tsx) as separate components.
- API Endpoints – Identify the API routes under “src/app/api”:
- Authentication: endpoints such as login (api/auth/login/route.ts) and logout (api/auth/logout/route.ts).
- Other APIs such as headcount (api/headcount/route.ts) and init-db (api/init-db/route.ts).
- UI Components – Include a block for “src/components” which houses reusable components (e.g., date-range-picker, file-upload, headcount-form, logout-button) and the UI elements (components/ui/*). These components build the reusable parts of the UI.
- Shared Libraries & Utilities – Represent the “src/lib” directory (with db.ts, gemini.ts, utils.ts) that likely encapsulate the business logic, database abstraction, or utility functions.
- Types – Include a note for “src/types”, showing that the project is TypeScript-based and type safety is maintained across components.
- Middleware – Since there is a “src/middleware.ts”, include this to denote that the project may handle cross-cutting concerns such as authentication or logging at the request level.

##### Relationships and Interactions
- UI & Component Reusability – Highlight how the “components” directory elements are included in multiple pages. You may show them as sub-components within the UI layer.

##### Architectural Patterns and Technologies
- Serverless/API Route Paradigm – Emphasize that API endpoints are implemented as serverless functions inside the Next.js project.
- Configuration & Build – Note the existence of configuration files (next.config.ts, tsconfig.json, eslint.config.mjs, postcss.config.mjs) to show that the project is set up with modern development tools.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    User["User"]:::user

    %% Client Layer
    subgraph "Client Layer"
        A["Next.js Application Core"]:::client

        subgraph "Pages & Routes"
            P1["Main Page (src/app/page.tsx)"]:::client
            P2["Login Page (src/app/login/page.tsx)"]:::client
            P3["Records Page (src/app/records/page.tsx)"]:::client
        end

        subgraph "UI Components"
            subgraph "Reusable Components"
                C1["Date Range Picker"]:::client
                C2["File Upload"]:::client
                C3["Headcount Form"]:::client
                C4["Logout Button"]:::client
                C5["Theme Provider"]:::client
            end
            subgraph "UI Library Components"
                U1["Alert UI"]:::client
                U2["Button UI"]:::client
                U3["Calendar UI"]:::client
                U4["Card UI"]:::client
                U5["Form UI"]:::client
                U6["Input UI"]:::client
                U7["Label UI"]:::client
                U8["Pagination UI"]:::client
                U9["Popover UI"]:::client
                U10["Table UI"]:::client
            end
        end
    end

    %% API/Server Layer
    subgraph "API/Server Layer"
        M["Middleware (src/middleware.ts)"]:::api
        subgraph "API Endpoints"
            AL["Auth Login API (api/auth/login)"]:::api
            ALout["Auth Logout API (api/auth/logout)"]:::api
            HC["Headcount API (api/headcount)"]:::api
            IDB["Init-DB API (api/init-db)"]:::api
        end
    end

    %% Service/Utility Layer
    subgraph "Service/Utility Layer"
        L["Shared Libraries (src/lib)"]:::utility
        T["Types (src/types/index.ts)"]:::utility
    end

    %% Relationships
    User -->|"accesses"| A
    A -->|"renders"| P1
    A -->|"renders"| P2
    A -->|"renders"| P3

    P1 -->|"calls"| M
    P2 -->|"calls"| M
    P3 -->|"calls"| M

    M -->|"routesTo"| AL
    M -->|"routesTo"| ALout
    M -->|"routesTo"| HC
    M -->|"routesTo"| IDB

    AL -->|"logic"| L
    ALout -->|"logic"| L
    HC -->|"logic"| L
    IDB -->|"logic"| L

    AL ---|"types"| T
    ALout ---|"types"| T
    HC ---|"types"| T
    IDB ---|"types"| T

    %% UI Components Usage in Pages
    P1 ---|"includes"| C1
    P1 ---|"includes"| U1
    P2 ---|"includes"| C4
    P3 ---|"includes"| C3

    %% Click Events
    click A "https://github.com/harshau007/attendify-web/tree/main/src/app"
    click P1 "https://github.com/harshau007/attendify-web/blob/main/src/app/page.tsx"
    click P2 "https://github.com/harshau007/attendify-web/blob/main/src/app/login/page.tsx"
    click P3 "https://github.com/harshau007/attendify-web/blob/main/src/app/records/page.tsx"
    click AL "https://github.com/harshau007/attendify-web/blob/main/src/app/api/auth/login/route.ts"
    click ALout "https://github.com/harshau007/attendify-web/blob/main/src/app/api/auth/logout/route.ts"
    click HC "https://github.com/harshau007/attendify-web/blob/main/src/app/api/headcount/route.ts"
    click IDB "https://github.com/harshau007/attendify-web/blob/main/src/app/api/init-db/route.ts"
    click C1 "https://github.com/harshau007/attendify-web/blob/main/src/components/date-range-picker.tsx"
    click C2 "https://github.com/harshau007/attendify-web/blob/main/src/components/file-upload.tsx"
    click C3 "https://github.com/harshau007/attendify-web/blob/main/src/components/headcount-form.tsx"
    click C4 "https://github.com/harshau007/attendify-web/blob/main/src/components/logout-button.tsx"
    click C5 "https://github.com/harshau007/attendify-web/blob/main/src/components/theme-provider.tsx"
    click U1 "https://github.com/harshau007/attendify-web/blob/main/src/components/ui/alert.tsx"
    click U2 "https://github.com/harshau007/attendify-web/blob/main/src/components/ui/button.tsx"
    click U3 "https://github.com/harshau007/attendify-web/blob/main/src/components/ui/calendar.tsx"
    click U4 "https://github.com/harshau007/attendify-web/blob/main/src/components/ui/card.tsx"
    click U5 "https://github.com/harshau007/attendify-web/blob/main/src/components/ui/form.tsx"
    click U6 "https://github.com/harshau007/attendify-web/blob/main/src/components/ui/input.tsx"
    click U7 "https://github.com/harshau007/attendify-web/blob/main/src/components/ui/label.tsx"
    click U8 "https://github.com/harshau007/attendify-web/blob/main/src/components/ui/pagination.tsx"
    click U9 "https://github.com/harshau007/attendify-web/blob/main/src/components/ui/popover.tsx"
    click U10 "https://github.com/harshau007/attendify-web/blob/main/src/components/ui/table.tsx"
    click L "https://github.com/harshau007/attendify-web/tree/main/src/lib"
    click T "https://github.com/harshau007/attendify-web/blob/main/src/types/index.ts"
    click M "https://github.com/harshau007/attendify-web/blob/main/src/middleware.ts"

    %% Style Definitions
    classDef user fill:#d9d9d9,stroke:#333,stroke-width:2px;
    classDef client fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef api fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef utility fill:#ffe4b5,stroke:#333,stroke-width:2px;
```
