# gomolemo-k/founderfinder architecture

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

- Interactive diagram: https://gitdiagram.com/gomolemo-k/founderfinder
- Repository: https://github.com/gomolemo-k/founderfinder

## Overview

##### Project type and purpose
- This is a full-stack SaaS starter built with Next.js 13’s App Router. It provides a marketing site (landing & pricing), authentication (sign-in/up, JWT cookies), payment integration (Stripe Checkout & webhooks), and a protected dashboard exposing CRUD on teams/users with RBAC and activity logging.

##### File structure
- Top-level “app/” directory:
- (login) segment handles sign-in & sign-up pages and actions.ts for server actions.
- (dashboard) segment contains layout.tsx, nested dashboard sub-routes (activity, general, security, pricing).
- app/api/stripe, app/api/team, app/api/user: serverless API routes.
- “components/ui/”: shared UI primitives (button, card, input, etc.).
- “lib/”:
- lib/auth: JWT session handling and middleware.
- lib/db: Drizzle ORM setup, migrations, queries, seeding.
- lib/payments: Stripe integration functions.
- lib/utils: helpers.
- Configuration & infra: Docker Compose, drizzle.config.ts, next.config.js, open-next.config.ts, wrangler.jsonc (for Cloudflare Workers), GitHub Actions deploy.yml.

##### README for additional insights
- Confirms tech stack: Next.js, Postgres, Drizzle ORM, Stripe, shadcn/ui.
- Describes key features: marketing pages, Stripe Checkout & Customer Portal, dashboard with CRUD, RBAC, JWT auth, middleware protection, activity logs.
- Outlines local dev (db setup/migrate/seed), Stripe CLI for webhooks, deployment to Vercel/Cloudflare with env vars.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client & CDN
    Browser["Client (Browser)"]:::frontend
    CDN["CDN/Edge (Vercel/Cloudflare)"]:::frontend
    Browser --> CDN

    %% Next.js App Server
    subgraph "Next.js App Server"
        direction TB
        SSR["SSR/SSG Pages"]:::nextjs
        MiddlewareLib["Auth Middleware"]:::nextjs
        subgraph "Server Actions & API Routes"
            direction TB
            APIUser["/api/user"]:::nextjs
            APITeam["/api/team"]:::nextjs
            CheckoutRoute["/api/stripe/checkout"]:::nextjs
            WebhookRoute["/api/stripe/webhook"]:::nextjs
            Actions["Server Actions"]:::nextjs
        end
    end

    CDN --> SSR
    SSR --> Browser
    Browser -->|login/signup| APIUser
    APIUser -->|sets JWT cookie| Browser
    Browser --> MiddlewareLib --> SSR

    %% Public Marketing
    subgraph "Public Marketing"
        direction TB
        LandingLayout["app/layout.tsx"]:::frontend
        LandingPage["app/page.tsx"]:::frontend
        LandingData["data/landingPageContent.json"]:::frontend
        PricingMarketing["app/(dashboard)/pricing/page.tsx"]:::frontend
    end
    SSR --> LandingLayout --> LandingPage --> LandingData
    LandingPage --> PricingMarketing

    %% Authentication
    subgraph "Authentication"
        direction TB
        AuthLoginPage["app/(login)/sign-in/page.tsx"]:::frontend
        AuthSignUpPage["app/(login)/sign-up/page.tsx"]:::frontend
        AuthActions["app/(login)/actions.ts"]:::nextjs
        AuthSession["lib/auth/session.ts"]:::nextjs
        AuthMiddlewareLib["lib/auth/middleware.ts"]:::nextjs
        GlobalMiddleware["middleware.ts"]:::nextjs
    end
    Browser --> AuthLoginPage --> AuthActions --> AuthSession
    AuthMiddlewareLib --> SSR
    GlobalMiddleware --> SSR

    %% Payment Integration
    CheckoutRoute --> PaymentsActions["lib/payments/actions.ts"]:::infra
    PaymentsActions --> PaymentsStripe["lib/payments/stripe.ts"]:::infra
    WebhookRoute --> PaymentsActions
    CheckoutRoute -->|"redirect to Stripe Checkout"| StripeCheckout
    StripeCheckout["Stripe Checkout"]:::external
    StripeCheckout -->|checkout session| WebhookRoute
    WebhookRoute -->|"handle webhook"| PaymentsActions
    PaymentsActions --> Drizzle

    %% Protected Dashboard
    subgraph "Authenticated Dashboard"
        direction TB
        DashboardLayout["app/(dashboard)/layout.tsx"]:::frontend
        DashboardHome["app/(dashboard)/dashboard/page.tsx"]:::frontend
        GeneralPage["app/(dashboard)/dashboard/general/page.tsx"]:::frontend
        SecurityPage["app/(dashboard)/dashboard/security/page.tsx"]:::frontend
        ActivityPage["app/(dashboard)/dashboard/activity/page.tsx"]:::frontend
        ActivityLoading["app/(dashboard)/dashboard/activity/loading.tsx"]:::frontend
        DashboardPricingButton["app/(dashboard)/pricing/submit-button.tsx"]:::frontend
    end
    SSR --> DashboardLayout
    DashboardLayout --> DashboardHome --> GeneralPage
    DashboardHome --> SecurityPage
    DashboardHome --> ActivityPage --> ActivityLoading
    DashboardLayout --> DashboardPricingButton
    DashboardPricingButton --> CheckoutRoute

    APITeam["/api/team"] --> Drizzle
    UserRoute["/api/user"]:::nextjs --> Drizzle

    %% Database & ORM
    subgraph "Database & ORM"
        direction TB
        DrizzleORM["lib/db/drizzle.ts"]:::infra
        Schema["lib/db/schema.ts"]:::infra
        Queries["lib/db/queries.ts"]:::infra
        Migrations["lib/db/migrations/"]:::infra
        Seed["lib/db/seed.ts"]:::infra
        Setup["lib/db/setup.ts"]:::infra
        DrizzleConfig["drizzle.config.ts"]:::infra
        Postgres["Postgres Database"]:::infra
    end
    DrizzleORM --> Postgres
    Schema --> DrizzleORM
    Queries --> DrizzleORM
    Migrations --> DrizzleORM
    Seed --> DrizzleORM
    Setup --> DrizzleORM

    APIUser --> Queries
    APITeam --> Queries

    %% Infrastructure & Configuration
    DockerCompose["docker-compose.yml"]:::infra
    NextConfig["next.config.js"]:::infra
    OpenNextConfig["open-next.config.ts"]:::infra
    WranglerConfig["wrangler.jsonc"]:::infra
    DeployYml[".github/workflows/deploy.yml"]:::infra
    TSConfig["tsconfig.json"]:::infra
    PackageJSON["package.json"]:::infra
    PostCSS["postcss.config.mjs"]:::infra

    %% External Services
    StripeWebhook["Stripe Webhooks"]:::external
    CustomerPortal["Stripe Customer Portal"]:::external

    StripeWebhook --> WebhookRoute
    DashboardPricingButton --> CustomerPortal

    %% Click Events
    click LandingLayout "https://github.com/gomolemo-k/founderfinder/blob/main/app/layout.tsx"
    click LandingPage "https://github.com/gomolemo-k/founderfinder/blob/main/app/page.tsx"
    click LandingData "https://github.com/gomolemo-k/founderfinder/blob/main/data/landingPageContent.json"
    click PricingMarketing "https://github.com/gomolemo-k/founderfinder/blob/main/app/(dashboard)/pricing/page.tsx"
    click AuthLoginPage "https://github.com/gomolemo-k/founderfinder/blob/main/app/(login)/sign-in/page.tsx"
    click AuthSignUpPage "https://github.com/gomolemo-k/founderfinder/blob/main/app/(login)/sign-up/page.tsx"
    click AuthActions "https://github.com/gomolemo-k/founderfinder/blob/main/app/(login)/actions.ts"
    click AuthSession "https://github.com/gomolemo-k/founderfinder/blob/main/lib/auth/session.ts"
    click AuthMiddlewareLib "https://github.com/gomolemo-k/founderfinder/blob/main/lib/auth/middleware.ts"
    click GlobalMiddleware "https://github.com/gomolemo-k/founderfinder/blob/main/middleware.ts"
    click CheckoutRoute "https://github.com/gomolemo-k/founderfinder/blob/main/app/api/stripe/checkout/route.ts"
    click WebhookRoute "https://github.com/gomolemo-k/founderfinder/blob/main/app/api/stripe/webhook/route.ts"
    click PaymentsActions "https://github.com/gomolemo-k/founderfinder/blob/main/lib/payments/actions.ts"
    click PaymentsStripe "https://github.com/gomolemo-k/founderfinder/blob/main/lib/payments/stripe.ts"
    click DashboardLayout "https://github.com/gomolemo-k/founderfinder/blob/main/app/(dashboard)/layout.tsx"
    click DashboardHome "https://github.com/gomolemo-k/founderfinder/blob/main/app/(dashboard)/dashboard/page.tsx"
    click GeneralPage "https://github.com/gomolemo-k/founderfinder/blob/main/app/(dashboard)/dashboard/general/page.tsx"
    click SecurityPage "https://github.com/gomolemo-k/founderfinder/blob/main/app/(dashboard)/dashboard/security/page.tsx"
    click ActivityPage "https://github.com/gomolemo-k/founderfinder/blob/main/app/(dashboard)/dashboard/activity/page.tsx"
    click ActivityLoading "https://github.com/gomolemo-k/founderfinder/blob/main/app/(dashboard)/dashboard/activity/loading.tsx"
    click DashboardPricingButton "https://github.com/gomolemo-k/founderfinder/blob/main/app/(dashboard)/pricing/submit-button.tsx"
    click APITeam "https://github.com/gomolemo-k/founderfinder/blob/main/app/api/team/route.ts"
    click UserRoute "https://github.com/gomolemo-k/founderfinder/blob/main/app/api/user/route.ts"
    click DrizzleORM "https://github.com/gomolemo-k/founderfinder/blob/main/lib/db/drizzle.ts"
    click Schema "https://github.com/gomolemo-k/founderfinder/blob/main/lib/db/schema.ts"
    click Queries "https://github.com/gomolemo-k/founderfinder/blob/main/lib/db/queries.ts"
    click Migrations "https://github.com/gomolemo-k/founderfinder/tree/main/lib/db/migrations/"
    click Seed "https://github.com/gomolemo-k/founderfinder/blob/main/lib/db/seed.ts"
    click Setup "https://github.com/gomolemo-k/founderfinder/blob/main/lib/db/setup.ts"
    click DrizzleConfig "https://github.com/gomolemo-k/founderfinder/blob/main/drizzle.config.ts"
    click DockerCompose "https://github.com/gomolemo-k/founderfinder/blob/main/docker-compose.yml"
    click NextConfig "https://github.com/gomolemo-k/founderfinder/blob/main/next.config.js"
    click OpenNextConfig "https://github.com/gomolemo-k/founderfinder/blob/main/open-next.config.ts"
    click WranglerConfig "https://github.com/gomolemo-k/founderfinder/blob/main/wrangler.jsonc"
    click DeployYml "https://github.com/gomolemo-k/founderfinder/blob/main/.github/workflows/deploy.yml"
    click TSConfig "https://github.com/gomolemo-k/founderfinder/blob/main/tsconfig.json"
    click PackageJSON "https://github.com/gomolemo-k/founderfinder/blob/main/package.json"
    click PostCSS "https://github.com/gomolemo-k/founderfinder/blob/main/postcss.config.mjs"

    %% Styles
    classDef frontend fill:#ddffdd,stroke:#333,stroke-width:1px
    classDef nextjs fill:#ddffff,stroke:#333,stroke-width:1px
    classDef external fill:#ffe0b3,stroke:#333,stroke-width:1px
    classDef infra fill:#e0e0e0,stroke:#333,stroke-width:1px
```
