# arjunhg/peerpath architecture

> Architecture diagram of the GitHub repository arjunhg/peerpath, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arjunhg/peerpath
- Repository: https://github.com/arjunhg/peerpath

## Overview

##### Project type and purpose
- This is a full-stack Next.js application that provides an AI-powered chat and community matching experience. Users can sign up, join communities, set learning goals, and chat with AI or matched partners. The codebase leverages:
- Next.js App Router (“app/…” directory) for both frontend and server actions
- Drizzle ORM (db/schema.ts + db/index.ts) for the SQL database
- A custom “app/server” layer to expose domain-specific routes (community, matches, conversations, learning goals)
- Tambo (via NEXT_PUBLIC_TAMBO_API_KEY) as an external AI service

##### File structure
- Top-level “app” directory:
- app/page.tsx, app/layout.tsx – root layout and entry point
- app/(main)/… – main authenticated area with nested routes (dashboard, communities, chat)
- app/api/[[...route]]/route.ts – catch-all API proxy endpoint
- app/server/*.ts – server-only route implementations and auth middleware
- app/sign-in, app/sign-up – authentication pages
- “components” directory: reusable UI pieces, grouped by feature (chat, communities, dashboard, landing, layout, providers, tambo integration, UI primitives)
- “hooks”: custom React hooks (use-conversations, use-communities, etc.) that encapsulate API interactions
- “lib”: client- and server-side utilities (API client, DB helpers, AI helpers, user-utils)
- “db”: schema, seed script, Drizzle config
- “proxy.ts”: local development proxy for the Tambo API
- Configuration files: next.config.ts, tsconfig.json, bun.lock, etc.

##### README for additional insights
- Boilerplate from create-next-app, configured for Next.js font optimization and environment variable for Tambo

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Tier
    subgraph "Frontend Tier"
        direction TB
        Browser["User's Web Browser"]:::external
        NextRouter["Next.js App Router"]:::frontend
        ReactUI["UI Components"]:::frontend
        QueryHooks["React Query & Hooks"]:::frontend
        APIClient["API Client"]:::frontend
        TamboUI["Tambo UI Components"]:::frontend
    end

    %% Server/API Tier
    subgraph "API / Server Tier"
        direction TB
        APIProxy["API Proxy Endpoint"]:::backend
        AuthMW["Auth Middleware"]:::backend
        DomainRoutes["Domain-Specific Routes"]:::backend
        DBHelpers["DB Helpers"]:::backend
    end

    %% Persistence & External Tier
    subgraph "Persistence & External"
        direction TB
        Database["SQL Database (Drizzle ORM)"]:::db
        AIUtils["AI Service Utils"]:::external
        DevProxy["Tambo Dev Proxy"]:::external
        TamboAPI["Tambo AI Service"]:::external
    end

    %% Flows
    Browser -->|"loads pages"| NextRouter
    NextRouter -->|"renders UI Components"| ReactUI
    ReactUI -->|"use hooks"| QueryHooks
    QueryHooks -->|"calls API client"| APIClient
    APIClient -->|"requests /api/*"| APIProxy
    APIProxy -->|"auth check"| AuthMW
    AuthMW -->|"route to handlers"| DomainRoutes
    DomainRoutes -->|"DB operations"| DBHelpers
    DBHelpers -->|"queries"| Database
    DomainRoutes -->|"AI requests"| AIUtils
    ReactUI -->|"invokes AI UI"| TamboUI
    TamboUI -->|"client AI calls"| AIUtils
    AIUtils -->|"proxy via dev"| DevProxy
    DevProxy -->|"calls"| TamboAPI

    %% Click Events
    click NextRouter "https://github.com/arjunhg/peerpath/blob/master/app/page.tsx"
    click ReactUI "https://github.com/arjunhg/peerpath/blob/master/components/chat/chat-interface.tsx"
    click QueryHooks "https://github.com/arjunhg/peerpath/blob/master/components/providers/query-provider.tsx"
    click APIClient "https://github.com/arjunhg/peerpath/blob/master/lib/api-client.ts"
    click TamboUI "https://github.com/arjunhg/peerpath/blob/master/components/tambo/copilot-panel.tsx"
    click APIProxy "https://github.com/arjunhg/peerpath/blob/master/app/api/[[...route]]/route.ts"
    click AuthMW "https://github.com/arjunhg/peerpath/blob/master/app/server/middleware/auth-middleware.ts"
    click DomainRoutes "https://github.com/arjunhg/peerpath/blob/master/app/server/community-routes.ts"
    click DBHelpers "https://github.com/arjunhg/peerpath/blob/master/lib/db-helpers.ts"
    click Database "https://github.com/arjunhg/peerpath/blob/master/db/index.ts"
    click AIUtils "https://github.com/arjunhg/peerpath/blob/master/lib/ai.ts"
    click DevProxy "https://github.com/arjunhg/peerpath/blob/master/proxy.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef backend fill:#E6F4EA,stroke:#28A745,color:#28A745;
    classDef db fill:#FDE8D0,stroke:#FFA31A,color:#FFA31A;
    classDef external fill:#F4E1FF,stroke:#6F42C1,color:#6F42C1
```
