# archit80/pitchup architecture

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

- Interactive diagram: https://gitdiagram.com/archit80/pitchup
- Repository: https://github.com/archit80/pitchup

## Overview

##### Project type and purpose
- This is a full-stack Next.js application called Pitch-Up for startups to pitch themselves to investors.
- It uses Next.js App Router (the app folder), Tailwind CSS for styling, Sanity as a headless CMS, NextAuth for authentication, and Sentry for error-monitoring in client, server, and edge environments.

##### File structure
- app/ : Next.js App Router.
- (root)/layout.tsx & page.tsx – global UI layout and home page
- /startup and /user route groups with dynamic pages
- app/api/auth/[...nextauth]/route.ts – authentication API
- app/api/sentry-example-api/route.ts – example server API
- app/studio/… – embedded Sanity Studio in the app
- components/ : reusable React components and a ui/ subfolder for primitives
- lib/ : application business logic (actions, utils, validation)
- hooks/ : custom React hooks (e.g. use-toast)
- sanity/ : Sanity CMS configuration, schema definitions, and helper clients
- instrumentation*.ts : Sentry configuration for client, server, and edge
- next.config.ts, tailwind.config.ts, tsconfig.json : build and framework configs
- public/ : static assets
- dist/ : compiled plugin or build artifacts (likely for Sanity Studio)

##### README for additional insights
- Confirms Next.js, Tailwind CSS, Sanity stack.

##### Main components and their relationships
a. Frontend (Next.js React App)
- Server Components & Client Components under app/ and components/
- Layout, pages, UI library
b. Backend/API (Next.js serverless functions)
- app/api/auth → NextAuth route for signin/signup/session
- app/api/sentry-example-api → example REST endpoint
c. Headless CMS (Sanity)
- sanity/lib/client.ts & write-client.ts for data reads/writes
- sanity/schemaTypes define content models (author, playlist, startup)
- Embedded Studio at app/studio/…
d. Authentication (NextAuth)
- next-auth.d.ts for types
- app/api/auth/[...nextauth]/route.ts interacts with your DB or provider
e. Monitoring (Sentry)
- instrumentation-client.ts (browser)
- instrumentation.ts (server)
- sentry.*.config.ts for edge, client, server
f. Styling & Assets
- Tailwind via tailwind.config.ts & globals.css
- public/ and fonts/ for static files

Data flows:
- UI components call either the Sanity client directly (for fetching startup data) or call internal API routes (auth, custom APIs).
- API routes may in turn call Sanity write-client or NextAuth internals.
- Errors or performance data flow to Sentry via configured instrumentation.

##### Architectural patterns & design principles
- Separation of concerns: UI in components/, business logic in lib/, data models in sanity/schemaTypes.
- Next.js App Router with server vs. client components.
- Headless CMS pattern: Sanity as external content store.
- API layer for authentication and custom backend logic.
- Observability layer with Sentry.

##### Elements
- Frontend vs. Backend vs. External services

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Next.js Application"
        subgraph "Frontend (React Components)"
            LayoutHome["Root Layout & Home Page"]:::frontend
            StartupRoutes["Startup Routes (/startup/[id] & create)"]:::frontend
            UserRoutes["User Routes (/user/[id])"]:::frontend
            SentryExamplePage["Example Sentry Page"]:::frontend
            SharedComponents["Shared React Components"]:::frontend
            UIPrimitives["UI Primitive Components"]:::frontend
            Hooks["Custom Hooks (use-toast)"]:::frontend
            GlobalStyles["Global Layout, Error & Styles"]:::frontend
        end
        subgraph "API Layer (Serverless Functions)"
            AuthAPI["Authentication API (NextAuth)"]:::backend
            CustomAPI["Custom Server API Example"]:::backend
        end
        subgraph "Data Layer & Business Logic"
            LibLogic["Business Logic Library"]:::backend
            SanityClient["Sanity Client Config & Data Layer"]:::backend
            SanitySchemas["Sanity Schema Definitions"]:::backend
        end

        LayoutHome -->|renders| SharedComponents
        SharedComponents -->|uses| UIPrimitives
        LayoutHome -->|wraps| StartupRoutes
        LayoutHome -->|wraps| UserRoutes
        LayoutHome -->|wraps| SentryExamplePage
        StartupRoutes -->|GET startups| SanityClient
        UserRoutes -->|GET user| SanityClient
        SentryExamplePage -->|calls example API| CustomAPI
        AuthAPI -->|writes/reads| SanityClient
        CustomAPI -->|writes| SanityClient
        SanityClient -->|uses schemas| SanitySchemas
        AuthAPI -->|business logic| LibLogic
        CustomAPI -->|business logic| LibLogic
        SharedComponents -->|track errors| SentryService
        FrontendUser["User Actions"]:::frontend -->|auth & data calls| AuthAPI
        FrontendUser -->|custom calls| CustomAPI
        SanityClient -->|connects to| SanityCMS
        AuthAPI -->|auth requests| AuthProvider
        CustomAPI -->|logs events| SentryService
    end

    SanityCMS[(Sanity CMS Service)]:::external
    SanityStudio["Embedded Sanity Studio"]:::external
    AuthProvider[(NextAuth Provider)]:::external
    SentryService[(Sentry Monitoring Service)]:::external

    subgraph "Legend"
        F[Frontend Components]:::frontend
        B[Backend/API]:::backend
        E[External Services]:::external
    end

    click LayoutHome "https://github.com/archit80/pitchup/blob/main/app/(root)/layout.tsx"
    click StartupRoutes "https://github.com/archit80/pitchup/blob/main/app/(root)/startup/[id]/page.tsx"
    click UserRoutes "https://github.com/archit80/pitchup/blob/main/app/(root)/user/[id]/page.tsx"
    click GlobalStyles "https://github.com/archit80/pitchup/blob/main/app/globals.css"
    click SentryExamplePage "https://github.com/archit80/pitchup/blob/main/app/sentry-example-page/page.tsx"
    click AuthAPI "https://github.com/archit80/pitchup/blob/main/app/api/auth/[...nextauth]/route.ts"
    click CustomAPI "https://github.com/archit80/pitchup/blob/main/app/api/sentry-example-api/route.ts"
    click SanityStudio "https://github.com/archit80/pitchup/blob/main/app/studio/[[...tool]]/page.tsx"
    click SharedComponents "https://github.com/archit80/pitchup/tree/main/components/"
    click UIPrimitives "https://github.com/archit80/pitchup/tree/main/components/ui/"
    click Hooks "https://github.com/archit80/pitchup/blob/main/hooks/use-toast.ts"
    click LibLogic "https://github.com/archit80/pitchup/blob/main/lib/actions.ts"
    click SanityClient "https://github.com/archit80/pitchup/blob/main/sanity/lib/client.ts"
    click SanitySchemas "https://github.com/archit80/pitchup/blob/main/sanity/schemaTypes/index.ts"

    classDef frontend fill:#D0E8FF,stroke:#0366d6
    classDef backend fill:#DFFFE0,stroke:#28a745
    classDef external fill:#FFE5B4,stroke:#C76B00
```
