# kewlaninaveen5/masterlingo architecture

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

- Interactive diagram: https://gitdiagram.com/kewlaninaveen5/masterlingo
- Repository: https://github.com/kewlaninaveen5/masterlingo

## Overview

This is a full-stack chat and video-calling application with account creation, onboarding, friend discovery and requests, messaging, notifications, and calls. The principal workflow is a user signing in and completing onboarding, then finding friends and starting chat or video calls. The graph follows documented frontend routes and sampled backend auth, user, Redis, Prisma, and call behavior. Chat, notifications, socket event handling, and several route details are represented at subsystem level because their implementation was not sampled.

Main entry points: [`frontend/src/lib/api.js`](https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/lib/api.js) (HTTP API client), [`frontend/src/App.jsx`](https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/App.jsx) (Route application), [`backend/src/server.js`](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/server.js) (Express server), [`backend/src/middleware/auth.middleware.js`](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/middleware/auth.middleware.js) (Session auth guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["Route application<br/>[App.jsx]"]
  node_authui["Auth and onboarding pages"]
  node_friendsui["Friends page<br/>[FriendsPage.jsx]"]
  node_notifyui["Notifications page"]
  node_api["HTTP API client<br/>[api.js]"]
end

subgraph group_identity["Identity and onboarding"]
  node_authroutes["Auth routes<br/>[auth.route.js]"]
  node_authflow["Auth handlers<br/>[auth.middleware.js]"]
  node_authguard["Session auth guard<br/>[auth.middleware.js]"]
  node_authhelper["Auth helper<br/>[authHelper.js]"]
end

subgraph group_social["Friends and notifications"]
  node_userroutes["User routes<br/>[user.route.js]"]
  node_userctrl["Friend and user handlers<br/>[user.controller.js]"]
end

subgraph group_conversation["Chat and calling"]
  node_chatui["Chat experience<br/>[ChatPage.jsx]"]
  node_callui["Call experience<br/>[CallPage.jsx]"]
  node_customcall["Custom video call"]
  node_incoming["Incoming call listener"]
  node_chatapi["Chat API client<br/>[ChatApi.js]"]
  node_socketclient["Socket client<br/>[sockets.js]"]
  node_chatroutes["Chat routes<br/>[chat.route.js]"]
  node_chatmiddleware["Chat middleware<br/>[chat.middleware.js]"]
  node_messagechecks["Message middleware"]
  node_chatcontroller["Chat controller<br/>[chat.controller.js]"]
  node_chatroom["Chat room helper<br/>[ChatRoomHelper.js]"]
  node_callroutes["Video call routes<br/>[videocall.route.js]"]
  node_callctrl["Call handlers"]
  node_callmodel["Call channel model"]
end

subgraph group_platform["Backend platform"]
  node_socketserver["Socket server<br/>[sockets.js]"]
  node_socketevents["User socket events<br/>[user.js]"]
  node_server["Express server<br/>[server.js]"]
  node_prisma["Prisma client<br/>[prismaClient.js]"]
  node_redis[("Redis client<br/>[redis.js]")]
  node_db["Database connector<br/>[db.js]"]
end

node_user(("User"))
node_postgres[("Cloud PostgreSQL")]
node_redisservice[("Redis service")]

node_user -->|"uses"| node_app
node_app -->|"routes"| node_authui
node_app -->|"routes"| node_friendsui
node_app -->|"routes"| node_notifyui
node_app -->|"routes"| node_chatui
node_app -->|"routes"| node_callui
node_app -->|"routes"| node_customcall
node_app -->|"renders"| node_incoming
node_authui -->|"requests"| node_api
node_friendsui -->|"requests"| node_api
node_notifyui -.->|"requests"| node_api
node_chatui -.->|"requests"| node_chatapi
node_chatapi -->|"uses HTTP"| node_api
node_customcall -.->|"creates calls"| node_api
node_incoming -.->|"listens"| node_socketclient
node_api -->|"HTTP requests"| node_authroutes
node_api -->|"HTTP requests"| node_userroutes
node_api -->|"HTTP requests"| node_chatroutes
node_api -->|"HTTP requests"| node_callroutes
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_userroutes
node_server -->|"mounts"| node_chatroutes
node_server -->|"mounts"| node_callroutes
node_server -->|"initializes"| node_socketserver
node_server -->|"connects"| node_redis
node_server -->|"connects"| node_db
node_authroutes -->|"routes to"| node_authflow
node_authroutes -->|"routes to"| node_authguard
node_authflow -->|"delegates"| node_authhelper
node_authhelper -->|"queries"| node_prisma
node_authflow -->|"queries"| node_prisma
node_authflow -->|"stores sessions"| node_redis
node_authguard -->|"checks session"| node_redis
node_authguard -->|"loads user"| node_authhelper
node_userroutes -->|"protects"| node_authguard
node_userroutes -->|"routes to"| node_userctrl
node_userctrl -->|"queries"| node_prisma
node_userctrl -->|"reads presence"| node_redis
node_chatroutes -->|"protects"| node_authguard
node_chatroutes -->|"routes to"| node_chatmiddleware
node_chatroutes -->|"routes to"| node_messagechecks
node_chatmiddleware -.->|"delegates"| node_chatcontroller
node_chatmiddleware -.->|"uses"| node_chatroom
node_callroutes -->|"protects"| node_authguard
node_callroutes -->|"routes to"| node_callctrl
node_callctrl -->|"creates and reads"| node_callmodel
node_socketserver -->|"uses"| node_redis
node_socketserver -->|"initializes"| node_socketevents

click node_app "https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/App.jsx"
click node_authui "https://github.com/kewlaninaveen5/masterlingo/tree/master/frontend/src/pages"
click node_friendsui "https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/pages/FriendsPage.jsx"
click node_notifyui "https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/pages/NotificationsPage.jsx"
click node_chatui "https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/pages/ChatPage.jsx"
click node_callui "https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/pages/CallPage.jsx"
click node_customcall "https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/pages/CustomVideoCall.jsx"
click node_incoming "https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/components/GlobalIncomingCallListener.jsx"
click node_api "https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/lib/api.js"
click node_chatapi "https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/lib/ChatApi.js"
click node_socketclient "https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/lib/sockets.js"
click node_authroutes "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/routes/auth.route.js"
click node_authflow "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/controllers/auth/auth.middleware.js"
click node_authguard "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/middleware/auth.middleware.js"
click node_authhelper "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/services/authHelper.js"
click node_userroutes "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/routes/user.route.js"
click node_userctrl "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/controllers/user.controller.js"
click node_chatroutes "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/routes/chat.route.js"
click node_chatmiddleware "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/middleware/chat.middleware.js"
click node_messagechecks "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/middleware/chat.message.middleware.js"
click node_chatcontroller "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/controllers/chat.controller.js"
click node_chatroom "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/services/ChatRoomHelper.js"
click node_callroutes "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/routes/videocall.route.js"
click node_callctrl "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/controllers/videocall.controller.js"
click node_callmodel "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/models/VideoCallChannel.js"
click node_socketserver "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/lib/sockets.js"
click node_socketevents "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/socketsCommunication/user.js"
click node_server "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/server.js"
click node_prisma "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/lib/prismaClient.js"
click node_redis "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/lib/redis.js"
click node_db "https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/lib/db.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_authui,node_friendsui,node_notifyui,node_api,node_user toneBlue
class node_authroutes,node_authflow,node_authguard,node_authhelper,node_postgres,node_redisservice toneAmber
class node_userroutes,node_userctrl toneMint
class node_chatui,node_callui,node_customcall,node_incoming,node_chatapi,node_socketclient,node_chatroutes,node_chatmiddleware,node_messagechecks,node_chatcontroller,node_chatroom,node_callroutes,node_callctrl,node_callmodel toneRose
class node_socketserver,node_socketevents,node_server,node_prisma,node_redis,node_db toneIndigo
```

## Components

### Web application

- [Route application](https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth and onboarding pages](https://github.com/kewlaninaveen5/masterlingo/tree/master/frontend/src/pages): `frontend/src/pages`
- [Friends page](https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/pages/FriendsPage.jsx): `frontend/src/pages/FriendsPage.jsx`
- [Notifications page](https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/pages/NotificationsPage.jsx): `frontend/src/pages/NotificationsPage.jsx`
- [HTTP API client](https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/lib/api.js): `frontend/src/lib/api.js`

### Identity and onboarding

- [Auth routes](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/routes/auth.route.js): `backend/src/routes/auth.route.js`
- [Auth handlers](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/controllers/auth/auth.middleware.js): `backend/src/controllers/auth/auth.middleware.js`
- [Session auth guard](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/middleware/auth.middleware.js): `backend/src/middleware/auth.middleware.js`
- [Auth helper](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/services/authHelper.js): `backend/src/services/authHelper.js`

### Friends and notifications

- [User routes](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/routes/user.route.js): `backend/src/routes/user.route.js`
- [Friend and user handlers](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/controllers/user.controller.js): `backend/src/controllers/user.controller.js`

### Chat and calling

- [Chat experience](https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/pages/ChatPage.jsx): `frontend/src/pages/ChatPage.jsx`
- [Call experience](https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/pages/CallPage.jsx): `frontend/src/pages/CallPage.jsx`
- [Custom video call](https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/pages/CustomVideoCall.jsx): `frontend/src/pages/CustomVideoCall.jsx`
- [Incoming call listener](https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/components/GlobalIncomingCallListener.jsx): `frontend/src/components/GlobalIncomingCallListener.jsx`
- [Chat API client](https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/lib/ChatApi.js): `frontend/src/lib/ChatApi.js`
- [Socket client](https://github.com/kewlaninaveen5/masterlingo/blob/master/frontend/src/lib/sockets.js): `frontend/src/lib/sockets.js`
- [Chat routes](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/routes/chat.route.js): `backend/src/routes/chat.route.js`
- [Chat middleware](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/middleware/chat.middleware.js): `backend/src/middleware/chat.middleware.js`
- [Message middleware](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/middleware/chat.message.middleware.js): `backend/src/middleware/chat.message.middleware.js`
- [Chat controller](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/controllers/chat.controller.js): `backend/src/controllers/chat.controller.js`
- [Chat room helper](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/services/ChatRoomHelper.js): `backend/src/services/ChatRoomHelper.js`
- [Video call routes](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/routes/videocall.route.js): `backend/src/routes/videocall.route.js`
- [Call handlers](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/controllers/videocall.controller.js): `backend/src/controllers/videocall.controller.js`
- [Call channel model](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/models/VideoCallChannel.js): `backend/src/models/VideoCallChannel.js`

### Backend platform

- [Socket server](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/lib/sockets.js): `backend/src/lib/sockets.js`
- [User socket events](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/socketsCommunication/user.js): `backend/src/socketsCommunication/user.js`
- [Express server](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/server.js): `backend/src/server.js`
- [Prisma client](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/lib/prismaClient.js): `backend/src/lib/prismaClient.js`
- [Redis client](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/lib/redis.js): `backend/src/lib/redis.js`
- [Database connector](https://github.com/kewlaninaveen5/masterlingo/blob/master/backend/src/lib/db.js): `backend/src/lib/db.js`

### Other components

- **User**
- **Cloud PostgreSQL**
- **Redis service**

## Connections

- User → Route application: uses (evidence: `frontend/src/App.jsx`)
- Route application → Auth and onboarding pages: routes (evidence: `frontend/src/App.jsx`)
- Route application → Friends page: routes (evidence: `frontend/src/App.jsx`)
- Route application → Notifications page: routes (evidence: `frontend/src/App.jsx`)
- Route application → Chat experience: routes (evidence: `frontend/src/App.jsx`)
- Route application → Call experience: routes (evidence: `frontend/src/App.jsx`)
- Route application → Custom video call: routes (evidence: `frontend/src/App.jsx`)
- Route application → Incoming call listener: renders (evidence: `frontend/src/App.jsx`)
- Auth and onboarding pages → HTTP API client: requests (evidence: `frontend/src/lib/api.js`)
- Friends page → HTTP API client: requests (evidence: `frontend/src/pages/FriendsPage.jsx`)
- Notifications page → HTTP API client: requests
- Chat experience → Chat API client: requests
- Chat API client → HTTP API client: uses HTTP (evidence: `frontend/src/lib/ChatApi.js`)
- Custom video call → HTTP API client: creates calls
- Incoming call listener → Socket client: listens
- HTTP API client → Auth routes: HTTP requests (evidence: `frontend/src/lib/api.js`)
- HTTP API client → User routes: HTTP requests (evidence: `frontend/src/lib/api.js`)
- HTTP API client → Chat routes: HTTP requests (evidence: `frontend/src/lib/api.js`)
- HTTP API client → Video call routes: HTTP requests (evidence: `frontend/src/lib/api.js`)
- Express server → Auth routes: mounts (evidence: `backend/src/server.js`)
- Express server → User routes: mounts (evidence: `backend/src/server.js`)
- Express server → Chat routes: mounts (evidence: `backend/src/server.js`)
- Express server → Video call routes: mounts (evidence: `backend/src/server.js`)
- Express server → Socket server: initializes (evidence: `backend/src/server.js`)
- Express server → Redis client: connects (evidence: `backend/src/server.js`)
- Express server → Database connector: connects (evidence: `backend/src/server.js`)
- Auth routes → Auth handlers: routes to (evidence: `backend/src/routes/auth.route.js`)
- Auth routes → Session auth guard: routes to (evidence: `backend/src/routes/auth.route.js`)
- Auth handlers → Auth helper: delegates (evidence: `backend/src/controllers/auth/auth.middleware.js`)
- Auth helper → Prisma client: queries (evidence: `backend/src/services/authHelper.js`)
- Auth handlers → Prisma client: queries (evidence: `backend/src/controllers/auth/auth.middleware.js`)
- Auth handlers → Redis client: stores sessions (evidence: `backend/src/controllers/auth/auth.middleware.js`)
- Session auth guard → Redis client: checks session (evidence: `backend/src/middleware/auth.middleware.js`)
- Session auth guard → Auth helper: loads user (evidence: `backend/src/middleware/auth.middleware.js`)
- User routes → Session auth guard: protects (evidence: `backend/src/routes/user.route.js`)
- User routes → Friend and user handlers: routes to (evidence: `backend/src/routes/user.route.js`)
- Friend and user handlers → Prisma client: queries (evidence: `backend/src/controllers/user.controller.js`)
- Friend and user handlers → Redis client: reads presence (evidence: `backend/src/controllers/user.controller.js`)
- Chat routes → Session auth guard: protects (evidence: `backend/src/routes/chat.route.js`)
- Chat routes → Chat middleware: routes to (evidence: `backend/src/routes/chat.route.js`)
- Chat routes → Message middleware: routes to (evidence: `backend/src/routes/chat.route.js`)
- Chat middleware → Chat controller: delegates
- Chat middleware → Chat room helper: uses
- Video call routes → Session auth guard: protects (evidence: `backend/src/routes/videocall.route.js`)
- Video call routes → Call handlers: routes to (evidence: `backend/src/routes/videocall.route.js`)
- Call handlers → Call channel model: creates and reads (evidence: `backend/src/controllers/videocall.controller.js`)
- Socket server → Redis client: uses (evidence: `backend/src/lib/sockets.js`)
- Socket server → User socket events: initializes (evidence: `backend/src/lib/sockets.js`)
