# swayamterode/portfolio architecture

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

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

## Overview

##### Main Components
- Frontend/UI Layer:
- Located primarily in the "app" directory.
- Contains pages such as the homepage (app/page.tsx), about page (app/about/page.tsx), contact page (app/contact/page.tsx), tech stack page (app/tech-stack/page.tsx), and work page (app/work/page.tsx).
- Global application elements like app/layout.tsx, styling in app/globals.css, and providers in app/providers.tsx.
- Reusable UI elements and components in the "components" directory (e.g., Navbar, Footer, Hero, buttons, and animations).

- API/Backend Layer:
- Contains API endpoints under app/api (for instance, about-me, contact, hero, and tech-stack endpoints).
- These endpoints handle client requests for dynamic content and interactions like contact form submissions or fetching data for the hero section.

- Business Logic/Service Layer:
- Modules in "lib", including database connections (lib/db.ts) and modal definitions, which separate business logic from presentation and API endpoints.
- External configurations in "config" (e.g., config/nodemailer.ts for handling email sending).

- Data & Constants:
- "constants" directory for static data such as project details and portfolio-specific information.
- "utils" directory for shared utilities like API response handling (utils/ApiResponse.ts), toast notifications (utils/Toastify.ts), and social links.

- Public Assets & Animation Files:

##### Relationships and Interactions
- The Frontend pages use components to present content and interact with API endpoints for dynamic features.
- API endpoints serve data requests from the frontend and interact with underlying business logic (via lib modules) and database (MongoDB via lib/db.ts).
- Utility and constant modules provide support across components and endpoints ensuring consistent data and behavior.
- External services (such as email via nodemailer) are integrated within the API endpoints to handle tasks like sending messages from the contact form.

##### Architectural Patterns and Design Principles
- File-based Routing (Next.js): Pages and API endpoints are automatically mapped from specific file and directory paths.
- Component-based Architecture: Reusable UI components are abstracted in the components directory, which enhances maintainability.
- Separation of Concerns: Clear boundaries exist between UI (app, components), backend/API (app/api), business logic (lib, config), and static assets (public).
- Responsive & Modern Design: Use of Tailwind CSS for styling and responsive layout, with capabilities for dark mode.
- Integration of Third-Party Libraries: ThreeJS for animations; nodemailer for email functionality; and MongoDB for data persistence.

##### Relevant Technologies and Frameworks
- Next.js for server-side rendering and routing.
- Tailwind CSS for styling and responsive design.
- ThreeJS for animations and 3D model rendering.
- MongoDB as the database.
- Node environment with configurations in .env.sample and next.config.js.
- Utility libraries and components for enhanced user interactions (like Toast notifications, theme switching).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client-Side Frontend
    subgraph "Client-Side Frontend"
        direction TB
        Home["Next.js Page (Home)"]
        About["Next.js Page (About)"]
        Contact["Next.js Page (Contact)"]
        TechStack["Next.js Page (Tech-Stack)"]
        Work["Next.js Page (Work)"]
        GlobalStyling["Global Styling (Tailwind CSS)"]
        Providers["Providers (Context)"]
        Navbar["UI Component: Navbar"]
        Footer["UI Component: Footer"]
        Hero["UI Component: Hero"]
        Button["UI Component: Button"]
        MobileNavbar["UI Component: MobileNavbar"]
        ThemeSwitcher["UI Component: ThemeSwitcher"]
    end

    %% Backend/API
    subgraph "Backend/API"
        direction TB
        APIAbout["API Endpoint: About Me"]
        APIContact["API Endpoint: Contact"]
        APIHero["API Endpoint: Hero"]
        APITechStack["API Endpoint: Tech-Stack"]
        Database["Database (MongoDB)"]
        Models["Data Models"]
    end

    %% External Services & Integrations
    subgraph "External & Integrations"
        direction TB
        EmailService["Email Service (Nodemailer)"]
        StaticAssets["Static Assets & ThreeJS Animations"]
    end

    %% Configuration & Utilities
    subgraph "Configuration & Utilities"
        direction TB
        TailwindConfig["Tailwind Config"]
        PostCSSConfig["PostCSS Config"]
        Utils["Utility Functions"]
    end

    %% Data flow connections

    %% Frontend requests to API endpoints
    Home -->|"requests"| APIHero
    About -->|"requests"| APIAbout
    Contact -->|"submits"| APIContact
    TechStack -->|"requests"| APITechStack
    Work -->|"displays"| APIHero

    %% Internal Frontend interactions
    Home -->|"uses"| Navbar
    Home -->|"uses"| Footer
    Home -->|"integrates"| Hero
    Home -->|"styledBy"| GlobalStyling
    Home -->|"stateVia"| Providers

    %% API interactions with Database and Email Service
    APIAbout -->|"queries"| Database
    APIHero -->|"queries"| Database
    APITechStack -->|"queries"| Database
    APIContact -->|"sends"| EmailService

    %% Database structured by Models
    Database -->|"structuredBy"| Models

    %% Frontend rendering static assets
    Home -->|"renders3D"| StaticAssets
    Hero -->|"includes3D"| StaticAssets

    %% Configuration & Utilities usage by Frontend
    Home -->|"stylesWith"| TailwindConfig
    Home -->|"helperVia"| Utils

    %% Click Events
    click Home "https://github.com/swayamterode/portfolio/blob/main/app/page.tsx"
    click About "https://github.com/swayamterode/portfolio/blob/main/app/about/page.tsx"
    click Contact "https://github.com/swayamterode/portfolio/blob/main/app/contact/page.tsx"
    click TechStack "https://github.com/swayamterode/portfolio/blob/main/app/tech-stack/page.tsx"
    click Work "https://github.com/swayamterode/portfolio/blob/main/app/work/page.tsx"
    click GlobalStyling "https://github.com/swayamterode/portfolio/blob/main/app/globals.css"
    click Providers "https://github.com/swayamterode/portfolio/blob/main/app/providers.tsx"
    click Navbar "https://github.com/swayamterode/portfolio/blob/main/components/Navbar.tsx"
    click Footer "https://github.com/swayamterode/portfolio/blob/main/components/Footer.tsx"
    click Hero "https://github.com/swayamterode/portfolio/blob/main/components/Hero.tsx"
    click Button "https://github.com/swayamterode/portfolio/blob/main/components/Button.tsx"
    click MobileNavbar "https://github.com/swayamterode/portfolio/blob/main/components/MobileNavbar.tsx"
    click ThemeSwitcher "https://github.com/swayamterode/portfolio/blob/main/components/ThemeSwitcher.tsx"
    click APIAbout "https://github.com/swayamterode/portfolio/blob/main/app/api/about-me/route.ts"
    click APIContact "https://github.com/swayamterode/portfolio/blob/main/app/api/contact/route.ts"
    click APIHero "https://github.com/swayamterode/portfolio/blob/main/app/api/hero/route.ts"
    click APITechStack "https://github.com/swayamterode/portfolio/blob/main/app/api/tech-stack/route.ts"
    click Database "https://github.com/swayamterode/portfolio/blob/main/lib/db.ts"
    click Models "https://github.com/swayamterode/portfolio/blob/main/lib/modals/About_me.ts"
    click Models "https://github.com/swayamterode/portfolio/blob/main/lib/modals/hero_section.ts"
    click Models "https://github.com/swayamterode/portfolio/blob/main/lib/modals/text_stack.ts"
    click EmailService "https://github.com/swayamterode/portfolio/blob/main/config/nodemailer.ts"
    click StaticAssets "https://github.com/swayamterode/portfolio/tree/main/public"
    click TailwindConfig "https://github.com/swayamterode/portfolio/blob/main/tailwind.config.ts"
    click PostCSSConfig "https://github.com/swayamterode/portfolio/blob/main/postcss.config.js"
    click Utils "https://github.com/swayamterode/portfolio/tree/main/utils"

    %% Style definitions
    classDef frontend fill:#a8dadc,stroke:#457b9d,stroke-width:2px;
    classDef api fill:#f4a261,stroke:#e76f51,stroke-width:2px;
    classDef database fill:#2a9d8f,stroke:#264653,stroke-width:2px;
    classDef external fill:#e9c46a,stroke:#f4a261,stroke-width:2px;
    classDef config fill:#e76f51,stroke:#e63946,stroke-width:2px;

    %% Assigning classes
    class Home,About,Contact,TechStack,Work,GlobalStyling,Providers,Navbar,Footer,Hero,Button,MobileNavbar,ThemeSwitcher frontend;
    class APIAbout,APIContact,APIHero,APITechStack api;
    class Database,Models database;
    class EmailService,StaticAssets external;
    class TailwindConfig,PostCSSConfig,Utils config;
```
