# nirbhay007/portfolio-new architecture

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

- Interactive diagram: https://gitdiagram.com/nirbhay007/portfolio-new
- Repository: https://github.com/nirbhay007/portfolio-new

## Overview

##### Core Components
- Frontend Application (Next.js):
- Pages (located in the app directory): These include the home page, about, blog, portfolio, services, contact, error pages, and even dynamic routes (e.g., [slug] pages).
- Layouts & Global Styling: The app directory includes global layout files and CSS (globals.css) that ensure consistent styling and structure.
- MDX and Content Integration: The presence of components like mdx-components.js and the content directory (with blog MDX files) show that some pages are rendered using MDX (a mix of Markdown and JSX).
- UI Components Library: A robust set of reusable UI components (in the components/ui and other components subdirectories) is used to assemble different sections (headers, footers, cards, dialogs, etc.).
- Animation & Effects: Components that use Framer Motion (as noted in the README) and other visual elements (e.g., animated-text.tsx, floating-astronaut.tsx, parallax-effect.tsx) indicate advanced UI interactions.
- Backend/API Routes:
- API Endpoints: Found in the app/api directory (e.g., send-email/route.ts) that handle serverless functions, such as processing the contact form submission.
- External Integrations: The README states that the contact form submission leverages Formspree, so although a local API route exists, there is also an external service interaction.
- Static Assets & Configuration:
- Public folder: Contains images, favicon, and other public-facing assets.
- Configuration Files: Files such as next.config.mjs, tailwind.config.ts, postcss.config.js, and tsconfig.json indicate build-time configurations and type settings.
- Supporting Utilities:
- Custom hooks (in the hooks directory) and libraries (located in the lib and types directories) provide business logic and type definitions.

##### Relationships & Data Flow
- Client Requests: Users access the website by navigating to different pages (home, blog, portfolio, etc.) rendered by Next.js.
- Page Rendering: Each page utilizes shared layouts and UI components (e.g., header, footer, sections) which are consistently structured across the site.
- API Interaction: When a user submits the contact form, the request is handled by the API route (app/api/send-email/route.ts) potentially forwarding data to Formspree for processing.
- Content Delivery: Blog posts and project data are served from the content directory, with static/dynamic routing provided by Next.js file system routing.

##### Architectural Patterns and Technologies
- File-Based Routing and Dynamic Route Generation: In Next.js, the app/ directory drives routing automatically (note folders like blog/[slug] and services/[...slug]).
- Component-Based Architecture: Reusable components in the components and components/ui directories encourage modular design.
- Theming and Styling: Utilization of Tailwind CSS and a theme provider (components/theme-provider.tsx) shows theme management, including support for a dark theme.
- Animation Libraries: Framer Motion is used for animations, enhancing the user interface.
- Serverless API: The send-email route represents a serverless API endpoint for handling form submissions.
- External Service Integration: Although not depicted physically in the codebase, the documentation reflects that forms use Formspree.

## Diagram (Mermaid)

```mermaid
flowchart TD
    browser["User Browser"]:::external
    app["Next.js Portfolio Website"]:::pages
    browser -->|"access"| app

    subgraph "Pages & Routing"
        p1["Home Page"]:::pages
        p2["About Page"]:::pages
        p3["Blog Page"]:::pages
        p4["Dynamic Blog Page ([slug])"]:::pages
        p9["Blog Layout"]:::pages
        p5["Portfolio Page"]:::pages
        p6["Services Page"]:::pages
        p7["Contact Page"]:::pages
        p8["Error Pages"]:::pages
    end

    subgraph "Layouts & Global Styling"
        l1["Main Layout"]:::layout
        l2["Global CSS"]:::layout
        l3["Theme Provider"]:::layout
    end

    subgraph "Content Management"
        c1["MDX Components"]:::content
        c2["Content Directory"]:::content
    end

    subgraph "UI Components & Animations"
        u1["UI Components Library"]:::ui
        u2["Animated Text"]:::ui
        u3["Floating Astronaut"]:::ui
        u4["Parallax Effect"]:::ui
        u5["Header, Footer & Sections"]:::ui
    end

    subgraph "API & Integration"
        a1["Contact Form API"]:::api
        a2["Formspree External Service"]:::api
    end

    subgraph "Static Assets & Configuration"
        s1["Public Assets"]:::assets
        s2["Configuration Files"]:::assets
    end

    subgraph "Supporting Utilities"
        ut1["Custom Hooks"]:::util
        ut2["Libraries/Utils"]:::util
        ut3["Type Definitions"]:::util
    end

    %% Connections from the main application to subcomponents
    app -->|"renders"| p1
    app --> p2
    app --> p3
    app --> p4
    app --> p5
    app --> p6
    app --> p7
    app --> p8
    app --> l1
    app --> c1
    app --> u1
    app --> a1
    app --> s1
    app --> ut1

    %% Pages using the Main Layout
    p1 -->|"uses_layout"| l1
    p2 -->|"uses_layout"| l1
    p3 -->|"uses_layout"| l1
    p4 -->|"uses_layout"| l1
    p5 -->|"uses_layout"| l1
    p6 -->|"uses_layout"| l1
    p7 -->|"uses_layout"| l1
    p8 -->|"uses_layout"| l1

    %% Blog pages use the shared Blog Layout
    p3 -->|"composes"| p9
    p4 -->|"composes"| p9

    %% Blog pages render content from the Content Directory
    p3 -->|"renders"| c2
    p4 -->|"renders"| c2

    %% Contact page submits form via API
    p7 -->|"form_submission"| a1
    a1 -->|"forwards_to"| a2

    %% Global Styling components support the Main Layout
    l2 --> l1
    l3 --> l1

    %% UI Components decomposition
    u1 --> u2
    u1 --> u3
    u1 --> u4
    u1 --> u5

    %% Sample connection from a page to UI components
    p1 -->|"includes_UI"| u5

    %% Configuration supports the Website
    s2 --> app

    %% Styling
    classDef pages fill:#CDEBFF,stroke:#0D47A1,stroke-width:2px
    classDef layout fill:#FFECB3,stroke:#FF6F00,stroke-width:2px
    classDef content fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px
    classDef ui fill:#F8BBD0,stroke:#880E4F,stroke-width:2px
    classDef api fill:#D1C4E9,stroke:#5E35B1,stroke-width:2px
    classDef assets fill:#FFF9C4,stroke:#F9A825,stroke-width:2px
    classDef util fill:#B2EBF2,stroke:#006064,stroke-width:2px
    classDef external fill:#E1F5FE,stroke:#0288D1,stroke-width:2px

    %% Click Events for Pages & Routing
    click p1 "https://github.com/nirbhay007/portfolio-new/blob/main/app/page.tsx"
    click p2 "https://github.com/nirbhay007/portfolio-new/blob/main/app/about/page.tsx"
    click p3 "https://github.com/nirbhay007/portfolio-new/blob/main/app/blog/page.tsx"
    click p4 "https://github.com/nirbhay007/portfolio-new/blob/main/app/blog/[slug]/page.tsx"
    click p9 "https://github.com/nirbhay007/portfolio-new/blob/main/app/blog/layout.tsx"
    click p5 "https://github.com/nirbhay007/portfolio-new/blob/main/app/portfolio/page.tsx"
    click p6 "https://github.com/nirbhay007/portfolio-new/blob/main/app/services/[...slug]/page.tsx"
    click p7 "https://github.com/nirbhay007/portfolio-new/blob/main/app/contact/page.tsx"
    click p8 "https://github.com/nirbhay007/portfolio-new/blob/main/app/error.tsx"

    %% Click Events for Layouts & Global Styling
    click l1 "https://github.com/nirbhay007/portfolio-new/blob/main/app/layout.tsx"
    click l2 "https://github.com/nirbhay007/portfolio-new/blob/main/app/globals.css"
    click l3 "https://github.com/nirbhay007/portfolio-new/blob/main/components/theme-provider.tsx"

    %% Click Events for Content Management
    click c1 "https://github.com/nirbhay007/portfolio-new/blob/main/app/mdx-components.js"
    click c2 "https://github.com/nirbhay007/portfolio-new/tree/main/content/"

    %% Click Events for UI Components & Animations
    click u1 "https://github.com/nirbhay007/portfolio-new/tree/main/components/ui"
    click u2 "https://github.com/nirbhay007/portfolio-new/blob/main/components/animated-text.tsx"
    click u3 "https://github.com/nirbhay007/portfolio-new/blob/main/components/floating-astronaut.tsx"
    click u4 "https://github.com/nirbhay007/portfolio-new/blob/main/components/parallax-effect.tsx"
    click u5 "https://github.com/nirbhay007/portfolio-new/blob/main/components/header.tsx"

    %% Click Event for API & Integration
    click a1 "https://github.com/nirbhay007/portfolio-new/blob/main/app/api/send-email/route.ts"

    %% Click Events for Static Assets & Configuration
    click s1 "https://github.com/nirbhay007/portfolio-new/tree/main/public/"
    click s2 "https://github.com/nirbhay007/portfolio-new/blob/main/next.config.mjs"

    %% Click Events for Supporting Utilities
    click ut1 "https://github.com/nirbhay007/portfolio-new/tree/main/hooks/"
    click ut2 "https://github.com/nirbhay007/portfolio-new/tree/main/lib/"
    click ut3 "https://github.com/nirbhay007/portfolio-new/tree/main/types/"
```
