How shubh-14-cloud/tether works
1. Overall shape
- Tether is a small Java web application packaged as a WAR and deployed to Apache Tomcat 10.1.
- The architecture is centered on one real-time server-side endpoint plus one database access component, with a thin browser-based client.
2. Client layer
- The user interface lives in src/main/webapp as index.html and index.jsp.
- This is a vanilla HTML/CSS/JavaScript front end, so the browser handles rendering, user input, and WebSocket communication directly rather than going through a separate frontend framework or API server.
3. Web runtime boundary
- WEB-INF/web.xml defines the web application configuration and wiring expected by the servlet container.
- Tomcat is the execution environment for HTTP entry points and the WebSocket endpoint, which means the app depends on container-managed deployment rather than an embedded server.
4. Real-time messaging subsystem
- src/main/java/com/chat/ChatWebSocket.java is the core application service.
- It is the WebSocket endpoint responsible for live chat traffic, including the real-time features described in the README: rooms, direct messages, typing indicators, and emoji reactions.
- This class is the main boundary between browser clients and server-side chat state.
5. Persistence subsystem
- src/main/java/com/chat/DatabaseManager.java is the data-access and schema-management layer.
- It connects the chat logic to MySQL, handles persistence of chat history, and likely performs startup initialization because the README says tables are created automatically on first launch.
- schema_v2.sql is the canonical schema definition for the MySQL database and indicates that schema evolution is managed outside the request path.
6. Data flow
- Browser clients connect to the server over WebSocket.
- Chat events enter ChatWebSocket, which then reads/writes persistent state through DatabaseManager.
- Updates are broadcast back to connected clients in real time, while message history and other durable state are stored in MySQL.
7. State model
- The app supports both transient and persistent state.
- Transient state includes live connections, typing status, and in-memory coordination for active rooms/users.
- Persistent state includes message history and room/user records stored in MySQL.
8. Deployment and environment
- The repository includes a Dockerfile and docker-entrypoint.sh, showing the app is designed to run in a containerized deployment.
- Railway is the documented hosting target, with MySQL provided as a separate service and configuration injected through environment variables.
9. Configuration boundary
- Database credentials are externalized via DB_URL, DB_USER, and DB_PASS.
- This keeps the application portable across local Tomcat, Docker, and Railway deployments without code changes.
10. Build and packaging
- Maven (pom.xml) builds the application into target/Tether.war.
- The packaged WAR includes runtime dependencies such as the MySQL JDBC driver and a JSON library, which supports server-side parsing/serialization of chat payloads.
11. Operational dependencies
- MySQL 8 is a required external service and is not embedded.
- Tomcat 10.1 is the servlet/WebSocket container, so the app’s network-facing behavior is constrained by Jakarta WebSocket and servlet container semantics.
12. Architecture summary for diagramming
- Draw three major boxes: browser client, Tomcat-hosted Java WebSocket backend, and MySQL database.
- Show WebSocket traffic between browser and ChatWebSocket, and JDBC-backed persistence between ChatWebSocket/DatabaseManager and MySQL.
- Treat web.xml, schema_v2.sql, Docker files, and environment variables as supporting configuration/infrastructure rather than primary business logic.
Main entry points: ChatWebSocket.java Chat WebSocket · DatabaseManager.java Database Manager · Tether.war Tether WAR · index.html Browser UI
Components 14
Client
Browser-facing UI and runtime interaction
- Browser UI · HTML/CSS/JS client rendered in the browser
src/main/webapp/index.html - JSP View · Secondary web entry served by the container
src/main/webapp/index.jsp
Server
Tomcat-hosted web and WebSocket runtime
- Web Config · Container wiring and deployment descriptor
src/main/webapp/WEB-INF/web.xml - Chat WebSocket · Real-time chat endpoint handling rooms, DMs, typing, and reactions
src/main/java/com/chat/ChatWebSocket.java - Database Manager · JDBC persistence and schema initialization layer
src/main/java/com/chat/DatabaseManager.java - Tomcat 10.1 · External runtime hosting HTTP and WebSocket entry points
- WAR Build · Builds the deployable web archive
pom.xml - Dockerfile · Container image definition for deployment
Dockerfile - Entrypoint · Container startup and launch wiring
docker-entrypoint.sh - Env Vars · Externalized database credentials and deployment settings
.env.example - Tether WAR · Packaged application artifact deployed to the container
target/Tether.war - Runtime JARs · Packaged JDBC and JSON libraries included in the WAR
target/Tether/WEB-INF/lib/mysql-connector-j-8.3.0.jar
Data
Persistent storage and schema
- MySQL · External persistent store for chat history and records
- Schema SQL · Canonical MySQL schema for initial database setup
schema_v2.sql
Connections 16
- Browser UI → Tomcat 10.1: HTTP/WebSocket · Browser connects to the container-hosted app
- JSP View → Tomcat 10.1: HTTP · Container serves the JSP entry point
- Tomcat 10.1 → Web Config: loads · Servlet container reads deployment configuration
- Tomcat 10.1 → Chat WebSocket: hosts · WebSocket endpoint runs inside Tomcat
- Web Config → Chat WebSocket: wires · Deployment descriptor binds the endpoint
- Chat WebSocket → Database Manager: uses · Chat logic delegates persistence and initialization
- Database Manager → MySQL: JDBC · Reads and writes durable chat state
- Schema SQL → MySQL: initializes · Schema defines the database structure
- Chat WebSocket → MySQL: persists · Live events are stored durably through the data layer
- Chat WebSocket → Browser UI: broadcasts · Real-time updates are pushed back to connected clients
- WAR Build → Tether WAR: packages · Maven produces the deployable WAR
- Tether WAR → Tomcat 10.1: deploys to · WAR is deployed into the servlet container
- Dockerfile → Tether WAR: ships · Container image includes the packaged app
- Entrypoint → Dockerfile: starts · Container startup script launches the app
- Env Vars → Database Manager: configures · Database connection settings are injected externally
- Runtime JARs → Chat WebSocket: supports · Bundled libraries provide JSON and JDBC support