# curtainteddy/lspp-swipetank architecture

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

- Interactive diagram: https://gitdiagram.com/curtainteddy/lspp-swipetank
- Repository: https://github.com/curtainteddy/lspp-swipetank

## Overview

##### Project Type and Purpose
- This is a full-stack web application built on Next.js 15 with an App Router, TypeScript, and Tailwind CSS.
- It provides an AI-powered “Tinder for startups and investors” platform: entrepreneurs create and analyze projects, investors browse/swipe projects, and both parties communicate via real-time messaging.

##### File Structure
- Top-level “app/” directory uses Next.js App Router: nested folders for pages and route groups (e.g., `(auth)`, `api`, `browse`, `dashboard`, etc.).
- Under “app/api/” you have REST-style serverless functions organized by domain (analysis, dashboard, investments, messages, projects).
- “components/” contains UI primitives (shadcn/ui) and feature modules (landing, browse, dashboard, analytics).
- “lib/” holds helpers (auth, Prisma client, utilities).
- “prisma/” defines your PostgreSQL schema, migrations, and seed script.
- “contexts/” and “hooks/” manage client-side state and utilities (user context, mobile detection, toast).
- Config files: `middleware.ts` for auth, `next.config.mjs`, Tailwind and PostCSS configs.

##### README for Additional Insights
- Frontend: Next.js, React 18, Radix UI, Framer Motion, Recharts, React Hook Form + Zod.
- Backend: Next.js API routes, Prisma ORM (PostgreSQL), Clerk for auth, Google Gemini for AI, Svix for webhooks.
- Design system: custom shadcn/ui, dark/light themes, responsive design.

a. Main Components
- **Client (Browser/Mobile)**: React-based UI, App Router, Context Providers.
- **Next.js Server**: SSR/SSG, App Router, API Routes (analysis, projects, messages, investments, dashboard).
- **Authentication Service**: Clerk (external).
- **AI Service**: Google Gemini API.
- **Database**: PostgreSQL accessed via Prisma ORM.
- **Webhooks**: Svix for file handling or events.
- **External Integrations**: Vercel (hosting), optional SMS/email, analytics/monitoring.

b. Relationships and Data Flows
- User ↔ Browser UI ↔ Next.js (SSR/CSR)
- UI calls Next.js API routes → business logic in route handlers → Prisma client → PostgreSQL
- Certain API routes call Google Gemini for analysis
- Clerk handles sign-in/up flows and JWT/session management; Next.js middleware protects routes
- Real-time messaging is implemented via RESTful message endpoints (could be extended to WebSockets)
- Webhooks from external services (Svix) funnel into specific API routes

c. Architectural Patterns
- **Modular Routing**: Domain-based grouping of API routes.
- **App Router Layouts**: Shared layouts (app/layout.tsx) with providers and navigation.
- **Context-based State**: React Context for user/session.
- **ORM Layer**: Prisma as single DB access point.
- **Separation of Concerns**: UI components vs. API handlers vs. business logic vs. data layer.

d. Key Technologies & Frameworks
- Next.js 15, React 18, TypeScript 5
- Tailwind CSS, Framer Motion, Recharts
- Prisma 6 + PostgreSQL
- Clerk Authentication
- Google Gemini AI
- Svix Webhooks

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Browser UI)" 
        classDef frontend fill:#E3F2FD,stroke:#42A5F5,stroke-width:2px
        subgraph "Layout & Theme"
            Layout["Layout: app/layout.tsx"]:::frontend
            PageHome["Home Page: app/page.tsx"]:::frontend
            AppLayout["App Layout: components/layout/app-layout.tsx"]:::frontend
            ThemeProvider["Theme Provider: components/theme-provider.tsx"]:::frontend
        end
        subgraph "App Router Pages"
            Browse["Browse: app/browse/page.tsx"]:::frontend
            DashboardPg["Dashboard: app/dashboard/page.tsx"]:::frontend
            AnalyticsPg["Analytics: app/analytics/page.tsx"]:::frontend
            InvestmentsPg["Investments: app/investments/page.tsx"]:::frontend
            MessagesPg["Messages: app/messages/page.tsx"]:::frontend
            ProjectsPg["Projects: app/projects/page.tsx"]:::frontend
            ProjectEdit["Edit Project: app/projects/[id]/edit/page.tsx"]:::frontend
            ProjectNew["New Project: app/projects/new/page.tsx"]:::frontend
            Portfolio["Portfolio: app/portfolio/page.tsx"]:::frontend
            Profile["Profile: app/profile/page.tsx"]:::frontend
            Settings["Settings: app/settings/page.tsx"]:::frontend
            Saved["Saved Projects: app/saved-projects/page.tsx"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend (Next.js API)" 
        classDef api fill:#FFF3E0,stroke:#FB8C00,stroke-width:2px
        subgraph "Analysis Service"
            AnalProj["/api/analysis/project\nroute.ts"]:::api
            AnalClear["/api/analysis/clear\nroute.ts"]:::api
        end
        subgraph "Projects Domain"
            APIProjects["/api/projects/route.ts"]:::api
            APIProjId["/api/projects/[id]/route.ts"]:::api
            APIMy["/api/projects/my/route.ts"]:::api
        end
        subgraph "Investments Domain"
            APIInv["/api/investments/route.ts"]:::api
            APIInvCreate["/api/investments/create/route.ts"]:::api
        end
        subgraph "Messaging Domain"
            APIMsg["/api/messages/route.ts"]:::api
            APIMsgConv["/api/messages/[conversationId]/route.ts"]:::api
        end
        subgraph "Dashboard Data"
            APIDash["/api/dashboard/route.ts"]:::api
        end
        classDef auth fill:#E8F5E9,stroke:#43A047,stroke-width:2px
        AuthMW["Middleware: middleware.ts"]:::auth
        LibAuth["Auth Helpers: lib/auth.ts"]:::auth
        LibAuthHelpers["Auth Utils: lib/auth-helpers.ts"]:::auth
        classDef data fill:#F3E5F5,stroke:#8E24AA,stroke-width:2px
        LibPrisma["Prisma Client: lib/prisma.ts"]:::data
    end

    %% Data Layer & Database
    subgraph "Data Layer & DB"
        PrismaSchema["Schema: prisma/schema.prisma"]:::data
        Migrations["Migrations: prisma/migrations/"]:::data
        Seed["Seed Script: prisma/seed.ts"]:::data
        classDef dba fill:#E0F7FA,stroke:#00ACC1,stroke-width:2px
        PostgreSQL[(PostgreSQL)]:::dba
    end

    %% External Services
    subgraph "External Services"
        classDef external fill:#FFEBEE,stroke:#E53935,stroke-width:2px
        Clerk[(Clerk Auth)]:::external
        Gemini[(Google Gemini API)]:::external
        Svix[(Svix Webhooks)]:::external
        Vercel[(Vercel Hosting)]:::external
    end

    %% Connections
    Browse -->|"requests"| APIProjects
    ProjectsPg -->|"requests"| APIProjects
    ProjectEdit -->|"requests"| APIProjId
    ProjectNew -->|"requests"| APIProjects
    APIMy -->|"requests from UI"| APIMy
    InvestmentsPg -->|"requests"| APIInv
    APIInvCreate -->|"requests"| APIInvCreate
    MessagesPg -->|"requests"| APIMsg
    APIMsg -->|"fetch conversation"| APIMsgConv
    AnalyticsPg -->|"analysis requests"| AnalProj
    AnalProj -->|"uses"| Gemini
    AnalClear -->|"uses"| Gemini
    DashboardPg -->|"dashboard data"| APIDash

    %% Auth Flow
    Layout -->|uses| AuthMW
    AuthMW -->|verifies| Clerk
    APIDash -->|protected by| AuthMW

    %% Data Flow
    APIProjects -->|"ORM calls"| LibPrisma
    APIProjId -->|"ORM calls"| LibPrisma
    APIMy -->|"ORM calls"| LibPrisma
    APIInv -->|"ORM calls"| LibPrisma
    APIInvCreate -->|"ORM calls"| LibPrisma
    APIMsg -->|"ORM calls"| LibPrisma
    APIMsgConv -->|"ORM calls"| LibPrisma
    APIDash -->|"ORM calls"| LibPrisma
    LibPrisma -->|"queries"| PostgreSQL
    PrismaSchema --> PostgreSQL
    Migrations --> PostgreSQL
    Seed --> PostgreSQL

    %% Webhooks
    Svix -->|posts events| APIDash

    %% Deployment
    Vercel --> Frontend
    Vercel --> Backend
    Vercel --> PostgreSQL

    %% Click Events
    click Layout "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/layout.tsx"
    click PageHome "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/page.tsx"
    click AppLayout "https://github.com/curtainteddy/lspp-swipetank/blob/main/components/layout/app-layout.tsx"
    click ThemeProvider "https://github.com/curtainteddy/lspp-swipetank/blob/main/components/theme-provider.tsx"
    click Browse "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/browse/page.tsx"
    click DashboardPg "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/dashboard/page.tsx"
    click AnalyticsPg "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/analytics/page.tsx"
    click InvestmentsPg "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/investments/page.tsx"
    click MessagesPg "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/messages/page.tsx"
    click ProjectsPg "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/projects/page.tsx"
    click ProjectEdit "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/projects/[id]/edit/page.tsx"
    click ProjectNew "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/projects/new/page.tsx"
    click Portfolio "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/portfolio/page.tsx"
    click Profile "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/profile/page.tsx"
    click Settings "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/settings/page.tsx"
    click Saved "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/saved-projects/page.tsx"
    click AnalProj "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/api/analysis/project/route.ts"
    click AnalClear "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/api/analysis/clear/route.ts"
    click APIProjects "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/api/projects/route.ts"
    click APIProjId "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/api/projects/[id]/route.ts"
    click APIMy "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/api/projects/my/route.ts"
    click APIInv "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/api/investments/route.ts"
    click APIInvCreate "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/api/investments/create/route.ts"
    click APIMsg "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/api/messages/route.ts"
    click APIMsgConv "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/api/messages/[conversationId]/route.ts"
    click APIDash "https://github.com/curtainteddy/lspp-swipetank/blob/main/app/api/dashboard/route.ts"
    click AuthMW "https://github.com/curtainteddy/lspp-swipetank/blob/main/middleware.ts"
    click LibAuth "https://github.com/curtainteddy/lspp-swipetank/blob/main/lib/auth.ts"
    click LibAuthHelpers "https://github.com/curtainteddy/lspp-swipetank/blob/main/lib/auth-helpers.ts"
    click LibPrisma "https://github.com/curtainteddy/lspp-swipetank/blob/main/lib/prisma.ts"
    click PrismaSchema "https://github.com/curtainteddy/lspp-swipetank/blob/main/prisma/schema.prisma"
    click Migrations "https://github.com/curtainteddy/lspp-swipetank/tree/main/prisma/migrations/"
    click Seed "https://github.com/curtainteddy/lspp-swipetank/blob/main/prisma/seed.ts"

    %% Styles
    class Frontend frontend
    class Backend api
    class DataLayer data
    class Database dba
    class External external
```
