# vader4k/pitch architecture

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

- Interactive diagram: https://gitdiagram.com/vader4k/pitch
- Repository: https://github.com/vader4k/pitch

## Overview

##### Project type and purpose
- This is a full-stack Next.js application (folder `app`) bootstrapped via create-next-app.
- It provides a user interface for listing and creating “startups,” user profile pages, and authentication flows.
- It integrates with NextAuth for authentication, Sanity as a headless CMS for content, and Sentry for error tracing/monitoring.

##### File structure
- Top-level “app” directory holds Next.js routes in the new App Router style:
- `app/layout.tsx`, `app/page.tsx` (global layout + homepage)
- `app/(root)/startup/*` and `app/(root)/user/*` dynamic routes for Startups and User pages
- `app/api/auth/[...nextauth]/route.ts` for NextAuth API route
- `app/studio/[[...tool]]/page.tsx` for embedding the Sanity Studio in-app
- `components/` holds reusable React components and a `components/ui/` subfolder with atomic UI building blocks.
- `lib/` contains shared utilities, validation, and action handlers.
- `hooks/` holds custom React hooks (e.g., `use-toast`).
- `sanity/` directory holds the Sanity schema, client configuration, queries, and type generation.
- Configuration files:
- `next.config.ts`, `tsconfig.json`, `tailwind.config.ts`, `postcss.config.mjs`
- Sentry configs: `sentry.client.config.ts`, `sentry.server.config.ts`, etc.

##### README for additional insights
- Confirms Next.js App Router use, font optimization, development setup, and suggests deployment on Vercel.

##### Detailed capture of essential elements
- Shared `lib/` and `hooks/` modules as utilities accessible from both server and client code.
- Tailwind CSS pipeline (PostCSS → CSS) as part of the build process.
- Where the Sentry SDK is initialized (in `instrumentation.ts`) and which sentry config file applies to client vs. server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Browser"
        Browser["Browser"]:::external
    end

    subgraph "Next.js App (Frontend)"
        subgraph "App Root"
            Layout["layout.tsx"]:::frontend
            GlobalError["global-error.tsx"]:::frontend
            GlobalStyles["globals.css"]:::frontend
        end

        subgraph "App Router (Server Components)"
            Homepage["page.tsx (root)"]:::frontend
            RootLayout["layout.tsx (root)"]:::frontend
            StartupList["[id]/page.tsx"]:::frontend
            StartupCreate["create/page.tsx"]:::frontend
            UserProfile["[...id]/page.tsx"]:::frontend
            SanityStudio["studio/[[...tool]]/page.tsx"]:::frontend
        end

        subgraph "Components (Client)"
            Navbar["Navbar.tsx"]:::frontend
            StartupCard["StartupCard.tsx"]:::frontend
            StartupForm["StartupForm.tsx"]:::frontend
            UserStartups["UserStartups.tsx"]:::frontend
            Ping["Ping.tsx"]:::frontend
            SearchForm["SearchForm.tsx"]:::frontend
            SearchFormReset["SearchFormReset.tsx"]:::frontend
            View["View.tsx"]:::frontend

            subgraph "UI Primitives"
                Avatar["avatar.tsx"]:::frontend
                Button["button.tsx"]:::frontend
                Input["input.tsx"]:::frontend
                Textarea["textarea.tsx"]:::frontend
                Skeleton["skeleton.tsx"]:::frontend
                Toast["toast.tsx"]:::frontend
                Toaster["toaster.tsx"]:::frontend
            end
        end

        subgraph "Utilities & Hooks"
            Actions["actions.ts"]:::utility
            Utils["utils.ts"]:::utility
            Validation["validation.ts"]:::utility
            ToastHook["use-toast.ts"]:::utility
        end

        Fonts["fonts/*"]:::frontend
        Public["public/*"]:::frontend
    end

    subgraph "API Layer"
        NextAuthRoute["[...nextauth]/route.ts"]:::backend
    end

    subgraph "Sanity CMS"
        subgraph "Studio UI"
            SanityStudioUI["Sanity Studio UI"]:::external
        end
        subgraph "Content Lake"
            SanityContent["Sanity Content Lake"]:::external
        end
        subgraph "Client & Schema"
            ClientConfig["sanity/lib/client.ts"]:::backend
            Live["sanity/lib/live.ts"]:::backend
            WriteClient["sanity/lib/write-client.ts"]:::backend
            QueriesLib["sanity/lib/queries.ts"]:::backend
            SchemaTypes["schemaTypes/index.ts"]:::backend
            SanityConfig["sanity.config.ts"]:::backend
            SanityCLI["sanity.cli.ts"]:::backend
            Structure["structure.ts"]:::backend
            Env["env.ts"]:::backend
            Types["types.ts"]:::backend
            Extract["extract.json"]:::backend
        end
    end

    subgraph "External Services"
        Sentry["Sentry"]:::external
        Vercel["Vercel"]:::external
        OAuthDB["OAuth Providers/Database"]:::external
    end

    Browser -->|"HTTP/SSR/SSG"| Homepage
    Browser -->|"HTTP/SSR/SSG"| StartupList
    Browser -->|"HTTP/SSR/SSG"| StartupCreate
    Browser -->|"HTTP/SSR/SSG"| UserProfile
    Browser -->|"Embed CMS"| SanityStudio

    Homepage -->|uses| RootLayout
    StartupList -->|uses| RootLayout
    StartupCreate -->|uses| RootLayout
    UserProfile -->|uses| RootLayout
    SanityStudio -->|uses| RootLayout

    Homepage -->|fetch| NextAuthRoute
    StartupList -->|fetch| NextAuthRoute
    StartupCreate -->|fetch| NextAuthRoute
    UserProfile -->|fetch| NextAuthRoute

    NextAuthRoute -->|auth CRUD| OAuthDB
    NextAuthRoute -->|CRUD| ClientConfig

    ClientConfig -->|queries| SanityContent
    Live -->|realtime| SanityContent
    WriteClient -->|write| SanityContent
    QueriesLib -->|read| SanityContent

    Homepage -.->|error| Sentry
    StartupList -.->|error| Sentry
    NextAuthRoute -.->|error| Sentry

    Browser -->|"deploy"| Vercel

    classDef frontend fill:#cce5ff,stroke:#3399ff,color:#000
    classDef backend fill:#d5f5e3,stroke:#28a745,color:#000
    classDef external fill:#ffe5cc,stroke:#ff9933,color:#000
    classDef utility fill:#e5ccff,stroke:#9933ff,color:#000

    click Layout "https://github.com/vader4k/pitch/blob/master/app/layout.tsx"
    click GlobalError "https://github.com/vader4k/pitch/blob/master/app/global-error.tsx"
    click GlobalStyles "https://github.com/vader4k/pitch/blob/master/app/globals.css"
    click Homepage "https://github.com/vader4k/pitch/blob/master/app/(root)/page.tsx"
    click RootLayout "https://github.com/vader4k/pitch/blob/master/app/(root)/layout.tsx"
    click StartupList "https://github.com/vader4k/pitch/blob/master/app/(root)/startup/[id]/page.tsx"
    click StartupCreate "https://github.com/vader4k/pitch/blob/master/app/(root)/startup/create/page.tsx"
    click UserProfile "https://github.com/vader4k/pitch/blob/master/app/(root)/user/[...id]/page.tsx"
    click NextAuthRoute "https://github.com/vader4k/pitch/blob/master/app/api/auth/[...nextauth]/route.ts"
    click SanityStudio "https://github.com/vader4k/pitch/blob/master/app/studio/[[...tool]]/page.tsx"
    click ClientConfig "https://github.com/vader4k/pitch/blob/master/sanity/lib/client.ts"
    click Live "https://github.com/vader4k/pitch/blob/master/sanity/lib/live.ts"
    click WriteClient "https://github.com/vader4k/pitch/blob/master/sanity/lib/write-client.ts"
    click QueriesLib "https://github.com/vader4k/pitch/blob/master/sanity/lib/queries.ts"
    click SchemaTypes "https://github.com/vader4k/pitch/blob/master/sanity/schemaTypes/index.ts"
    click SanityConfig "https://github.com/vader4k/pitch/blob/master/sanity.config.ts"
    click SanityCLI "https://github.com/vader4k/pitch/blob/master/sanity.cli.ts"
    click Structure "https://github.com/vader4k/pitch/blob/master/sanity/structure.ts"
    click Env "https://github.com/vader4k/pitch/blob/master/sanity/env.ts"
    click Types "https://github.com/vader4k/pitch/blob/master/sanity/types.ts"
    click Extract "https://github.com/vader4k/pitch/blob/master/sanity/extract.json"
```
