# mermeriem/messaging-system architecture

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

- Interactive diagram: https://gitdiagram.com/mermeriem/messaging-system
- Repository: https://github.com/mermeriem/messaging-system

## Overview

This is a browser messaging application with an Express/MySQL backend and Socket.IO real-time transport. Users enter through the React app, authenticate through REST endpoints, then use the dashboard to exchange socket messages and file references; file uploads and downloads use separate HTTP routes. The README also describes notifications and status updates, which align with the server’s socket events. The sampled files do not show persistent chat history or profile-management flows, so those are not represented as implemented subsystems.

Main entry points: [`frontend/src/App.jsx`](https://github.com/mermeriem/messaging-system/blob/main/frontend/src/App.jsx) (React app routing), [`backend/controllers/authenticationController.js`](https://github.com/mermeriem/messaging-system/blob/main/backend/controllers/authenticationController.js) (Auth controller), [`backend/server.js`](https://github.com/mermeriem/messaging-system/blob/main/backend/server.js) (HTTP and socket server), [`frontend/src/context/SocketContext.jsx`](https://github.com/mermeriem/messaging-system/blob/main/frontend/src/context/SocketContext.jsx) (Socket state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web client"]
  node_app["React app routing<br/>[App.jsx]"]
  node_dashboard["Chat dashboard<br/>[DashboardPage.jsx]"]
  node_login["Login page<br/>[LoginPage.jsx]"]
  node_signup["Sign-up page<br/>[SignUpPage.jsx]"]
  node_auth_context["Auth state<br/>[AuthContext.jsx]"]
  node_socket_context["Socket state<br/>[SocketContext.jsx]"]
end

subgraph group_auth["Authentication"]
  node_auth_routes["Auth routes"]
  node_auth_controller["Auth controller"]
  node_auth_middleware["Input and token checks"]
  node_passwords["Password hashing<br/>[hashing.js]"]
  node_tokens["JWT creation<br/>[createToken.js]"]
  node_db_pool[("MySQL connection<br/>[db.js]")]
end

subgraph group_realtime["Realtime messaging"]
  node_server["HTTP and socket server<br/>[server.js]"]
end

subgraph group_files["File sharing"]
  node_upload_route["Upload route"]
  node_upload_middleware["Upload handling<br/>[uploadings.js]"]
  node_download_route["Download route"]
  node_download_controller["File download"]
  node_stored_files[("Local uploaded files")]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"checks auth"| node_auth_context
node_app -->|"routes to"| node_signup
node_app -->|"routes to"| node_dashboard
node_app -->|"imports"| node_login
node_dashboard -->|"uses"| node_socket_context
node_user -.->|"submits credentials"| node_auth_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"validates inputs"| node_auth_middleware
node_auth_controller -->|"queries"| node_db_pool
node_auth_controller -->|"hashes and compares"| node_passwords
node_auth_controller -->|"creates token"| node_tokens
node_auth_controller -.->|"returns token"| node_auth_context
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_upload_route
node_server -->|"mounts"| node_download_route
node_socket_context -->|"exchanges socket events"| node_server
node_socket_context -->|"uploads files"| node_upload_route
node_upload_route -->|"handles upload"| node_upload_middleware
node_user -->|"sends messages"| node_socket_context
node_download_route -->|"dispatches"| node_download_controller
node_download_controller -->|"reads file"| node_stored_files

click node_app "https://github.com/mermeriem/messaging-system/blob/main/frontend/src/App.jsx"
click node_dashboard "https://github.com/mermeriem/messaging-system/blob/main/frontend/src/pages/DashboardPage.jsx"
click node_login "https://github.com/mermeriem/messaging-system/blob/main/frontend/src/pages/LoginPage.jsx"
click node_signup "https://github.com/mermeriem/messaging-system/blob/main/frontend/src/pages/SignUpPage.jsx"
click node_auth_context "https://github.com/mermeriem/messaging-system/blob/main/frontend/src/context/AuthContext.jsx"
click node_socket_context "https://github.com/mermeriem/messaging-system/blob/main/frontend/src/context/SocketContext.jsx"
click node_auth_routes "https://github.com/mermeriem/messaging-system/blob/main/backend/routes/authenticationRoute.js"
click node_auth_controller "https://github.com/mermeriem/messaging-system/blob/main/backend/controllers/authenticationController.js"
click node_auth_middleware "https://github.com/mermeriem/messaging-system/blob/main/backend/middleware/authenticationMiddlware.js"
click node_passwords "https://github.com/mermeriem/messaging-system/blob/main/backend/utils/hashing.js"
click node_tokens "https://github.com/mermeriem/messaging-system/blob/main/backend/utils/createToken.js"
click node_db_pool "https://github.com/mermeriem/messaging-system/blob/main/backend/config/db.js"
click node_server "https://github.com/mermeriem/messaging-system/blob/main/backend/server.js"
click node_upload_route "https://github.com/mermeriem/messaging-system/blob/main/backend/routes/sendingFilesRoute.js"
click node_upload_middleware "https://github.com/mermeriem/messaging-system/blob/main/backend/middleware/uploadings.js"
click node_download_route "https://github.com/mermeriem/messaging-system/blob/main/backend/routes/downloadFileRoute.js"
click node_download_controller "https://github.com/mermeriem/messaging-system/blob/main/backend/controllers/downloadFileController.js"
click node_stored_files "https://github.com/mermeriem/messaging-system/tree/main/backend/uploads"

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_dashboard,node_login,node_signup,node_auth_context,node_socket_context,node_user toneBlue
class node_auth_routes,node_auth_controller,node_auth_middleware,node_passwords,node_tokens,node_db_pool toneAmber
class node_server toneMint
class node_upload_route,node_upload_middleware,node_download_route,node_download_controller,node_stored_files toneRose
```

## Components

### Web client

- [React app routing](https://github.com/mermeriem/messaging-system/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Chat dashboard](https://github.com/mermeriem/messaging-system/blob/main/frontend/src/pages/DashboardPage.jsx): `frontend/src/pages/DashboardPage.jsx`
- [Login page](https://github.com/mermeriem/messaging-system/blob/main/frontend/src/pages/LoginPage.jsx): `frontend/src/pages/LoginPage.jsx`
- [Sign-up page](https://github.com/mermeriem/messaging-system/blob/main/frontend/src/pages/SignUpPage.jsx): `frontend/src/pages/SignUpPage.jsx`
- [Auth state](https://github.com/mermeriem/messaging-system/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Socket state](https://github.com/mermeriem/messaging-system/blob/main/frontend/src/context/SocketContext.jsx): `frontend/src/context/SocketContext.jsx`

### Authentication

- [Auth routes](https://github.com/mermeriem/messaging-system/blob/main/backend/routes/authenticationRoute.js): `backend/routes/authenticationRoute.js`
- [Auth controller](https://github.com/mermeriem/messaging-system/blob/main/backend/controllers/authenticationController.js): `backend/controllers/authenticationController.js`
- [Input and token checks](https://github.com/mermeriem/messaging-system/blob/main/backend/middleware/authenticationMiddlware.js): `backend/middleware/authenticationMiddlware.js`
- [Password hashing](https://github.com/mermeriem/messaging-system/blob/main/backend/utils/hashing.js): `backend/utils/hashing.js`
- [JWT creation](https://github.com/mermeriem/messaging-system/blob/main/backend/utils/createToken.js): `backend/utils/createToken.js`
- [MySQL connection](https://github.com/mermeriem/messaging-system/blob/main/backend/config/db.js): `backend/config/db.js`

### Realtime messaging

- [HTTP and socket server](https://github.com/mermeriem/messaging-system/blob/main/backend/server.js): `backend/server.js`

### File sharing

- [Upload route](https://github.com/mermeriem/messaging-system/blob/main/backend/routes/sendingFilesRoute.js): `backend/routes/sendingFilesRoute.js`
- [Upload handling](https://github.com/mermeriem/messaging-system/blob/main/backend/middleware/uploadings.js): `backend/middleware/uploadings.js`
- [Download route](https://github.com/mermeriem/messaging-system/blob/main/backend/routes/downloadFileRoute.js): `backend/routes/downloadFileRoute.js`
- [File download](https://github.com/mermeriem/messaging-system/blob/main/backend/controllers/downloadFileController.js): `backend/controllers/downloadFileController.js`
- [Local uploaded files](https://github.com/mermeriem/messaging-system/tree/main/backend/uploads): `backend/uploads`

### Other components

- **User**

## Connections

- User → React app routing: uses (evidence: `README.md`)
- React app routing → Auth state: checks auth (evidence: `frontend/src/App.jsx`)
- React app routing → Sign-up page: routes to (evidence: `frontend/src/App.jsx`)
- React app routing → Chat dashboard: routes to (evidence: `frontend/src/App.jsx`)
- React app routing → Login page: imports (evidence: `frontend/src/App.jsx`)
- Chat dashboard → Socket state: uses (evidence: `frontend/src/pages/DashboardPage.jsx`)
- User → Auth routes: submits credentials (evidence: `README.md`)
- Auth routes → Auth controller: dispatches (evidence: `backend/routes/authenticationRoute.js`)
- Auth routes → Input and token checks: validates inputs (evidence: `backend/routes/authenticationRoute.js`)
- Auth controller → MySQL connection: queries (evidence: `backend/controllers/authenticationController.js`)
- Auth controller → Password hashing: hashes and compares (evidence: `backend/controllers/authenticationController.js`)
- Auth controller → JWT creation: creates token (evidence: `backend/controllers/authenticationController.js`)
- Auth controller → Auth state: returns token
- HTTP and socket server → Auth routes: mounts (evidence: `backend/server.js`)
- HTTP and socket server → Upload route: mounts (evidence: `backend/server.js`)
- HTTP and socket server → Download route: mounts (evidence: `backend/server.js`)
- Socket state → HTTP and socket server: exchanges socket events (evidence: `frontend/src/context/SocketContext.jsx`)
- Socket state → Upload route: uploads files (evidence: `frontend/src/context/SocketContext.jsx`)
- Upload route → Upload handling: handles upload (evidence: `backend/routes/sendingFilesRoute.js`)
- User → Socket state: sends messages (evidence: `README.md`)
- Download route → File download: dispatches (evidence: `backend/routes/downloadFileRoute.js`)
- File download → Local uploaded files: reads file (evidence: `backend/controllers/downloadFileController.js`)
