# victorvinh04/shadcn-admin architecture

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

- Interactive diagram: https://gitdiagram.com/victorvinh04/shadcn-admin
- Repository: https://github.com/victorvinh04/shadcn-admin

## Overview

##### Main Components
a. UI & Presentation Layer:
- Layout Components: Represent the overall page structure (e.g., app-sidebar, header, top-nav, main content, and side navigations).
- UI Components: Capture the reusable visual components provided under src/components/ui (buttons, alerts, dialogs, modals, tables, etc.).
- Custom Components: Highlight components like password-input, command-menu, profile-dropdown, and theme-switch.
b. Feature Modules:
- Authentication: Include sub-modules like sign-in, sign-up, OTP, and forgot-password located under src/features/auth.
- Dashboard & Analytics: Shown under src/features/dashboard, representing components like overview and recent-sales.
- Communication & Interaction: Modules like Chats (src/features/chats) and Tasks (src/features/tasks) that contain dedicated UI and logic.
- User Management: Under src/features/users for user tables, dialogs, invites, and deletion functionalities.
- Settings: All settings-related features for account, appearance, display, notifications, and profile that reside in src/features/settings.
c. Routing & Navigation:
- Router Setup: Based on TanStack Router as declared in the README, the src/routes directory structure serves as the backbone for page routing and authentication versus error pages.
- Route Groups: Different folders for authenticated routes, auth pages, and error pages indicate a segregated routing strategy.
d. State & Context Providers:
- Contexts for theme, fonts, and search (in src/context) providing global state management.
- Stores, e.g. authStore in src/stores, provide the state layer to support authentication and UI state.
e. Utilities & Configuration:
- Build Tool: Vite (vite.config.ts) drives the build and development process.
- TypeScript Configurations: Multiple tsconfig files to maintain type safety.
- Linting and Formatting: Eslint (eslint.config.js) and Prettier (prettierrc and prettierignore) ensure code consistency.
- Tailwind and PostCSS setup: Tailwind config and postcss.config.js manage styling.

##### Relationships and Interactions
- The Layout and UI components form the visual framework and are used across all pages.
- Each feature module (auth, dashboard, tasks, etc.) uses its own folder structure with associated sub-components for both UI and business logic.
- Global context and stores are shared across the modules providing state management (e.g., theme and authentication information).
- The routing system (src/routes) ties together public pages (auth and error routes) with protected/authenticated screens.

##### Architectural Patterns and Design Principles
- Modular Structure: The project follows a feature-based module organization making components, hooks, and contexts highly modular.
- Component Reusability: With a distinct UI library in src/components/ui, the design emphasizes reusable building blocks that can be applied in various contexts.
- Separation of Concerns: The file organization clearly separates layout, business logic (features), routing, and utilities.
- Responsive and Accessible Design: As noted in the README, components are designed with responsiveness and accessibility in mind, which might influence how components interact (e.g., state-sensitive UI updates).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Utilities & Configuration
    subgraph "Utilities & Configuration"
        M["Build Tool (Vite)"]:::infra
        N["TypeScript Configs"]:::infra
        O["Linting & Formatting"]:::infra
        P["Styling Configurations"]:::infra
    end

    %% Routing & Navigation
    subgraph "Routing & Navigation"
        J["Router Setup & Route Groups"]:::infra
    end

    %% UI & Presentation Layer
    subgraph "UI & Presentation Layer"
        A["Layout Components"]:::presentation
        B["UI Components"]:::presentation
        subgraph "Custom Components"
            C1["Password Input"]:::presentation
            C2["Command Menu"]:::presentation
            C3["Profile Dropdown"]:::presentation
            C4["Theme Switch"]:::presentation
        end
        C["Custom Components"]:::presentation
    end

    %% State & Context Providers
    subgraph "State & Context Providers"
        K["Contexts"]:::infra
        L["Stores"]:::infra
    end

    %% Feature Modules
    subgraph "Feature Modules"
        D["Authentication"]:::feature
        E["Dashboard & Analytics"]:::feature
        F["Chats"]:::feature
        G["Tasks"]:::feature
        H["User Management"]:::feature
        I["Settings"]:::feature
    end

    %% Connections: Utilities to Routing
    M --> J
    N --> J
    O --> J
    P --> J

    %% Connections: Routing feeds into UI & Presentation
    J --> A

    %% Connections: UI & Presentation layer wraps Feature Modules
    A --> D
    B --> D
    C --> D

    %% Connections: State & Context Providers supply Feature Modules
    K --> D
    L --> D

    %% Internal vertical grouping within Feature Modules
    D --- E
    E --- F
    F --- G
    G --- H
    H --- I

    %% Styles
    classDef presentation fill:#B8E1FF,stroke:#333,stroke-width:2px;
    classDef feature fill:#FFDDC1,stroke:#333,stroke-width:2px;
    classDef infra fill:#C6F6D5,stroke:#333,stroke-width:2px;

    %% Click Events for UI & Presentation Layer components
    click A "https://github.com/victorvinh04/shadcn-admin/tree/main/src/components/layout"
    click B "https://github.com/victorvinh04/shadcn-admin/tree/main/src/components/ui"
    click C1 "https://github.com/victorvinh04/shadcn-admin/blob/main/src/components/password-input.tsx"
    click C2 "https://github.com/victorvinh04/shadcn-admin/blob/main/src/components/command-menu.tsx"
    click C3 "https://github.com/victorvinh04/shadcn-admin/blob/main/src/components/profile-dropdown.tsx"
    click C4 "https://github.com/victorvinh04/shadcn-admin/blob/main/src/components/theme-switch.tsx"

    %% Click Events for Feature Modules
    click D "https://github.com/victorvinh04/shadcn-admin/tree/main/src/features/auth"
    click E "https://github.com/victorvinh04/shadcn-admin/tree/main/src/features/dashboard"
    click F "https://github.com/victorvinh04/shadcn-admin/tree/main/src/features/chats"
    click G "https://github.com/victorvinh04/shadcn-admin/tree/main/src/features/tasks"
    click H "https://github.com/victorvinh04/shadcn-admin/tree/main/src/features/users"
    click I "https://github.com/victorvinh04/shadcn-admin/tree/main/src/features/settings"

    %% Click Event for Routing & Navigation
    click J "https://github.com/victorvinh04/shadcn-admin/tree/main/src/routes"

    %% Click Events for State & Context Providers
    click K "https://github.com/victorvinh04/shadcn-admin/tree/main/src/context"
    click L "https://github.com/victorvinh04/shadcn-admin/tree/main/src/stores"

    %% Click Events for Utilities & Configuration
    click M "https://github.com/victorvinh04/shadcn-admin/blob/main/vite.config.ts"
    click N "https://github.com/victorvinh04/shadcn-admin/blob/main/tsconfig.json"
    click O "https://github.com/victorvinh04/shadcn-admin/blob/main/eslint.config.js"
    click P "https://github.com/victorvinh04/shadcn-admin/blob/main/tailwind.config.js"
```
