# baldurlogi/portfolio-website architecture

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

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

## Overview

##### Project type and purpose
- This is a full-stack Next.js personal portfolio website with an integrated contact form and email-sending feature.
- The top-level folders (`app/`, `components/`, `context/`, `actions/`, `email/`, `lib/`) + the `react-email-starter` subfolder indicate both a Next.js “App Router” frontend and some server-side logic (Next.js Server Actions) for sending emails.

##### File structure
- app/
- Next.js App Router entrypoints (`layout.tsx`, `page.tsx`) and global CSS.
- Renders React components from components/ and reads data from lib/data.ts.
- components/
- Reusable UI pieces: header, footer, about, projects, contact form, theme switch, etc.
- context/
- React Context providers for tracking active page section and theme.
- actions/sendEmail.tsx
- A Next.js Server Action that processes the contact form data and dispatches an email.
- email/contact-form-email.tsx
- An email template component that formats the contact form submission.
- lib/
- Shared utilities, type definitions, data sources, custom hooks.
- public/
- react-email-starter/
- A self-contained Next.js app used to develop & preview email templates (full code under `.react-email`).
- Configuration files
- next.config.js, tailwind.config.js, tsconfig.json, ESLint, PostCSS.

##### README
- Confirms this was bootstrapped with `create-next-app` using Next.js App Router and automatic font optimization.
- No mention of databases—email sending is the only backend interaction.
- Deployment target is Vercel.

a. Main Components
1. Client Browser (User)
2. Next.js Frontend (App Router)
– UI Components (components/)
– Context Providers (context/)
– Styling (Tailwind via globals.css & tailwind.config.js)
3. Next.js Server Actions
– Contact Form Endpoint (actions/sendEmail.tsx)
– Email Template Renderer (email/contact-form-email.tsx)
4. Email Template Development App (react-email-starter)
5. External Email Service (SMTP provider, e.g., SendGrid, Nodemailer SMTP)

b. Relationships & Data Flow
- User → Next.js Frontend: loads pages, navigates, interacts with the contact form.
- Next.js Frontend → Server Action: form submission triggers `sendEmail` server action.
- Server Action → Email Template: populates `contact-form-email` component with form data.
- Server Action → External Email Service: dispatches the formatted email.
- Developer ↔ react-email-starter: preview/edit email templates in isolation.

c. Architectural Patterns & Design Principles
– App Router pattern in Next.js (colocated routes/components under `app/`).
– React Context for cross-cutting concerns (active section, theme).
– Server Actions for API logic without separate API routes.
– Component-driven UI (atomic to composite components).
– Monorepo-style subapp (`react-email-starter`) for email template dev.

d. Key Technologies & Frameworks
– Next.js (App Router, Server Actions)
– React & React Context
– Tailwind CSS + PostCSS
– TypeScript
– React-Email (email templates)
– Vercel (hosting/deployment)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Zone
    subgraph "Frontend (Next.js App Router)"
        direction TB
        Browser["Client Browser (User)"]:::external
        NextApp["Next.js App Router"]:::frontend
        subgraph "App Router Entrypoints"
            direction TB
            Layout["layout.tsx"]:::frontend
            Page["page.tsx"]:::frontend
            GlobalsCSS["globals.css"]:::frontend
        end
        subgraph "Styling"
            Tailwind["tailwind.config.js"]:::frontend
            PostCSS["postcss.config.js"]:::frontend
        end
        subgraph "UI Components"
            Components["components/"]:::frontend
        end
        subgraph "React Context Providers"
            ActiveCtx["active-section-context.tsx"]:::frontend
            ThemeCtx["theme-context.tsx"]:::frontend
        end
        subgraph "Shared Utilities"
            DataSrc["data.ts"]:::frontend
            Hooks["hooks.ts"]:::frontend
            Types["types.ts"]:::frontend
            Utils["utils.ts"]:::frontend
        end
    end

    %% Backend Zone
    subgraph "Backend (Server Actions)"
        direction TB
        SendEmail["sendEmail Server Action"]:::backend
        EmailTemplate["contact-form-email.tsx"]:::backend
    end

    %% External and Dev Tools
    SMTP["SMTP Email Service"]:::external
    subgraph "Dev Tool (Email Template App)"
        direction TB
        EmailStarter["react-email-starter/.react-email/"]:::devtool
    end

    %% Connections
    Browser -->|"loads pages & interacts"| NextApp
    NextApp -->|"renders layout & pages"| Layout
    NextApp -->|"renders layout & pages"| Page
    NextApp -->|"applies global styles"| GlobalsCSS
    NextApp -->|"uses Tailwind/PostCSS"| Tailwind
    NextApp -->|"uses Tailwind/PostCSS"| PostCSS
    NextApp -->|"renders UI components"| Components
    NextApp -->|"provides context"| ActiveCtx
    NextApp -->|"provides context"| ThemeCtx
    NextApp -->|"uses shared utilities"| DataSrc
    NextApp -->|"uses shared utilities"| Hooks
    NextApp -->|"uses shared utilities"| Types
    NextApp -->|"uses shared utilities"| Utils

    Components -->|"contact form submits to"| SendEmail
    SendEmail -->|"renders template"| EmailTemplate
    SendEmail -->|"dispatches email via"| SMTP

    Developer(("Developer")):::devtool
    Developer -->|"preview/edit templates"| EmailStarter

    %% Click Events
    click Layout "https://github.com/baldurlogi/portfolio-website/blob/main/app/layout.tsx"
    click Page "https://github.com/baldurlogi/portfolio-website/blob/main/app/page.tsx"
    click GlobalsCSS "https://github.com/baldurlogi/portfolio-website/blob/main/app/globals.css"
    click Tailwind "https://github.com/baldurlogi/portfolio-website/blob/main/tailwind.config.js"
    click PostCSS "https://github.com/baldurlogi/portfolio-website/blob/main/postcss.config.js"
    click Components "https://github.com/baldurlogi/portfolio-website/tree/main/components/"
    click ActiveCtx "https://github.com/baldurlogi/portfolio-website/blob/main/context/active-section-context.tsx"
    click ThemeCtx "https://github.com/baldurlogi/portfolio-website/blob/main/context/theme-context.tsx"
    click SendEmail "https://github.com/baldurlogi/portfolio-website/blob/main/actions/sendEmail.tsx"
    click EmailTemplate "https://github.com/baldurlogi/portfolio-website/blob/main/email/contact-form-email.tsx"
    click DataSrc "https://github.com/baldurlogi/portfolio-website/blob/main/lib/data.ts"
    click Hooks "https://github.com/baldurlogi/portfolio-website/blob/main/lib/hooks.ts"
    click Types "https://github.com/baldurlogi/portfolio-website/blob/main/lib/types.ts"
    click Utils "https://github.com/baldurlogi/portfolio-website/blob/main/lib/utils.ts"
    click EmailStarter "https://github.com/baldurlogi/portfolio-website/tree/main/react-email-starter/.react-email/"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#0366d6,color:#0366d6,stroke-width:2px
    classDef backend fill:#d4edda,stroke:#22863a,color:#22863a,stroke-width:2px
    classDef external fill:#ffe5b4,stroke:#d18601,color:#d18601,stroke-width:2px
    classDef devtool fill:#e2e3e5,stroke:#6a737d,color:#6a737d,stroke-width:2px
```
