How sharmasatyam121104-devloper/circle-communication-platform works
This repository is a two-part monorepo: a TypeScript backend in circle-server and a Vite/React frontend in circle-ui. The app is a real-time messaging and calling system, with authentication, chat, message attachments, and Twilio-backed audio/video calling.
1. Backend runtime and request boundary
circle-server is the HTTP API and real-time server. It is organized around Express-style entry points (src/index.ts, src/app.ts) and feature routers under src/modules/*. Cross-cutting middleware/config sits in src/config and src/utils, which means most business logic is isolated behind domain controllers and routes.
2. Domain modules on the server
The backend is split into four main business areas: user, chat, message, and twilio, plus a socket layer. Each feature has its own controller, routes, and types/models, which suggests the API is intentionally domain-scoped rather than monolithic.
3. Authentication and user management
The user subsystem handles signup/login/session-style concerns, profile updates, and profile image upload. The presence of passport.config.ts, jwt.ts, cookies.utils.ts, and user.middleware.ts indicates auth is enforced with JWT/cookie-based mechanisms, likely with Passport strategies and protected route middleware.
4. Persistence and server-side infrastructure
db.ts implies a database-backed API, and the *.model.ts files indicate a model layer beneath controllers. Redis is also configured, so the backend likely has a second stateful dependency for caching, session/connection coordination, or real-time support. logger.ts, serverErrorHandler.ts, cors.config.ts, and helmet.config.ts show the API is production-hardened with logging and security middleware.
5. Chat and message data flow
Chat and message are separated into distinct modules. Chat appears to manage conversation membership and metadata, while message handles message creation/retrieval and attachment handling. The message module includes a dedicated multer setup for attachments, which means file upload is part of the message pipeline rather than a generic file service.
6. Media upload handling
Uploads are routed through multer-specific config files and then likely forwarded to Cloudinary, as shown by cloudinary.config.ts. The user module has profile-picture upload support, and the message module has attachment upload support. This creates two main media paths: user avatars and chat attachments.
7. Real-time socket layer
src/socket.ts and the socket module indicate a persistent websocket channel alongside the REST API. This is the likely path for live message delivery, chat presence, and call notifications. The frontend also has a socketClient wrapper, confirming the app depends on real-time events, not just polling.
8. Twilio calling subsystem
The twilio module is a distinct integration boundary for audio/video calling. On the frontend there are separate AudioCall.tsx and VideoCall.tsx pages, plus call-related UI sounds and popups. That suggests call setup and signaling are initiated through the API/Twilio layer, while the UI handles call state and user experience.
9. Frontend application structure
circle-ui is a React SPA using Vite. Routing is split into public and protected routes, with pages for home, login, signup, chat, image update, audio call, and video call. This mirrors the backend’s domain model and indicates the UI is organized around user auth plus a main authenticated messaging surface.
10. Client state and API integration
The frontend has a small client layer in src/lib for API access, socket connection, time formatting, and error handling. Zustand stores (useAuthStore, useVideoCallStore) centralize app state for authentication and call state, so the UI is not purely component-local. This matters for the diagram because auth and call state are shared across multiple pages and overlays.
11. UI composition for messaging
The chat UI is decomposed into message area, sender/receiver message bubbles, attachment rendering, and member-management components. This suggests the Chat page is the central authenticated workspace, with supporting components for conversation membership and message presentation rather than one large page component.
12. Deployment and containerization
The backend has a Dockerfile, docker-compose setup, and a GitHub Actions deploy workflow. That indicates the server is expected to be containerized and deployed independently from the frontend, with CI/CD handling releases. The frontend is a separate Vite app, so the repo represents two deployable units connected by API and socket endpoints.
Overall, the key architecture boundary is: React UI in the browser talks to a TypeScript API server over REST and sockets; the server persists user/chat/message data, stores or proxies media uploads through Cloudinary, and integrates Twilio for calls. Redis, JWT/cookies, and Passport provide the infrastructure for stateful auth and real-time behavior.
Main entry points: app.ts App wiring · pages Pages · db.ts Database · config Server config
Components 25
circle-server
TypeScript API, realtime layer, and integrations
- Server entry · Bootstraps the HTTP API and wires the app/server runtime.
circle-server/src/index.ts - App wiring · Composes middleware, routes, and cross-cutting server setup.
circle-server/src/app.ts - Server config · Security, persistence, auth, upload, and cache configuration.
circle-server/src/config - Shared utils · Reusable server helpers for JWTs, logging, error handling, and basic routes.
circle-server/src/utils - Users · Authentication, profile management, and user-facing account flows.
circle-server/src/modules/user - Chats · Conversation membership and chat metadata.
circle-server/src/modules/chat - Messages · Message creation, retrieval, and attachment-aware messaging.
circle-server/src/modules/message - Twilio · Audio/video calling integration and call orchestration endpoints.
circle-server/src/modules/twilio - Socket layer · Persistent websocket channel for live events and call or chat signaling.
circle-server/src/socket.ts - Profile upload · Multer path for user avatar and profile image handling.
circle-server/src/modules/user/multer/profile-picture.ts - Attachment upload · Multer path for chat message attachments.
circle-server/src/modules/message/multer/attachment.multer.ts - Database · Primary server-side data store used by models and controllers.
circle-server/src/config/db.ts - Redis · Auxiliary stateful dependency for caching or realtime coordination.
circle-server/src/config/redis.config.ts - Cloudinary · External media storage/proxy for uploaded images and attachments.
circle-server/src/config/cloudinary.config.ts - Models · Domain models beneath the server controllers for users, chats, and messages.
circle-server/src/modules
circle-ui
React/Vite client application
- Client app · Vite entrypoint for the React single-page application.
circle-ui/src/main.tsx - Routes · Public and protected routing for authenticated and unauthenticated screens.
circle-ui/src/routes - Pages · Top-level screens for home, chat, auth, uploads, and calling.
circle-ui/src/pages - Chat UI · Message area, bubbles, attachments, and member-management components.
circle-ui/src/Components/chats - Shared UI · Reusable buttons, modals, popups, loaders, and upload controls.
circle-ui/src/Components/ui - Client lib · API wrapper, socket client, formatting helpers, and local error handling.
circle-ui/src/lib - Auth store · Client-side auth/session state shared across pages and routes.
circle-ui/src/store/useAuthStore.ts - Call store · Client-side audio/video call state and signaling coordination.
circle-ui/src/store/useVideoCallStore.ts
Delivery
Containerization and CI/CD
- Deploy workflow · GitHub Actions deployment pipeline.
.github/workflows/deploy.yml - Server container · Docker and compose setup for running the backend service.
circle-server/Dockerfile
Connections 27
- Server entry → App wiring: starts · Bootstraps the app wiring from the server entrypoint.
- App wiring → Server config: uses · Loads security, persistence, auth, and upload configuration.
- App wiring → Shared utils: uses · Shares common middleware helpers and error handling.
- App wiring → Users: routes to · Mounts user/auth endpoints.
- App wiring → Chats: routes to · Mounts chat endpoints.
- App wiring → Messages: routes to · Mounts message endpoints.
- App wiring → Twilio: routes to · Mounts calling endpoints.
- App wiring → Socket layer: attaches · Enables realtime server behavior alongside HTTP routes.
- Users → Database: persists · Reads and writes account data.
- Chats → Database: persists · Stores conversation data.
- Messages → Database: persists · Stores message records.
- Users → Profile upload: uploads · Handles profile image uploads.
- Messages → Attachment upload: uploads · Handles attachment uploads.
- Profile upload → Cloudinary: stores in · Sends uploaded media to external storage.
- Attachment upload → Cloudinary: stores in · Sends uploaded media to external storage.
- Server config → Redis: connects · Configures Redis-backed shared state.
- Server config → Database: connects · Configures the primary database connection.
- Client app → Routes: loads · Initializes navigation and route selection.
- Routes → Pages: renders · Switches between public, chat, and call pages.
- Pages → Chat UI: composes · Builds the messaging workspace from chat components.
- Pages → Shared UI: uses · Reuses shared UI primitives across screens.
- Pages → Client lib: calls · Uses API and socket utilities for server communication.
- Pages → Auth store: reads · Consumes authentication state.
- Pages → Call store: reads · Consumes call state.
- Client lib → Socket layer: connects to · Socket client mirrors the server realtime channel.
- Client lib → App wiring: calls · REST API integration point.
- Deploy workflow → Server container: builds · CI/CD supports containerized backend deployment.