# owengretzinger/hackmate architecture

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

- Interactive diagram: https://gitdiagram.com/owengretzinger/hackmate
- Repository: https://github.com/owengretzinger/hackmate

## Overview

##### Main System Components

a. Client Layer:
- Next.js Frontend (located in /src/app)
- Key pages: inspiration, pitch, readme, projects, architecture
- UI Components (in /src/components)

b. API Layer:
- tRPC API routes (/src/server/api/routers)
- NextAuth authentication endpoints
- API handlers for different features

c. Server Layer:
- tRPC server implementation
- Authentication services
- Database operations

d. External Services:
- Google Cloud Vertex AI
- Google Authentication
- Database (likely PostgreSQL based on Drizzle ORM usage)

**[Client Layer]**
- ↕
**[API Layer]**
- ↕
**[Server Layer]**
- ↕
**[External Services]**

##### Component Relationships

Key interactions:

a. Frontend to API:
- tRPC queries/mutations for:
- Project inspiration (/routers/inspiration.ts)
- README generation (/routers/readme.ts)
- Pitch creation (/routers/pitch.ts)
- User projects (/routers/user-projects.ts)

b. Authentication Flow:
- NextAuth integration with Google
- Session management
- Protected routes

c. AI Integration:
- Vertex AI service connections
- AI response processing
- Template management

##### Technical Details

Implementation specifics:

a. Database Schema:
- Drizzle ORM models (/server/db/schema.ts)
- Relationships between entities

b. API Routes:
- tRPC router configuration
- Authentication endpoints
- Protected vs public routes

c. AI Services:
- Vertex AI integration points
- Template processing
- Response handling

##### Notes for Implementation

- Clear labels for all components
- Both synchronous and asynchronous operations
- Security boundaries
- Scalable components

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[Frontend App]
        Pages["Pages"]
        UI["UI Components"]:::ui
        Templates["README Templates"]:::templates
        
        Pages --> |Contains| IP["Inspiration Page"]:::page
        Pages --> |Contains| PP["Pitch Page"]:::page
        Pages --> |Contains| RP["README Page"]:::page
        Pages --> |Contains| PRJ["Projects Page"]:::page
        Pages --> |Contains| AP["Architecture Page"]:::page
        
        FE --> Pages
        FE --> UI
        FE --> Templates
    end

    subgraph API
        TR["tRPC Router"]:::api
        AE["Auth Endpoints"]:::api
        TH["tRPC Handler"]:::api

        IR["Inspiration Router"]:::router
        RR["README Router"]:::router
        AR["Architecture Router"]:::router
        PR["Pitch Router"]:::router
        UPR["User Projects Router"]:::router

        TR --> IR
        TR --> RR
        TR --> AR
        TR --> PR
        TR --> UPR
    end

    subgraph Server
        TS["tRPC Server"]:::server
        AS["Auth Service"]:::server
        DO["Database Operations"]:::server
        DS["Database Schema"]:::server

        TS --> AS
        TS --> DO
        DO --> DS
    end

    subgraph External
        VAI["Vertex AI"]:::external
        GA["Google Auth"]:::external
        DB[(PostgreSQL)]:::database
    end

    Client --> API
    API --> Server
    Server --> External

    %% Click events for component mapping
    click FE "https://github.com/owengretzinger/hackmate/tree/main/src/app"
    click IP "https://github.com/owengretzinger/hackmate/blob/main/src/app/inspiration/page.tsx"
    click PP "https://github.com/owengretzinger/hackmate/blob/main/src/app/pitch/page.tsx"
    click RP "https://github.com/owengretzinger/hackmate/blob/main/src/app/readme/page.tsx"
    click PRJ "https://github.com/owengretzinger/hackmate/blob/main/src/app/projects/page.tsx"
    click AP "https://github.com/owengretzinger/hackmate/blob/main/src/app/architecture/page.tsx"
    click UI "https://github.com/owengretzinger/hackmate/tree/main/src/components/ui"
    click Templates "https://github.com/owengretzinger/hackmate/tree/main/src/components/readme-templates"
    click TR "https://github.com/owengretzinger/hackmate/tree/main/src/server/api/routers"
    click AE "https://github.com/owengretzinger/hackmate/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click TH "https://github.com/owengretzinger/hackmate/blob/main/src/app/api/trpc/[trpc]/route.ts"
    click TS "https://github.com/owengretzinger/hackmate/blob/main/src/server/api/trpc.ts"
    click AS "https://github.com/owengretzinger/hackmate/blob/main/src/server/auth/index.ts"
    click DO "https://github.com/owengretzinger/hackmate/blob/main/src/server/db/index.ts"
    click DS "https://github.com/owengretzinger/hackmate/blob/main/src/server/db/schema.ts"
    click IR "https://github.com/owengretzinger/hackmate/blob/main/src/server/api/routers/inspiration.ts"
    click RR "https://github.com/owengretzinger/hackmate/blob/main/src/server/api/routers/readme.ts"
    click AR "https://github.com/owengretzinger/hackmate/blob/main/src/server/api/routers/architecture.ts"
    click PR "https://github.com/owengretzinger/hackmate/blob/main/src/server/api/routers/pitch.ts"
    click UPR "https://github.com/owengretzinger/hackmate/blob/main/src/server/api/routers/user-projects.ts"
    click VAI "https://github.com/owengretzinger/hackmate/blob/main/src/utils/vertex-ai.ts"

    %% Styling
    classDef page fill:#2563eb,color:white
    classDef ui fill:#3b82f6,color:white
    classDef templates fill:#60a5fa,color:white
    classDef api fill:#059669,color:white
    classDef router fill:#10b981,color:white
    classDef server fill:#ca8a04,color:white
    classDef external fill:#9333ea,color:white
    classDef database fill:#4b5563,color:white

    %% Legend
    subgraph Legend
        L1[Frontend Components]:::page
        L2[API Components]:::api
        L3[Server Components]:::server
        L4[External Services]:::external
        L5[(Database)]:::database
    end
```
