# bytegrad/portfolio-website architecture

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

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

## Overview

##### Project Type and Purpose
- This project is a modern Next.js 13 web application with a focus on a polished, responsive portfolio/website. It incorporates both client and server components, leverages server actions (such as sending emails via Resend), and uses contextual state management.
- The README emphasizes key aspects like Next.js Server Actions, the App Router, TypeScript, Tailwind CSS, Context API, and dynamic UI effects (with Framer Motion). This indicates the app’s role in showcasing modern web development practices.

##### Analyzing the File Structure
- Top-Level Files & Configs: Files such as next.config.js, package.json, tsconfig.json, tailwind.config.js, and others indicate the modern framework and tooling used.
- app Directory:
- Contains layout.tsx, page.tsx, and globals.css, which are responsible for the high-level page structure and styling.
- components Directory:
- A rich collection of UI components (e.g., about, projects, header, footer, etc.) that build up the user interface. These are intended to be reused across the site.
- context Directory:
- Houses Context API components (e.g., active-section-context and theme-context) managing global states like currently active sections and the theme (light/dark mode).
- actions Directory:
- Contains server action code (sendEmail.ts), likely used for handling form submissions and integrating with an external email service.
- email Directory:
- Includes email template or processing logic (contact-form-email.tsx) that formats or handles email content.
- lib Directory:
- Provides utility functions, custom hooks, type definitions, and shared data. This layer encapsulates common logic shared among various parts of the app.

##### Main Architectural Components
a. Frontend (UI) Layer:
- Next.js App Layer: Includes page.tsx and layout.tsx defining overall routing and layout.
- UI Components: All the React components grouped under the “components” directory that build the different sections of the portfolio (e.g., Introduction, About, Projects).
- Client-Side State: Managed through Context Providers found in the “context” directory.
b. Server Side & Business Logic:
- Server Actions: “actions/sendEmail.ts” for handling email sending, encapsulating critical backend logic.
- Email Processing: “email/contact-form-email.tsx” to structure email content, likely interfacing with external services like Resend.
c. Utility/Library Layer:
- “lib” directory encapsulates reusable functions, hooks, and type definitions to support both client and server code.

##### Relationships and Interactions
- The App layout and page components orchestrate rendering, calling various UI components.
- UI components (in “components”) interact with the Context Providers for theme and active section state.
- The Contact component likely triggers a server action by calling “actions/sendEmail.ts” when submitting a form, and this action uses “email/contact-form-email.tsx” to format the email.
- Shared functions, hooks, and type definitions in “lib” are used across multiple components and server actions to maintain consistency.

##### Architectural Patterns and Technologies
- Modern Next.js App Router pattern with segregation of layout and pages.
- Server-Client separation: Clear division between client components (UI, Context) and server actions.
- Use of the Context API for global state management.
- Integration with external services (Resend for email sending).
- Use of TypeScript, Tailwind CSS, and possibly Framer Motion (for advanced animations as mentioned in the README).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side Subgraphs
    subgraph "Client Side"
        %% Next.js App Layer
        subgraph "Next.js App Layer"
            A1["layout.tsx"]:::client
            A2["page.tsx"]:::client
            A3["globals.css"]:::client
        end

        %% UI Components
        subgraph "UI Components"
            U1["about.tsx"]:::client
            U2["contact.tsx"]:::client
            U3["experience.tsx"]:::client
        end

        %% Context Layer
        subgraph "Context Layer"
            C1["active-section-context.tsx"]:::client
            C2["theme-context.tsx"]:::client
        end
    end

    %% Server Side Subgraph
    subgraph "Server Side"
        SA["sendEmail.ts"]:::server
        EP["contact-form-email.tsx"]:::server
    end

    %% Utility/Lib Subgraph
    subgraph "Utility/Lib"
        L1["data.ts"]:::lib
        L2["hooks.ts"]:::lib
        L3["types.ts"]:::lib
        L4["utils.ts"]:::lib
    end

    %% Connections
    A2 -->|"renders"| U1
    A2 -->|"renders"| U2
    A2 -->|"renders"| U3

    U1 -->|"uses"| C1
    U1 -->|"uses"| C2

    U2 -->|"trigger"| SA
    SA -->|"calls"| EP

    U2 ---|"uses"| L1
    SA ---|"uses"| L4

    %% Click Events
    click A1 "https://github.com/bytegrad/portfolio-website/blob/master/app/layout.tsx"
    click A2 "https://github.com/bytegrad/portfolio-website/blob/master/app/page.tsx"
    click A3 "https://github.com/bytegrad/portfolio-website/blob/master/app/globals.css"
    click U1 "https://github.com/bytegrad/portfolio-website/blob/master/components/about.tsx"
    click U2 "https://github.com/bytegrad/portfolio-website/blob/master/components/contact.tsx"
    click U3 "https://github.com/bytegrad/portfolio-website/blob/master/components/experience.tsx"
    click C1 "https://github.com/bytegrad/portfolio-website/blob/master/context/active-section-context.tsx"
    click C2 "https://github.com/bytegrad/portfolio-website/blob/master/context/theme-context.tsx"
    click SA "https://github.com/bytegrad/portfolio-website/blob/master/actions/sendEmail.ts"
    click EP "https://github.com/bytegrad/portfolio-website/blob/master/email/contact-form-email.tsx"
    click L1 "https://github.com/bytegrad/portfolio-website/blob/master/lib/data.ts"
    click L2 "https://github.com/bytegrad/portfolio-website/blob/master/lib/hooks.ts"
    click L3 "https://github.com/bytegrad/portfolio-website/blob/master/lib/types.ts"
    click L4 "https://github.com/bytegrad/portfolio-website/blob/master/lib/utils.ts"

    %% Styles
    classDef client fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef server fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef lib fill:#d4edda,stroke:#155724,stroke-width:2px;
```
