# zackproser/portfolio architecture

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

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

## Overview

##### Main System Components

a) Frontend Layer:
- Next.js Application (App Router)
- Client Components
- Server Components
- MDX Content
- Static Pages

b) API Layer:
- Authentication endpoints (/api/auth)
- Chat functionality (/api/chat)
- Embeddings service (/api/embeddings)
- Payment processing (/api/checkout-sessions)
- OpenGraph image generation (/api/og)

c) External Services Integration:
- Authentication service (NextAuth)
- Vector database integration (Pinecone)
- Payment processing (Stripe)
- Comments system (Giscus)
- Newsletter service (likely Postmark based on postmark.ts)

##### Data Flow Architecture

Key interactions:

a) Content Management:
- MDX files → Static Generation
- Blog posts
- Courses
- Videos
- Newsletters

b) Dynamic Features:
- Authentication flow
- Chat functionality
- Vector search
- Payment processing

##### Specific Implementation Details

Architectural patterns:

a) Next.js App Router Structure:
- Route groups
- API routes
- Static pages
- Dynamic routes

b) Data Services:
- Embeddings generation
- Vector search
- Content indexing

##### Key Relationships to Highlight

- Content pipeline: MDX → Static Generation → Pages
- Search functionality: Content → Embeddings → Vector DB → Search Results
- Authentication flow: User → NextAuth → Protected Routes
- Payment processing: Checkout → Stripe → Success/Failure

**[Client Browser] ←→ [Next.js App]**
- ↓               ↓
**[Static Content] ←→ [API Layer]**
- ↙ ↓ ↘
- [Auth] [Payments] [Vector Search]

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Browser/Client"]
    end

    subgraph NextApp["Next.js Application"]
        direction TB
        AppRouter["App Router"]:::nextjs
        ClientComp["Client Components"]:::nextjs
        ServerComp["Server Components"]:::nextjs
        StaticPages["Static Pages"]:::nextjs
        MDXContent["MDX Content"]:::nextjs
    end

    subgraph APILayer["API Layer"]
        direction TB
        Auth["/api/auth"]:::api
        Chat["/api/chat"]:::api
        Embed["/api/embeddings"]:::api
        Payment["/api/checkout-sessions"]:::api
        OG["/api/og"]:::api
    end

    subgraph Content["Content Management"]
        direction TB
        Blog["Blog Posts"]:::content
        Courses["Courses"]:::content
        Videos["Videos"]:::content
        Newsletter["Newsletters"]:::content
    end

    subgraph ExternalServices["External Services"]
        direction TB
        NextAuth["NextAuth"]:::external
        Pinecone["Pinecone Vector DB"]:::external
        Stripe["Stripe Payments"]:::external
        Giscus["Giscus Comments"]:::external
        Postmark["Postmark Email"]:::external
    end

    subgraph Search["Search System"]
        direction TB
        ArticleSearch["Article Search"]:::search
        DevToolSearch["DevTool Search"]:::search
        SearchForm["Search Form"]:::search
    end

    Browser --> AppRouter
    AppRouter --> ClientComp
    AppRouter --> ServerComp
    AppRouter --> StaticPages
    AppRouter --> MDXContent

    StaticPages --> Content
    MDXContent --> Content

    AppRouter --> APILayer
    Auth --> NextAuth
    Chat --> Pinecone
    Embed --> Pinecone
    Payment --> Stripe
    
    Search --> Embed

    Newsletter --> Postmark

    %% Styles
    classDef nextjs fill:#1E40AF,color:white
    classDef api fill:#FCD34D,color:black
    classDef external fill:#10B981,color:white
    classDef content fill:#8B5CF6,color:white
    classDef search fill:#F97316,color:white

    %% Click Events
    click AppRouter "https://github.com/zackproser/portfolio/tree/main/src/app/"
    click Auth "https://github.com/zackproser/portfolio/tree/main/src/app/api/auth/[...nextauth]/"
    click Chat "https://github.com/zackproser/portfolio/tree/main/src/app/api/chat/"
    click Embed "https://github.com/zackproser/portfolio/tree/main/src/app/api/embeddings/"
    click Payment "https://github.com/zackproser/portfolio/tree/main/src/app/api/checkout-sessions/"
    click OG "https://github.com/zackproser/portfolio/tree/main/src/app/api/og/"
    click Blog "https://github.com/zackproser/portfolio/tree/main/src/app/blog/"
    click Courses "https://github.com/zackproser/portfolio/tree/main/src/app/learn/courses/"
    click Videos "https://github.com/zackproser/portfolio/tree/main/src/app/videos/"
    click Newsletter "https://github.com/zackproser/portfolio/tree/main/src/app/newsletter/"
    click ArticleSearch "https://github.com/zackproser/portfolio/blob/main/src/components/ArticleSearch.tsx"
    click DevToolSearch "https://github.com/zackproser/portfolio/blob/main/src/components/DevToolSearch.tsx"
    click SearchForm "https://github.com/zackproser/portfolio/blob/main/src/components/SearchForm.tsx"
    click ClientComp "https://github.com/zackproser/portfolio/blob/main/src/app/HomepageClientComponent.tsx"
```
