How gravedd/sechat-v2 works
Purpose and Top-Level Shape
seChat is a PWA chat application intended to encrypt messages with a key. It is split into a Vue 3 client and Laravel API/backend, with a separate Ratchet WebSocket chat server. Primary deployments likely expose the SPA separately from Laravel’s public HTTP entry point.
Entry Points and Request Routing
• Vue boots from frontend/src/main.js, mounts frontend/src/App.vue, and uses routes in frontend/src/router/index.js.
• Laravel HTTP traffic enters backend/public/index.php, runs through backend/app/Http/Kernel.php, and is mapped by backend/routes/api.php and backend/routes/web.php.
• The persistent chat process is started through the Artisan command backend/app/Console/Commands/ChatServer.php, registered by backend/app/Console/Kernel.php.
Client Application and UI Stages
• Route-level views provide landing, authentication, profile/search, dialogue list, and active-chat surfaces: frontend/src/views/IndexView.vue, frontend/src/views/DialoguesView.vue, frontend/src/views/ChatView.vue.
• Authentication UI is separated into frontend/src/components/auth/loginform.vue and frontend/src/components/auth/registerform.vue.
• The browser application is configured as a PWA, including service-worker registration at frontend/src/registerServiceWorker.js; public assets include notification sound and UI assets.
Client State, API, and Realtime Boundary
• Vuex is centralized in frontend/src/store/index.js.
• Dialogue and notification state are maintained in frontend/src/store/dialogues.js and frontend/src/store/Notifications.js.
• WebSocket lifecycle/protocol handling is isolated from views in frontend/src/store/ws.js and frontend/src/store/ChatWS.js. This is the client boundary for real-time message delivery; views consume store state rather than owning socket transport.
Laravel API and Domain Layer
• Controllers define the application API around identity, users, friendship, dialogues, and messages: backend/app/Http/Controllers/AuthController.php, backend/app/Http/Controllers/DialoguesController.php, backend/app/Http/Controllers/MessagesController.php.
• Eloquent models represent the durable chat graph: backend/app/Models/User.php, backend/app/Models/Friend.php, backend/app/Models/Dialogue.php, and backend/app/Models/Message.php.
• Authentication middleware and Laravel’s auth configuration establish the protected API boundary: backend/app/Http/Middleware/Authenticate.php and backend/config/auth.php.
Realtime Chat Server
• Ratchet socket behavior resides in backend/app/sockets/ChatSocket.php, built on backend/app/sockets/base/BaseSocket.php.
• backend/app/Models/SocketUser.php indicates the socket server tracks connected-user/session state separately from the core user model.
• Control flow is: browser WebSocket stores connect/send through the socket server; socket-user state determines recipients; REST endpoints persist and query account, relationship, dialogue, and message data.
Persistence and Runtime Infrastructure
• MySQL is the stated datastore; Laravel database wiring is in backend/config/database.php.
• Schema migrations establish users/auth tokens plus friend, message, socket-user, and dialogue records: backend/database/migrations/2022_04_16_125835_create_friends_table.php, backend/database/migrations/2022_04_18_155258_create_messages_table.php, backend/database/migrations/2022_04_28_171941_create_dialogues_table.php.
• Material runtimes are PHP/Laravel, a long-running Ratchet server, and JavaScript/Vue 3 in the browser. Laravel also carries queue, cache, mail, and broadcasting configuration, though their active use is not established by the supplied structure.
Main entry points: store/index.js Vuex store · ChatSocket.php Chat socket · router/index.js Client router · ws.js WebSocket client
Components 19
Vue PWA
Browser single-page chat client.
- Vue bootstrap
frontend/src/main.js - App shell
frontend/src/App.vue - Client router
frontend/src/router/index.js - Chat views · Landing, dialogue list, and active chat surfaces.
frontend/src/views/ChatView.vue - Auth forms · Login and registration UI.
frontend/src/components/auth/loginform.vue - Vuex store · Central state consumed by views.
frontend/src/store/index.js - Dialogue state · Dialogue and notification state.
frontend/src/store/dialogues.js - WebSocket client · Owns browser socket lifecycle and protocol.
frontend/src/store/ws.js - Service worker
frontend/src/registerServiceWorker.js
Laravel API
HTTP API, authentication, and chat domain.
- HTTP entry
backend/public/index.php - HTTP kernel · Applies middleware and protected API boundary.
backend/app/Http/Kernel.php - API routes
backend/routes/api.php - Chat API controllers · Identity, dialogues, and message endpoints.
backend/app/Http/Controllers/MessagesController.php - Chat domain models · Users, relationships, dialogues, and messages.
backend/app/Models/Message.php
Ratchet Realtime
Long-running WebSocket delivery process.
- Chat server command · Starts the persistent socket process.
backend/app/Console/Commands/ChatServer.php - Chat socket · Routes realtime chat traffic to connected recipients.
backend/app/sockets/ChatSocket.php - Socket user state · Tracks connected user/session state separately.
backend/app/Models/SocketUser.php
MySQL
Durable chat and connection state.
- MySQL · Stores accounts, relationships, dialogues, messages, and socket users.
backend/config/database.php - Chat schema migrations · Creates friend, message, and dialogue tables.
backend/database/migrations/2022_04_18_155258_create_messages_table.php
Connections 20
- Vue bootstrap → App shell: mounts
- App shell → Client router: renders routes
- Client router → Chat views: selects
- Client router → Auth forms: selects
- Chat views → Vuex store: reads and dispatches
- Vuex store → Dialogue state: contains
- Vuex store → WebSocket client: contains
- Service worker → Vue bootstrap: supports offline client
- Vuex store → HTTP entry: REST requests
- HTTP entry → HTTP kernel: boots through
- HTTP kernel → API routes: dispatches
- API routes → Chat API controllers: maps to
- Chat API controllers → Chat domain models: uses
- Chat domain models → MySQL: persists
- Chat schema migrations → MySQL: creates schema
- Chat server command → Chat socket: starts
- WebSocket client → Chat socket: connects and sends
- Chat socket → Socket user state: finds recipients
- Socket user state → MySQL: persists sessions
- Chat socket → WebSocket client: delivers messages