# rohitrath0d/career-counsellor-chatapp architecture

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

- Interactive diagram: https://gitdiagram.com/rohitrath0d/career-counsellor-chatapp
- Repository: https://github.com/rohitrath0d/career-counsellor-chatapp

## Overview

##### Project type and purpose
- This is a full-stack, real-time chat application built on Next.js. It uses Next.js for server-rendered React pages, tRPC for type-safe API calls, Prisma as an ORM, NextAuth (Auth.js) for authentication, and WebSockets/Redis for real-time messaging.

##### File structure
- Top-level:
- pages/ – Next.js pages and API routes (auth, tRPC, hello)
- src/components/ – React UI components (chat, animations, theme, UI primitives)
- src/server/ – server-side code (context, Prisma client, Redis client, tRPC routers, WebSocket server)
- prisma/ – database schema and migrations
- public/ – static assets (animations)
- Key patterns:
- Next.js page router for SSR/SSG and API routes
- tRPC router pattern in src/server/routers
- WebSocket server separated in src/server/web-socket
- Prisma for data models, migrations in prisma/*
- Redis used likely for pub/sub and session caching (src/server/redis.ts)

##### README for additional insights
- Boilerplate Next.js instructions plus references to:
- tRPC client/server setup
- Auth.js/Prisma adapter
- React-query (TanStack Query)
- WebSockets API

##### Detail
- Subsystem (authentication, chat, data)
- How tRPC router files (chat.ts, user.ts) map to API endpoints
- Context creation (src/server/context) feeding into tRPC
- Don’t over-generalize—show both Next.js API layer and standalone WebSocket server

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        Browser["Browser (Next.js React App)"]:::frontend
    end

    subgraph "Backend"
        NextServer["Next.js Server\n(SSR, API Routes, NextAuth)"]:::backend
        TRPCRouters["tRPC Routers"]:::backend
        NextAuthComp["NextAuth (Auth.js)"]:::backend
        ContextSetup["Context Setup"]:::backend
    end

    subgraph "Real-time"
        WebSocketServer["WebSocket Server"]:::backend
    end

    subgraph "Data Stores"
        PostgreSQL["PostgreSQL"]:::database
        RedisPubSub["Redis Pub/Sub"]:::database
    end

    ExternalInfra["Vercel Hosting"]:::infra

    Browser -->|HTTPS| NextServer
    Browser -->|WSS| WebSocketServer
    NextServer -->|uses| TRPCRouters
    NextServer -->|auth flows| NextAuthComp
    NextServer -->|provides| ContextSetup
    ContextSetup -->|injected into| TRPCRouters
    ContextSetup -->|injected into| WebSocketServer
    TRPCRouters -->|reads/writes| PostgreSQL
    TRPCRouters -->|caches/pubsub| RedisPubSub
    NextAuthComp -->|stores sessions| PostgreSQL
    WebSocketServer -->|pub/sub| RedisPubSub
    WebSocketServer -->|real-time messages| Browser
    NextServer -->|hosted on| ExternalInfra
    WebSocketServer -->|hosted on| ExternalInfra

    classDef frontend fill:#e0f7e9,stroke:#2ecc71,color:#000
    classDef backend fill:#e8f4fc,stroke:#3498db,color:#000
    classDef database fill:#fcf3cf,stroke:#f39c12,color:#000
    classDef infra fill:#f2f2f2,stroke:#95a5a6,color:#000

    click Browser "https://github.com/rohitrath0d/career-counsellor-chatapp/blob/main/src/pages/_app.tsx"
    click NextServer "https://github.com/rohitrath0d/career-counsellor-chatapp/blob/main/src/pages/api/auth/[...nextauth].ts"
    click TRPCRouters "https://github.com/rohitrath0d/career-counsellor-chatapp/blob/main/src/server/routers/index.ts"
    click NextAuthComp "https://github.com/rohitrath0d/career-counsellor-chatapp/blob/main/src/pages/api/auth/[...nextauth].ts"
    click ContextSetup "https://github.com/rohitrath0d/career-counsellor-chatapp/blob/main/src/server/context/context.ts"
    click WebSocketServer "https://github.com/rohitrath0d/career-counsellor-chatapp/blob/main/src/server/web-socket/wsServer.ts"
    click PostgreSQL "https://github.com/rohitrath0d/career-counsellor-chatapp/blob/main/prisma/schema.prisma"
    click RedisPubSub "https://github.com/rohitrath0d/career-counsellor-chatapp/blob/main/src/server/redis.ts"
```
