How paritosh-j/cheap-chats works
Project Type and Purpose
• This is a full-stack, mobile-first, real-time group chat application (“Cheap Chats”), built as a single-page React/Vite frontend and a Spring Boot backend exposing both REST and WebSocket (STOMP/SockJS) endpoints.
• Users create temporary chat groups via REST, then exchange messages in real time via WebSockets.
High-Level File-Structure Analysis
• Top level:
• backend/ — Spring Boot project (Maven) with config, controllers, DTOs, models, repositories, services, resources, tests
• frontend/ — Vite + React + TypeScript SPA with TailwindCSS, organized into pages, components, services (api, socket), types, assets
• Key patterns:
• Backend follows MVC + Service + Repository layers (Spring Data JPA)
• Frontend follows component-based SPA structure with service modules for HTTP and WebSocket logic
README Insights
• Real-time messaging via WebSocket STOMP + SockJS
• REST endpoints for login, group management
• H2 or PostgreSQL for persistence
• Tech stack calls out React/Vite, Tailwind, Spring Boot 3, Spring Data JPA, WebSocket STOMP
Main Components
a. Frontend Client (Browser)
• UI (pages & components in React)
• REST Client (axios or fetch)
• WebSocket Client (STOMP over SockJS)
b. Backend Application Server
• REST Controllers (ChatController, GroupController)
• WebSocket Config & Message Endpoints
• Service Layer (business logic)
• Repository Layer (Spring Data JPA -> H2/PostgreSQL)
c. Database
• H2 (in-memory) or PostgreSQL
d. External/Infrastructure Services
• (Optional) Load Balancer or API Gateway
• (Optional) STOMP message broker (embedded in Spring or external)
Relationships & Data-Flow
• Browser → REST API (HTTP/HTTPS) → Spring Boot Controllers → Service → Repository → Database
• Browser ↔ WebSocket Server (STOMP/SockJS) → Message Broker → Spring Message Handlers → Service → Broadcast to subscribed clients
• Sequence examples:
1. Login via POST /api/login
2. Establish WebSocket handshake at /ws-endpoint
3. Subscribe to /topic/group/{groupName}
4. Send chat messages to /app/chat/{groupName}
Architectural Patterns & Design Principles
• Layered Architecture (Controller → Service → Repository)
• Single-Page Application (SPA) with separation of UI, API service, socket service
• Event-driven real-time messaging (publish/subscribe via STOMP)
• Temporary resource lifecycle (chat groups with TTL)
Technologies & Frameworks Callout
• Frontend: React, Vite, TypeScript, TailwindCSS, STOMP client over SockJS
• Backend: Spring Boot 3, Spring MVC, Spring WebSocket (STOMP), Spring Data JPA, Maven
• Database: H2 (dev) or PostgreSQL (prod)