# krkavinraj/kavinai-website architecture

> Architecture diagram of the GitHub repository krkavinraj/kavinai-website, 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/krkavinraj/kavinai-website
- Repository: https://github.com/krkavinraj/kavinai-website

## Overview

##### Main Components
- Frontend Pages – Represented by the files in the “src/app” directory. Note the “layout.tsx” files (global layout) and the specific page routes groupings in “(pages)”. Pages include specific routes such as download, pricing, questions, and waitlist.
- API Endpoints – For example, the API route under “src/app/api/waitlist/route.ts” which handles server-side logic (likely for the waitlist functionality).
- UI Components – Located in “src/components” and further organized (e.g., “ui” subfolder for atomic elements like button, card, input). There are additional specialized components like “demo-video”, “hero”, “navbar”, etc.
- Global Providers & Hooks – “src/app/Provider.tsx” hints at a global state or context provider, while custom hooks (in “src/hooks”) manage reusable logic (like toast notifications).
- Utility Libraries – In “src/lib”, containing helpers for database interactions (e.g., “mongodb.ts”) and other utility functions (“utils.ts”).
- Public Assets – The “public” directory contains static assets like demo videos.

##### Relationships and Interactions
- The Browser (Client) interacts with the Next.js Frontend, rendering pages (from “src/app/(pages)”) which are composed of reusable UI components (from “src/components”).
- The global provider imported in “src/app/Provider.tsx” likely wraps the application, managing state or context for UI components.
- Some pages additionally interact with server-side functionality via API routes (e.g., the waitlist API under “src/app/api/waitlist”), which in turn might use utilities (from “src/lib”) for data persistence or other backend operations.
- Static assets are served to enhance user content (e.g., demo videos in “public”).

##### Architectural Patterns and Technology Stack
- Next.js App Router & Component-Based Design: The project heavily uses Next.js conventions with segregated “pages” that automatically handle route creation.
- Separation of Concerns: Clear separation between layout/pages, business logic (via API endpoints), and UI components.
- Styling: Use of Tailwind CSS and PostCSS (evidenced by “tailwind.config.ts”, “postcss.config.mjs”, and global CSS files).
- Code Quality & Linting: Presence of ESLint (through “eslint.config.mjs”) ensuring code consistency.
- Advanced Components: The “magicui” and other specialized directories indicate custom component groups bolstering visual features.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Global Entities
    CB["Client Browser"]:::client

    %% Frontend Application Layer
    subgraph "Frontend Application Layer"
        subgraph "Global Shell"
            GL["Global Layout"]:::layout
            GP["Global Provider"]:::layout
            GL --> GP
        end
        subgraph "Pages"
            DP["Download Page"]:::pages
            PP["Pricing Page"]:::pages
            QP["Questions Page"]:::pages
            WP["Waitlist Page"]:::pages
        end
    end

    %% UI Components
    UICC["UI Components (Common)"]:::ui
    UICU["UI Components (UI)"]:::ui

    %% Global Hooks
    GH["Global Hooks"]:::hooks

    %% API Endpoint
    API["Waitlist API"]:::api

    %% Utility Libraries
    subgraph "Utility Libraries"
        UM["MongoDB"]:::util
        UU["Utils"]:::util
    end

    %% Public Assets
    PA["Public Assets"]:::assets

    %% Connections
    CB --> GL
    GP --> DP
    GP --> PP
    GP --> QP
    GP --> WP
    GP --> UICC
    GP --> UICU
    GP --> GH
    GP --> PA
    WP --> API
    API --> UM
    API --> UU

    %% Click Events
    click DP "https://github.com/krkavinraj/kavinai-website/tree/main/src/app/(pages)/download"
    click PP "https://github.com/krkavinraj/kavinai-website/tree/main/src/app/(pages)/pricing"
    click QP "https://github.com/krkavinraj/kavinai-website/tree/main/src/app/(pages)/questions"
    click WP "https://github.com/krkavinraj/kavinai-website/tree/main/src/app/(pages)/waitlist"
    click API "https://github.com/krkavinraj/kavinai-website/blob/main/src/app/api/waitlist/route.ts"
    click GL "https://github.com/krkavinraj/kavinai-website/blob/main/src/app/layout.tsx"
    click GP "https://github.com/krkavinraj/kavinai-website/blob/main/src/app/Provider.tsx"
    click UICC "https://github.com/krkavinraj/kavinai-website/tree/main/src/components"
    click UICU "https://github.com/krkavinraj/kavinai-website/tree/main/src/components/ui"
    click GH "https://github.com/krkavinraj/kavinai-website/blob/main/src/hooks/use-toast.ts"
    click UM "https://github.com/krkavinraj/kavinai-website/blob/main/src/lib/mongodb.ts"
    click UU "https://github.com/krkavinraj/kavinai-website/blob/main/src/lib/utils.ts"
    click PA "https://github.com/krkavinraj/kavinai-website/tree/main/public"

    %% Styles
    classDef client fill:#8ecae6,stroke:#333,stroke-width:2px;
    classDef layout fill:#219ebc,stroke:#333,stroke-width:2px;
    classDef pages fill:#ffb703,stroke:#333,stroke-width:2px;
    classDef api fill:#fb8500,stroke:#333,stroke-width:2px;
    classDef ui fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef hooks fill:#f94144,stroke:#333,stroke-width:2px;
    classDef util fill:#577590,stroke:#333,stroke-width:2px;
    classDef assets fill:#a9def9,stroke:#333,stroke-width:2px;
```
