# alex289/portfolio architecture

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

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

## Overview

##### Main System Components

a) Frontend Layer:
- Next.js Application (App Router)
- Internationalization System
- MDX Blog Content
- Authentication UI
- Command Palette
- Analytics

b) API Layer:
- Authentication Endpoints
- Guestbook API
- Now Playing (Spotify Integration)
- Views Counter
- OG Image Generation
- Feed Generation

c) Database Layer:
- Vercel Postgres
- Drizzle ORM

d) External Services:
- GitHub Integration
- Spotify API
- Authentication Providers (Google, GitHub)

**┌─ Client Layer ─────────────────────┐**
- Next.js Pages                    │
- React Components                 │
- TailwindCSS Styling             │
- ┬───────────────────┘
- ↕
**┌─ API Layer ────┴───────────────────┐**
- Next.js API Routes              │
- Authentication                  │
- External API Integration        │
- ┬───────────────────┘
- ↕
**┌─ Data Layer ───┴───────────────────┐**
- Vercel Postgres                 │
- Drizzle ORM                     │
- ┬───────────────────┘
- ↕
**┌─ External Services ─┴──────────────┐**
- GitHub API                      │
- Spotify API                     │
- Auth Providers                  │
- ┘

##### Key Features to Highlight

a) Internationalization Flow:
- How messages/ directory connects to pages
- Locale routing structure

b) Content Management:
- MDX processing pipeline
- Blog post routing
- Image optimization

c) Authentication Flow:
- NextAuth.js integration
- Provider connections
- Protected routes

d) Data Flow:
- API route handling
- Database queries through Drizzle
- External API interactions

##### Implementation Details

- Authentication flow
- Content rendering pipeline
- API route handling
- Database schema
- Internationalization system

Remember to include:
- Error boundaries and error handling
- Build-time vs runtime processes
- Static vs dynamic routes
- Data fetching patterns
- State management flow

This will provide a comprehensive view of the system while maintaining clarity and usefulness for development and documentation purposes.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        NextApp["Next.js App Router"]:::frontend
        I18n["Internationalization"]:::frontend
        MDX["MDX Content"]:::frontend
        Auth_UI["Authentication UI"]:::frontend
        CmdPalette["Command Palette"]:::frontend
        Analytics["Analytics"]:::frontend
        Blog["Blog System"]:::frontend
    end

    subgraph API
        Auth_API["Auth Endpoints"]:::api
        Guestbook["Guestbook API"]:::api
        NowPlaying["Now Playing API"]:::api
        Views["Views Counter"]:::api
        OG["OG Image Gen"]:::api
        Feed["Feed Generation"]:::api
    end

    subgraph Database
        Postgres["Vercel Postgres"]:::database
        Drizzle["Drizzle ORM"]:::database
    end

    subgraph External
        GitHub["GitHub API"]:::external
        Spotify["Spotify API"]:::external
        AuthProviders["Auth Providers"]:::external
    end

    NextApp --> Auth_API
    NextApp --> I18n
    NextApp --> MDX
    NextApp --> Blog
    
    Auth_UI --> Auth_API
    Auth_API --> AuthProviders
    Auth_API --> Drizzle
    
    CmdPalette --> NextApp
    Analytics --> Views
    
    Blog --> MDX
    Blog --> Views
    
    Guestbook --> Drizzle
    NowPlaying --> Spotify
    Views --> Drizzle
    Feed --> MDX
    
    Drizzle --> Postgres

    %% Click Events
    click NextApp "https://github.com/alex289/portfolio/tree/main/src/app/[locale]"
    click I18n "https://github.com/alex289/portfolio/tree/main/src/messages"
    click MDX "https://github.com/alex289/portfolio/tree/main/src/content"
    click Auth_UI "https://github.com/alex289/portfolio/blob/main/src/components/icons/google-icon.tsx"
    click CmdPalette "https://github.com/alex289/portfolio/blob/main/src/components/command-palette.tsx"
    click Analytics "https://github.com/alex289/portfolio/blob/main/src/components/analytics.tsx"
    click Blog "https://github.com/alex289/portfolio/tree/main/src/app/[locale]/blog"
    click Auth_API "https://github.com/alex289/portfolio/blob/main/src/app/api/auth/[...nextauth]"
    click Guestbook "https://github.com/alex289/portfolio/tree/main/src/app/api/guestbook"
    click NowPlaying "https://github.com/alex289/portfolio/tree/main/src/app/api/now-playing"
    click Views "https://github.com/alex289/portfolio/tree/main/src/app/api/views"
    click OG "https://github.com/alex289/portfolio/tree/main/src/app/api/og"
    click Feed "https://github.com/alex289/portfolio/blob/main/src/app/feed.xml/route.ts"
    click Drizzle "https://github.com/alex289/portfolio/blob/main/src/lib/db/index.ts"
    click GitHub "https://github.com/alex289/portfolio/blob/main/src/lib/github.ts"
    click Spotify "https://github.com/alex289/portfolio/blob/main/src/lib/spotify.ts"

    %% Styling
    classDef frontend fill:#3b82f6,color:white
    classDef api fill:#22c55e,color:white
    classDef database fill:#eab308,color:white
    classDef external fill:#a855f7,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        API["API Service"]:::api
        DB["Database"]:::database
        Ext["External Service"]:::external
    end
```
