# ankush-web-eng/personal_website architecture

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

- Interactive diagram: https://gitdiagram.com/ankush-web-eng/personal_website
- Repository: https://github.com/ankush-web-eng/personal_website

## Overview

##### Main Components
- Client (Browser/User Interface): Represents how visitors interact with the website.
- Next.js Application Server:
- UI/Pages: All the rendered pages under the “app” directory (for example, landing pages for about, freelance, kaizen, messages, add pages).
- Components: The reusable UI elements in the “components” folder (headers, footers, navigation, cards, skeletons, etc.).
- Layout and Providers: Global layout files (app/layout.tsx, app/provider.tsx) and context providers (for sessions and themes).
- API Layer: Located in “app/api” with endpoints organized by resource (applications, blogs, freelance, ghost, messages, projects, skill, testimonial, and users). These endpoints handle CRUD operations and authentication (using NextAuth in the “auth” subfolder).
- Database & ORM: The “prisma” folder with the Prisma schema and migrations indicates a database layer (the data store for blogs, projects, testimonials, etc.) accessed via utilities in “lib/db.ts” and through models under “models”.
- External & Third-Party Services:
- Firebase Config: Found in the “config/firebase.ts” file may be used for notifications, storage, or other external service interactions.
- NextAuth: For authentication, integrated with the API endpoints in “api/auth/[...nextauth]”.

##### Relationships & Data Flow
- The Browser sends requests (either page navigation or API calls) to the Next.js server.
- The UI layer (pages and components) consumes data from the API endpoints.
- API endpoints (RESTful or Next.js route handlers) process incoming requests, perform database operations via Prisma, and then send responses back.
- The authentication flows (managed in “api/auth”) are used by the session provider under “context/SessionProvider.tsx” to secure pages and API endpoints.
- Shared utilities (in “lib” and “context”) assist with state management, theming, and database connections.

##### Architectural Patterns & Design Principles
- Separation of Concerns: The code is separated into UI (components, pages), API (server logic, CRUD operations), and data access (Prisma schema and models).
- Modular Design: Resources like “blogs”, “projects”, and “messages” are isolated in both their UI and API representations, supporting easier maintenance and potential refactoring.
- Dynamic Routing: The “app/(routes)” and “app/add” directories feature dynamic routes (using [id]) to handle variable content, which is a typical pattern in Next.js applications.
- Consistent Naming & Structure: The API routes mirror the structure of the UI routes, making the design more intuitive.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client("Client (Browser/User Interface)"):::client

    subgraph "Next.js Server"
        subgraph "UI - Pages"
            P1("Home Page"):::ui
            P2("About Page"):::ui
            P3("Freelance Page"):::ui
            P4("Kaizen Page"):::ui
            P5("Messages Page"):::ui
            P6("Dynamic [id] Routes"):::ui
        end
        C("UI - Components (Reusable Elements)"):::ui
        subgraph "Layout & Providers"
            L1("Layout (app/layout.tsx)"):::ui
            L2("Provider (app/provider.tsx)"):::ui
            L3("SessionProvider (context/SessionProvider.tsx)"):::ui
            L4("ThemeProvider (context/theme-provider.tsx)"):::ui
        end
    end

    subgraph "API Layer"
        E("API Endpoints (CRUD Operations)"):::api
        E1("NextAuth (Authentication)"):::api
    end

    subgraph "Database & ORM"
        F1("Prisma (prisma)"):::db
        F2("DB Utility (lib/db.ts)"):::db
        F3("Models (models)"):::db
    end

    subgraph "External Services"
        H("Firebase Config (config/firebase.ts)"):::external
    end

    %% Relationships & Data Flow
    Client -->|"navigates"| P1
    Client -->|"uses"| C
    Client -->|"loads"| L1

    P1 -->|"fetchesData"| E
    C -->|"callsAPI"| E
    L3 -->|"authenticates"| E1

    E -->|"performsCRUD"| F1
    E -->|"performsCRUD"| F2
    E -->|"performsCRUD"| F3

    E -->|"integrates"| E1
    E -->|"externalCalls"| H

    %% Click Events for UI - Pages
    click P1 "https://github.com/ankush-web-eng/personal_website/blob/master/app/page.tsx"
    click P2 "https://github.com/ankush-web-eng/personal_website/blob/master/app/(routes)/about/page.tsx"
    click P3 "https://github.com/ankush-web-eng/personal_website/blob/master/app/(routes)/freelance/page.tsx"
    click P4 "https://github.com/ankush-web-eng/personal_website/blob/master/app/(routes)/kaizen/page.tsx"
    click P5 "https://github.com/ankush-web-eng/personal_website/blob/master/app/(routes)/messages/page.tsx"
    click P6 "https://github.com/ankush-web-eng/personal_website/tree/master/app/(routes)/[id]"

    %% Click Events for UI - Components
    click C "https://github.com/ankush-web-eng/personal_website/tree/master/components"

    %% Click Events for Layout & Providers
    click L1 "https://github.com/ankush-web-eng/personal_website/blob/master/app/layout.tsx"
    click L2 "https://github.com/ankush-web-eng/personal_website/blob/master/app/provider.tsx"
    click L3 "https://github.com/ankush-web-eng/personal_website/blob/master/context/SessionProvider.tsx"
    click L4 "https://github.com/ankush-web-eng/personal_website/blob/master/context/theme-provider.tsx"

    %% Click Events for API Layer
    click E "https://github.com/ankush-web-eng/personal_website/tree/master/app/api"
    click E1 "https://github.com/ankush-web-eng/personal_website/blob/master/app/api/auth/[...nextauth]/route.ts"

    %% Click Events for Database & ORM
    click F1 "https://github.com/ankush-web-eng/personal_website/tree/master/prisma"
    click F2 "https://github.com/ankush-web-eng/personal_website/blob/master/lib/db.ts"
    click F3 "https://github.com/ankush-web-eng/personal_website/tree/master/models"

    %% Click Event for External Services
    click H "https://github.com/ankush-web-eng/personal_website/blob/master/config/firebase.ts"

    %% Styles
    classDef client fill:#FFD700,stroke:#DAA520,stroke-width:2px;
    classDef ui fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef api fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef db fill:#FFB6C1,stroke:#B22222,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#696969,stroke-width:2px;
```
