# joincalldotco/call architecture

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

- Interactive diagram: https://gitdiagram.com/joincalldotco/call
- Repository: https://github.com/joincalldotco/call

## Overview

##### Project Type & Purpose
- Open-source, AI-native, web-based video conferencing platform
- Monorepo with two main applications (web frontend, server backend) and shared packages

##### High-Level Components
A. Clients
- Browser / PWA on desktop & mobile
- Consumes Next.js app, connects via HTTP(S) & WebSockets
B. Frontend (“apps/web”)
- Next.js 15 (App Router)
- Tailwind CSS, shadcn/ui components
- React Query for server state, Zustand for shared state
- Mediasoup client for real-time media (over WebRTC)
- API routes (Next.js route handlers) for waitlist & other SSR endpoints
C. Backend API (“apps/server”)
- Hono web framework (HTTP + WebSocket handlers)
- Express-style routes: auth, calls, contacts, notifications, room, teams, thoughts
- Mediasoup SFU integration (media relay server)
- Redis (caching, rate limiting)
- Better Auth for authentication (JWT sessions)
- Email notifications (Resend API)
D. Database
- PostgreSQL (Docker-managed)
- Drizzle ORM for schema, migrations, queries
E. Shared Packages (“packages/…”)
- @call/auth – token extraction & auth-client
- @call/db – Drizzle config, schema, type definitions
- @call/ui – shadcn/ui component library
- ESLint & TypeScript configs
F. Infrastructure
- Turborepo (monorepo orchestration)
- Docker Compose (PostgreSQL service)
- Vercel for frontend deployment
- CI/CD via GitHub Actions (implied)

##### Interactions & Data Flow
1. User opens the Next.js web app (HTTP GET → Vercel CDN)
2. Frontend initializes React Query / Zustand for session and data
3. API calls from browser → Backend Hono server (HTTP REST)
– Authentication endpoints → Better Auth
– CRUD endpoints → PostgreSQL via Drizzle ORM
– Rate limiting → Redis
4. WebSocket (or Socket.IO) connections for real-time events
– Signaling messages for WebRTC setup (via Hono)
– Media streams peer-to-SFU (mediasoup-server.ts)
5. SFU (Mediasoup):
– Receives audio/video from participants
– Forwards media streams appropriately
6. Notifications & Emails
– Backend queues notifications → Email service (Resend)
– Frontend subscribes to notification streams

##### Architectural Patterns & Principles
- Monorepo with clear workspace boundaries (apps vs. packages)
- Separation of concerns:
- Frontend (UI, state management, media client)
- Backend (API, business logic, SFU, cache)
- Shared (auth, db, UI components)
- Modular routing (Hono) & Next.js App Router
- Scalable SFU pattern (Mediasoup) for video conferencing
- Rate limiting & caching with Redis
- Type-safe throughout (TypeScript, Drizzle, shared types)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Browser["Browser/PWA"]:::client
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        NextApp["Next.js 15 App Router"]:::frontend
        APIroutes["API Routes (waitlist)"]:::frontend
        Tailwind["Tailwind CSS Config"]:::frontend
        UIlib["shadcn/ui Components"]:::frontend
        Providers["React Query & Zustand Providers"]:::frontend
        MedClient["Mediasoup Client (WebRTC)"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        Hono["Hono Server (HTTP & WebSocket)"]:::backend
        AuthEP["Auth Endpoints"]:::backend
        CallsEP["Calls Endpoints"]:::backend
        ContactsEP["Contacts Endpoints"]:::backend
        NotEP["Notifications Endpoints"]:::backend
        RoomEP["Room Endpoints"]:::backend
        TeamsEP["Teams Endpoints"]:::backend
        ThoughtsEP["Thoughts Endpoints"]:::backend
        WSHandlers["WebSocket Handlers"]:::backend
    end

    %% Media Layer
    subgraph "Media Layer"
        SFU["Mediasoup SFU (Server)"]:::media
    end

    %% Data Layer
    subgraph "Data Layer"
        Redis["Redis (Cache & Rate Limit)"]:::data
        Postgres["PostgreSQL (Drizzle ORM)"]:::data
    end

    %% External Services
    subgraph "External Services"
        AuthService["Better Auth Provider"]:::external
        EmailService["Resend Email API"]:::external
        CDN["Vercel CDN"]:::external
    end

    %% Orchestration & Infra
    subgraph "Orchestration & Infra"
        Turbo["Turborepo & Workspaces"]:::orchestration
        ESLintCfg["ESLint Config"]:::orchestration
        TSCfg["TS Config"]:::orchestration
        Docker["Docker Compose"]:::orchestration
        GHactions["GitHub Actions (CI/CD)"]:::orchestration
        VercelCfg["Vercel Config"]:::orchestration
    end

    %% Connections
    Browser -->|"HTTP GET"| CDN
    Browser -->|"HTTPS"| NextApp
    NextApp -->|"routes to"| APIroutes
    NextApp -->|"uses"| Tailwind
    NextApp -->|"renders"| UIlib
    NextApp -->|"wraps"| Providers
    NextApp -->|"invokes"| MedClient
    Browser -->|"<dashed>WebSocket"| WSHandlers
    NextApp -->|"HTTP REST"| Hono
    APIroutes --> Hono

    Hono --> AuthEP
    Hono --> CallsEP
    Hono --> ContactsEP
    Hono --> NotEP
    Hono --> RoomEP
    Hono --> TeamsEP
    Hono --> ThoughtsEP
    Hono --> WSHandlers

    AuthEP -->|"auth checks"| AuthService
    CallsEP -->|"SQL"| Postgres
    CallsEP -->|"cache"| Redis
    WSHandlers -->|"signal"| SFU
    SFU <-->|"WebRTC media"| MedClient
    SFU -->|"media relay"| SFU
    Hono -->|"cache & rate"| Redis
    Hono -->|"queries"| Postgres
    NotEP -->|"email queue"| EmailService

    %% Click Events
    click Browser "https://github.com/joincalldotco/call/tree/main/apps/web"
    click NextApp "https://github.com/joincalldotco/call/tree/main/apps/web/app"
    click APIroutes "https://github.com/joincalldotco/call/tree/main/apps/web/app/api/waitlist"
    click Tailwind "https://github.com/joincalldotco/call/blob/main/apps/web/tailwind.config.ts"
    click UIlib "https://github.com/joincalldotco/call/tree/main/packages/ui"
    click Providers "https://github.com/joincalldotco/call/blob/main/apps/web/components/providers/theme-and-query.tsx"
    click Providers "https://github.com/joincalldotco/call/blob/main/apps/web/components/providers/session.tsx"
    click MedClient "https://github.com/joincalldotco/call/blob/main/apps/web/hooks/useMediasoupClient.ts"
    click Hono "https://github.com/joincalldotco/call/blob/main/apps/server/src/index.ts"
    click WSHandlers "https://github.com/joincalldotco/call/tree/main/apps/server/src/routes"
    click AuthEP "https://github.com/joincalldotco/call/blob/main/apps/server/src/routes/auth/index.ts"
    click CallsEP "https://github.com/joincalldotco/call/blob/main/apps/server/src/routes/calls/index.ts"
    click ContactsEP "https://github.com/joincalldotco/call/blob/main/apps/server/src/routes/contacts/index.ts"
    click NotEP "https://github.com/joincalldotco/call/blob/main/apps/server/src/routes/notifications/index.ts"
    click RoomEP "https://github.com/joincalldotco/call/blob/main/apps/server/src/routes/room/index.ts"
    click TeamsEP "https://github.com/joincalldotco/call/blob/main/apps/server/src/routes/teams/index.ts"
    click ThoughtsEP "https://github.com/joincalldotco/call/blob/main/apps/server/src/routes/thoughts/index.ts"
    click SFU "https://github.com/joincalldotco/call/blob/main/apps/server/src/mediasoup-server.ts"
    click Redis "https://github.com/joincalldotco/call/blob/main/apps/server/src/config/redis.ts"
    click AuthService "https://github.com/joincalldotco/call/tree/main/packages/auth"
    click Postgres "https://github.com/joincalldotco/call/tree/main/packages/db"
    click ESLintCfg "https://github.com/joincalldotco/call/tree/main/packages/eslint-config"
    click TSCfg "https://github.com/joincalldotco/call/tree/main/packages/typescript-config"
    click Turbo "https://github.com/joincalldotco/call/blob/main/turbo.json"
    click Docker "https://github.com/joincalldotco/call/blob/main/docker-compose.yml"
    click VercelCfg "https://github.com/joincalldotco/call/blob/main/vercel.json"
    click GHactions "https://github.com/joincalldotco/call/blob/main/.github"

    %% Styles
    classDef client fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef frontend fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef backend fill:#c8e6c9,stroke:#43a047,color:#1b5e20
    classDef media fill:#ffe0b2,stroke:#fb8c00,color:#e65100
    classDef data fill:#e0e0e0,stroke:#757575,color:#212121
    classDef external fill:#e1bee7,stroke:#8e24aa,color:#4a148c
    classDef orchestration fill:#f5f5f5,stroke:#9e9e9e,color:#424242
```
