# transitive-bullshit/severance-wellness-memes architecture

> Architecture diagram of the GitHub repository transitive-bullshit/severance-wellness-memes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/transitive-bullshit/severance-wellness-memes
- Repository: https://github.com/transitive-bullshit/severance-wellness-memes

## Overview

##### Main Components
- Client (Browser/User Devices): The entry point that interacts with the frontend.
- Frontend (Next.js Web Application):
- Pages found under src/app (e.g., about, legal, dynamic pages under src/app/o and src/app/x) indicate the visual and navigational components.
- UI components (in src/components) provide elements like headers, footers, interactive elements (e.g., dark mode toggle, animated inputs, hero buttons).
- Backend / API Endpoints:
- API routes such as those under src/app/api/stripe (for handling Stripe-related webhooks) and dynamic API routes for image generation (e.g., src/app/o/[id]/image) handle server-side logic.
- Tasks/Utilities in the src/bin directory (e.g., seeding, generating wellness facts, resolving Twitter users) serve as CLI tools and background tasks.
- Database:
- The prisma directory and the files under src/lib/db indicate that the application uses Prisma as the ORM layer with a PostgreSQL backend.
- External Services and Integrations:
- Twitter: The app fetches Twitter profiles and tweets. Files like src/lib/resolve-twitter-user.ts and the data seeding files show dependency on Twitter data.
- OpenAI: The README and files in src/lib (like generate-wellness-facts.ts and extract-user-full-name.ts) illustrate calls to gpt-4.5 and gpt-4o-mini for text generation.
- Stripe: The API endpoints handling Stripe webhooks and additional Stripe integration logic in src/lib/stripe.ts highlight payment processing.
- Vercel and Dynamic OG Image Generation: With Next.js and the mention of Vercel’s dynamic image generation powered by Satori, there is an on-the-fly image generation component (visible in files like src/app/o/[id]/image/route.tsx).

##### Architectural Design Principles and Patterns
- The system uses a serverless/edge-like pattern where Next.js API routes act as serverless functions.
- Separation of concerns: Dedicated directories for views (pages), business logic (lib), and utility tools (bin).
- API-driven interactions: Dynamic endpoints (with [id] routes) map to RESTful API handlers that trigger different services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client (Browser/User Devices)"]:::client
    FE["Next.js Frontend"]:::frontend

    subgraph "Frontend - Pages"
        direction TB
        PagesHome["Home & General Pages"]:::frontend
        PagesDynamic["Dynamic Routes (o/[id] & x/[twitterUsername])"]:::frontend
    end

    subgraph "Frontend - UI Components"
        direction TB
        Header["Header Component"]:::frontend
        Footer["Footer Component"]:::frontend
        Animated["Animated Inputs"]:::frontend
        Hero["Hero Button"]:::frontend
        UIShared["UI Shared Components"]:::frontend
    end

    subgraph "Backend/API Layer"
        direction TB
        StripeAPI["Stripe Webhook API"]:::backend
        OGImageAPI["OG Image Generation API"]:::backend
    end

    CLI["CLI Tools & Utilities"]:::cli
    DB["PostgreSQL Database (Prisma)"]:::database

    subgraph "External Services"
        direction TB
        subgraph "Twitter Integration"
            direction TB
            TwitterResolver["Twitter User Resolver"]:::external
            TwitterSeeder["Twitter Data Seeder"]:::external
            TwitterFeatured["Featured Twitter Users"]:::external
        end
        subgraph "OpenAI Integration"
            direction TB
            AIWellness["Generate Wellness Facts"]:::external
            AIFullName["Extract User Full Name"]:::external
        end
        StripeExt["Stripe Payment Gateway"]:::external
        subgraph "Vercel Deployment"
            direction TB
            VercelOG["Dynamic OG Image API"]:::external
            VercelTwitterOG["Twitter OG Image Component"]:::external
        end
    end

    Client -->|"HTTP_Request"| FE
    FE -->|"page_load"| PagesHome
    FE -->|"navigate"| PagesDynamic
    PagesHome -->|"process_payment"| StripeAPI
    PagesDynamic -->|"generate_image"| OGImageAPI
    Header --- Footer
    Animated --- Hero
    Hero --- UIShared

    StripeAPI -->|"db_interaction"| DB
    OGImageAPI -->|"db_interaction"| DB
    CLI -->|"maintenance"| DB

    StripeAPI -->|"payment"| StripeExt
    OGImageAPI -->|"image_gen"| VercelOG
    OGImageAPI -->|"ai_text"| AIWellness
    OGImageAPI -->|"extract_name"| AIFullName

    FE -->|"twitter_profile"| TwitterResolver
    CLI -->|"seed_twitter"| TwitterSeeder
    TwitterSeeder -->|"update_db"| DB
    TwitterResolver -->|"store_data"| DB

    PagesDynamic -->|"og_component"| VercelTwitterOG

    click PagesHome "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/src/app/page.tsx"
    click PagesDynamic "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/src/app/o/[id]/image/route.tsx"
    click Header "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/src/app/header.tsx"
    click Footer "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/src/app/footer.tsx"
    click Animated "https://github.com/transitive-bullshit/severance-wellness-memes/tree/main/src/components/animated-input"
    click Hero "https://github.com/transitive-bullshit/severance-wellness-memes/tree/main/src/components/hero-button"
    click UIShared "https://github.com/transitive-bullshit/severance-wellness-memes/tree/main/src/components/ui"
    click StripeAPI "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/src/app/api/stripe/webhook/route.ts"
    click CLI "https://github.com/transitive-bullshit/severance-wellness-memes/tree/main/src/bin"
    click DB "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/prisma/schema.prisma"
    click TwitterResolver "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/src/lib/resolve-twitter-user.ts"
    click TwitterSeeder "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/src/data/seed-twitter-users.ts"
    click TwitterFeatured "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/src/data/featured-twitter-users.ts"
    click AIWellness "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/src/lib/generate-wellness-facts.ts"
    click AIFullName "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/src/lib/extract-user-full-name.ts"
    click StripeExt "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/src/lib/stripe.ts"
    click VercelOG "https://github.com/transitive-bullshit/severance-wellness-memes/blob/main/src/app/o/[id]/image/route.tsx"
    click VercelTwitterOG "https://github.com/transitive-bullshit/severance-wellness-memes/tree/main/src/app/x/[twitterUsername]"

    classDef client fill:#fce38a,stroke:#333,stroke-width:2px;
    classDef frontend fill:#eaffd0,stroke:#333,stroke-width:2px;
    classDef backend fill:#ffd3b4,stroke:#333,stroke-width:2px;
    classDef cli fill:#c9ada7,stroke:#333,stroke-width:2px;
    classDef database fill:#d3c0eb,stroke:#333,stroke-width:2px;
    classDef external fill:#f9d5bb,stroke:#333,stroke-width:2px;
```
