# prathameshp107/clinlabops architecture

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

- Interactive diagram: https://gitdiagram.com/prathameshp107/clinlabops
- Repository: https://github.com/prathameshp107/clinlabops

## Overview

##### Project Type and Purpose
- This is a full-stack admin dashboard built with Next.js (App Router), React, Tailwind CSS and ShadCN UI.
- Its goal is to provide a unified interface for laboratory task management, customer enquiries, project management, experiment tracking, inventory control, user/role management and authentication.

##### File Structure & Architectural Patterns
- Top-level “src/app” directory holds all route handlers and layouts – a feature-based folder structure (admin-dashboard, enquiries, tasks, projects, experiments, inventory, user-management, auth flows).
- “src/components” is organized by domain (dashboard, task-management, project-management, experiment-management, inventory-management, user-management, auth, ui primitives).
- Utility, hook, data and store modules under “src/lib”, “src/hooks”, “src/data”, “src/store” implement shared logic, mock data, global state (Zustand, Context), API helpers (Axios/React-Query), and validation (Zod).
- No in-repo API routes are visible – the frontend likely consumes external REST/GraphQL microservices or serverless functions (e.g., Auth via NextAuth.js).

##### Main Components
a. Client Layer
- Web Browser / Mobile Browser
- Next.js App (App-Router/Server Components + Client Components)
b. Presentation Layer
- UI Library: ShadCN UI + Tailwind CSS
- Layouts & Pages (src/app/layout.js, page.js, nested route layouts)
- Reusable UI Components (src/components/ui, dashboard, feature-specific)
c. State & Data Layer
- React Context & Zustand for client state
- React Query + Axios for data fetching
- Form handling: React Hook Form + Zod
d. Authentication & Authorization
- NextAuth.js (JWT, OAuth providers: GitHub, Google)
- Two-Factor flow (2FA form component)
- Role-Based Access Control (Admin, Scientist, Technician, Reviewer)
e. API & Backend Services
- External LabTasker API (microservices for tasks, projects, enquiries, experiments, inventory, users)
- Database(s): e.g. PostgreSQL or MongoDB (data persistence)
- File Storage / CDN (lab reports, document uploads)
- Email Service (SMTP or third-party for notifications)
- Analytics / Logging Service (system logs, usage metrics)
f. Third-Party Integrations
- Charts: Recharts
- Animations: Framer Motion, Lottie (Aceternity UI)
- Date handling: date-fns
- PDF generation: react-pdf
- Internationalization: next-intl
- CI/CD: GitHub Actions (nextjs.yml)

##### Relationships & Data Flows
- User → Browser → Next.js SSR/CSR → React Components
- Components dispatch fetches via React Query/Axios → External API
- API ↔ Database (CRUD for tasks, enquiries, etc.)
- NextAuth.js ↔ OAuth Providers / Identity store
- File Uploads → Cloud Storage → Asset URLs served via CDN
- Notification events → Email Service (SMTP/SendGrid)
- Analytics events → Logging Service

##### Architectural Patterns & Design Principles
- Feature-based modular structure for clarity and scalability
- Separation of concerns: UI, state management, data access, auth
- Hybrid SSR/CSR using Next.js App Router and Server Components
- Component reusability: atomic UI primitives in src/components/ui
- Unidirectional data flow: React Query for server state, Zustand/Context for client state
- API-first approach: frontend decoupled from backend via REST/GraphQL

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["Web/Mobile Browser"]:::external
        NextApp["Next.js App\n(App Router)"]:::presentation
    end

    Browser -->|"requests"| NextApp

    %% Presentation Layer
    subgraph "Presentation Layer"
        UIlib["ShadCN UI + Tailwind CSS"]:::presentation
        subgraph "Layouts & Pages"
            RootLayout["Root Layout"]:::presentation
            click RootLayout "https://github.com/prathameshp107/clinlabops/blob/master/src/app/layout.js"
            AdminPage["Admin Dashboard Page"]:::presentation
            click AdminPage "https://github.com/prathameshp107/clinlabops/blob/master/src/app/admin-dashboard/page.js"
            subgraph EnquiriesPages
                EnqList["Enquiries List"]:::presentation
                click EnqList "https://github.com/prathameshp107/clinlabops/blob/master/src/app/enquiries/page.jsx"
                NewEnquiry["New Enquiry"]:::presentation
                click NewEnquiry "https://github.com/prathameshp107/clinlabops/blob/master/src/app/enquiries/new/page.jsx"
                EnqDetail["Enquiry Detail"]:::presentation
                click EnqDetail "https://github.com/prathameshp107/clinlabops/blob/master/src/app/enquiries/[id]/page.jsx"
                EnqEdit["Enquiry Edit"]:::presentation
                click EnqEdit "https://github.com/prathameshp107/clinlabops/blob/master/src/app/enquiries/[id]/edit/page.jsx"
                EnqUpload["Enquiry Upload"]:::presentation
                click EnqUpload "https://github.com/prathameshp107/clinlabops/blob/master/src/app/enquiries/[id]/upload/page.jsx"
            end
            subgraph TasksPages
                TaskList["Tasks List"]:::presentation
                click TaskList "https://github.com/prathameshp107/clinlabops/blob/master/src/app/tasks/page.jsx"
                TaskDetail["Task Detail"]:::presentation
                click TaskDetail "https://github.com/prathameshp107/clinlabops/blob/master/src/app/tasks/[id]/page.jsx"
                TaskLayout["Task Layout"]:::presentation
                click TaskLayout "https://github.com/prathameshp107/clinlabops/blob/master/src/app/tasks/[id]/layout.jsx"
                TaskLoading["Task Loading"]:::presentation
                click TaskLoading "https://github.com/prathameshp107/clinlabops/blob/master/src/app/tasks/[id]/loading.jsx"
                TaskNotFound["Task Not-Found"]:::presentation
                click TaskNotFound "https://github.com/prathameshp107/clinlabops/blob/master/src/app/tasks/[id]/not-found.jsx"
            end
            subgraph ProjectsPages
                ProjectList["Projects List"]:::presentation
                click ProjectList "https://github.com/prathameshp107/clinlabops/blob/master/src/app/projects/page.jsx"
                ProjectDetail["Project Detail"]:::presentation
                click ProjectDetail "https://github.com/prathameshp107/clinlabops/blob/master/src/app/projects/[id]/page.jsx"
                ProjectLayout["Project Layout"]:::presentation
                click ProjectLayout "https://github.com/prathameshp107/clinlabops/blob/master/src/app/projects/[id]/layout.jsx"
                ProjectEdit["Project Edit"]:::presentation
                click ProjectEdit "https://github.com/prathameshp107/clinlabops/blob/master/src/app/projects/edit/[id]/page.jsx"
                ProjectEditLayout["Project Edit Layout"]:::presentation
                click ProjectEditLayout "https://github.com/prathameshp107/clinlabops/blob/master/src/app/projects/edit/[id]/layout.jsx"
            end
            Experiments["Experiments Page"]:::presentation
            click Experiments "https://github.com/prathameshp107/clinlabops/blob/master/src/app/experiments/page.jsx"
            Inventory["Inventory Page"]:::presentation
            click Inventory "https://github.com/prathameshp107/clinlabops/blob/master/src/app/inventory/page.jsx"
            UserMgmt["User Management Page"]:::presentation
            click UserMgmt "https://github.com/prathameshp107/clinlabops/blob/master/src/app/user-management/page.jsx"
            subgraph AuthPages
                Login["Login Page"]:::presentation
                click Login "https://github.com/prathameshp107/clinlabops/blob/master/src/app/login/page.js"
                Register["Register Page"]:::presentation
                click Register "https://github.com/prathameshp107/clinlabops/blob/master/src/app/register/page.jsx"
                ForgotPwd["Forgot Password"]:::presentation
                click ForgotPwd "https://github.com/prathameshp107/clinlabops/blob/master/src/app/forgot-password/page.jsx"
            end
        end
        subgraph "Reusable UI Components"
            UIprimitives["UI Primitives Library"]:::presentation
            click UIprimitives "https://github.com/prathameshp107/clinlabops/tree/master/src/components/ui"
            DashboardComp["Dashboard Components"]:::presentation
            click DashboardComp "https://github.com/prathameshp107/clinlabops/tree/master/src/components/dashboard/"
            EnqSidebar["Enquiries Sidebar"]:::presentation
            click EnqSidebar "https://github.com/prathameshp107/clinlabops/blob/master/src/components/enquiries/enquiries-sidebar.jsx"
            ProjectsComp["Projects Components"]:::presentation
            click ProjectsComp "https://github.com/prathameshp107/clinlabops/tree/master/src/components/projects/"
            TasksComp["Tasks Components"]:::presentation
            click TasksComp "https://github.com/prathameshp107/clinlabops/tree/master/src/components/tasks/"
        end
    end

    NextApp --> UIlib
    NextApp --> RootLayout
    NextApp --> UIprimitives

    %% State & Data Layer
    subgraph "State & Data Layer"
        Zustand["Zustand / Context"]:::state
        ReactQuery["React Query + Axios"]:::state
        FormValidation["React Hook Form + Zod"]:::state
        Hooks["Shared Hooks"]:::state
        click Hooks "https://github.com/prathameshp107/clinlabops/blob/master/src/hooks/use-media-query.js"
        Utils["Utilities"]:::state
        click Utils "https://github.com/prathameshp107/clinlabops/blob/master/src/lib/utils.js"
        click Utils "https://github.com/prathameshp107/clinlabops/blob/master/src/lib/mock-data.js"
        click Utils "https://github.com/prathameshp107/clinlabops/blob/master/src/lib/mock-inventory-data.js"
        Data["Mock & Static Data"]:::state
        click Data "https://github.com/prathameshp107/clinlabops/tree/master/src/data/"
        StaticHelper["Static Params Helper"]:::state
        click StaticHelper "https://github.com/prathameshp107/clinlabops/blob/master/src/utils/staticParamsHelper.js"
    end

    UIlib --> Zustand
    UIlib --> ReactQuery
    UIlib --> FormValidation
    UIlib --> Hooks
    ReactQuery --> Utils
    ReactQuery --> Data

    %% Auth & Authorization
    subgraph "Authentication & Authorization"
        NextAuth["NextAuth.js\n(JWT, OAuth)"]:::external
        TwoFA["2FA Flow Component"]:::external
        RBAC["Role-Based Access Control"]:::external
    end

    NextApp --> NextAuth
    NextAuth -->|"OAuth"| TwoFA
    NextApp --> RBAC

    %% API & Backend Services
    subgraph "Backend Services"
        API["LabTasker API"]:::backend
        DB["Database\n(PostgreSQL/MongoDB)"]:::backend
        Storage["File Storage / CDN"]:::backend
        EmailSvc["Email Service\n(SMTP/SendGrid)"]:::external
        Logging["Analytics/Logging"]:::external
    end

    ReactQuery --> API
    API --> DB
    API --> Storage
    API --> EmailSvc
    API --> Logging

    %% Third-Party Integrations
    subgraph "Third-Party Integrations"
        OAuthProv["GitHub / Google"]:::external
        Charts["Recharts"]:::external
        Animations["Framer Motion / Lottie"]:::external
        DateLib["date-fns"]:::external
        PDFGen["react-pdf"]:::external
        i18n["next-intl"]:::external
    end

    NextAuth --> OAuthProv
    UIlib --> Charts
    UIlib --> Animations
    UIlib --> DateLib
    UIlib --> PDFGen
    UIlib --> i18n

    %% CI/CD Pipeline
    CI["GitHub Actions\n(.github/workflows/nextjs.yml)"]:::external
    click CI "https://github.com/prathameshp107/clinlabops/blob/master/.github/workflows/nextjs.yml"
    NextApp --> CI
    CI -->|"deploy to"| Storage

    %% Styles & Config
    Config["Tailwind Config\ntailwind.config.js"]:::state
    Styles["Global Stylesheet\nglobals.css"]:::state
    click Styles "https://github.com/prathameshp107/clinlabops/blob/master/src/app/globals.css"
    NextApp --> Config
    NextApp --> Styles

    %% Class Definitions
    classDef presentation fill:#D0E8FF,stroke:#0288D1,color:#000;
    classDef state fill:#E6F4EA,stroke:#388E3C,color:#000;
    classDef backend fill:#FFE0B2,stroke:#F57C00,color:#000;
    classDef external fill:#E1BEE7,stroke:#8E24AA,color:#000;
```
