# div641/hermes architecture

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

- Interactive diagram: https://gitdiagram.com/div641/hermes
- Repository: https://github.com/div641/hermes

## Overview

Hermes is a full-stack AI chat application. Users register and verify an account, log in, then create conversations, ask questions, and receive AI answers that can include current web information; they can revisit or delete chat history. The frontend also provides a public landing page and real-time client wiring. The graph follows sampled route, controller, and service calls; documented but unsampled UI and integrations are shown at their supported directory paths. Socket.IO is initialized, but its live event behavior is not established by the sampled server source.

Main entry points: [`Backend/src/app.js`](https://github.com/div641/hermes/blob/master/Backend/src/app.js) (Express application), [`Frontend/src/app/app.routes.jsx`](https://github.com/div641/hermes/blob/master/Frontend/src/app/app.routes.jsx) (UI routes), [`Backend/src/controllers/chat.controller.js`](https://github.com/div641/hermes/blob/master/Backend/src/controllers/chat.controller.js) (Chat controller), [`Backend/server.js`](https://github.com/div641/hermes/blob/master/Backend/server.js) (HTTP and socket entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_app["App shell<br/>[App.jsx]"]
  node_routes_ui["UI routes<br/>[app.routes.jsx]"]
  node_landing["Landing experience<br/>[Landing.jsx]"]
end

subgraph group_identity["Authentication"]
  node_auth_ui["Auth pages and state"]
  node_auth_hook["Auth actions<br/>[useAuth.js]"]
  node_auth_api["Auth API client<br/>[auth.api.js]"]
  node_auth_routes["Auth routes<br/>[auth.routes.js]"]
  node_auth_controller["Auth controller<br/>[auth.controller.js]"]
  node_auth_middleware["Session middleware<br/>[auth.middleware.js]"]
  node_user_store[("User records<br/>[user.model.js]")]
  node_mail_service["Verification email<br/>[mail.service.js]"]
end

subgraph group_chat["Chat workflow"]
  node_chat_ui["Chat interface<br/>[Dashboard.jsx]"]
  node_chat_state["Chat state and hooks"]
  node_chat_api["Chat API client<br/>[chat.api.js]"]
  node_chat_socket["Socket client<br/>[chat.socket.js]"]
  node_chat_routes["Chat routes<br/>[chat.routes.js]"]
  node_chat_controller["Chat controller<br/>[chat.controller.js]"]
  node_chat_store[("Chat records<br/>[chat.model.js]")]
  node_message_store[("Message records<br/>[message.model.js]")]
end

subgraph group_intelligence["AI and search"]
  node_ai_service["AI agent and titles<br/>[ai.service.js]"]
  node_internet_service["Internet search tool"]
  node_model_provider{{"Gemini and Mistral"}}
  node_tavily{{"Tavily search"}}
end

subgraph group_platform["Runtime and state"]
  node_app_server["Express application<br/>[app.js]"]
  node_server_entry["HTTP and socket entry<br/>[server.js]"]
  node_database_config["Database connection<br/>[database.js]"]
  node_mongodb[("MongoDB")]
  node_socket_server["Socket.IO server<br/>[server.socket.js]"]
  node_email_provider{{"Email service"}}
end

node_visitor(("Visitor"))

node_visitor -->|"opens app"| node_frontend_app
node_frontend_app -->|"renders routes"| node_routes_ui
node_routes_ui -->|"serves public page"| node_landing
node_routes_ui -->|"serves auth pages"| node_auth_ui
node_routes_ui -->|"protects dashboard"| node_chat_ui
node_auth_ui -->|"invokes actions"| node_auth_hook
node_auth_hook -->|"calls endpoints"| node_auth_api
node_auth_api -->|"HTTP requests"| node_app_server
node_app_server -->|"mounts auth routes"| node_auth_routes
node_auth_routes -->|"dispatches handlers"| node_auth_controller
node_auth_routes -->|"guards session routes"| node_auth_middleware
node_auth_controller -->|"reads and writes"| node_user_store
node_auth_controller -->|"sends verification"| node_mail_service
node_mail_service -.->|"delivers email"| node_email_provider
node_chat_ui -->|"uses chat state"| node_chat_state
node_chat_state -->|"requests chat data"| node_chat_api
node_chat_api -->|"HTTP requests"| node_app_server
node_chat_ui -.->|"uses live client"| node_chat_socket
node_chat_socket -.->|"Socket.IO connection"| node_socket_server
node_app_server -->|"mounts chat routes"| node_chat_routes
node_chat_routes -->|"guards chat routes"| node_auth_middleware
node_chat_routes -->|"dispatches handlers"| node_chat_controller
node_chat_controller -->|"creates and queries"| node_chat_store
node_chat_controller -->|"creates and queries"| node_message_store
node_chat_controller -->|"generates title and answer"| node_ai_service
node_ai_service -.->|"invokes models"| node_model_provider
node_ai_service -->|"exposes search tool"| node_internet_service
node_internet_service -.->|"searches web"| node_tavily
node_server_entry -->|"creates HTTP server"| node_app_server
node_server_entry -->|"initializes sockets"| node_socket_server
node_server_entry -->|"connects database"| node_database_config
node_database_config -->|"opens connection"| node_mongodb
node_user_store -->|"persists users"| node_mongodb
node_chat_store -->|"persists chats"| node_mongodb
node_message_store -->|"persists messages"| node_mongodb

click node_frontend_app "https://github.com/div641/hermes/blob/master/Frontend/src/app/App.jsx"
click node_routes_ui "https://github.com/div641/hermes/blob/master/Frontend/src/app/app.routes.jsx"
click node_landing "https://github.com/div641/hermes/blob/master/Frontend/src/features/landing/Landing.jsx"
click node_auth_ui "https://github.com/div641/hermes/tree/master/Frontend/src/features/auth"
click node_auth_hook "https://github.com/div641/hermes/blob/master/Frontend/src/features/auth/hook/useAuth.js"
click node_auth_api "https://github.com/div641/hermes/blob/master/Frontend/src/features/auth/service/auth.api.js"
click node_auth_routes "https://github.com/div641/hermes/blob/master/Backend/src/routes/auth.routes.js"
click node_auth_controller "https://github.com/div641/hermes/blob/master/Backend/src/controllers/auth.controller.js"
click node_auth_middleware "https://github.com/div641/hermes/blob/master/Backend/src/middlewares/auth.middleware.js"
click node_user_store "https://github.com/div641/hermes/blob/master/Backend/src/models/user.model.js"
click node_mail_service "https://github.com/div641/hermes/blob/master/Backend/src/services/mail.service.js"
click node_chat_ui "https://github.com/div641/hermes/blob/master/Frontend/src/features/chat/pages/Dashboard.jsx"
click node_chat_state "https://github.com/div641/hermes/tree/master/Frontend/src/features/chat"
click node_chat_api "https://github.com/div641/hermes/blob/master/Frontend/src/features/chat/service/chat.api.js"
click node_chat_socket "https://github.com/div641/hermes/blob/master/Frontend/src/features/chat/service/chat.socket.js"
click node_chat_routes "https://github.com/div641/hermes/blob/master/Backend/src/routes/chat.routes.js"
click node_chat_controller "https://github.com/div641/hermes/blob/master/Backend/src/controllers/chat.controller.js"
click node_chat_store "https://github.com/div641/hermes/blob/master/Backend/src/models/chat.model.js"
click node_message_store "https://github.com/div641/hermes/blob/master/Backend/src/models/message.model.js"
click node_ai_service "https://github.com/div641/hermes/blob/master/Backend/src/services/ai.service.js"
click node_internet_service "https://github.com/div641/hermes/blob/master/Backend/src/services/internet.service.js"
click node_app_server "https://github.com/div641/hermes/blob/master/Backend/src/app.js"
click node_server_entry "https://github.com/div641/hermes/blob/master/Backend/server.js"
click node_database_config "https://github.com/div641/hermes/blob/master/Backend/src/config/database.js"
click node_socket_server "https://github.com/div641/hermes/blob/master/Backend/src/sockets/server.socket.js"

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_frontend_app,node_routes_ui,node_landing toneBlue
class node_auth_ui,node_auth_hook,node_auth_api,node_auth_routes,node_auth_controller,node_auth_middleware,node_user_store,node_mail_service toneAmber
class node_chat_ui,node_chat_state,node_chat_api,node_chat_socket,node_chat_routes,node_chat_controller,node_chat_store,node_message_store toneMint
class node_ai_service,node_internet_service,node_model_provider,node_tavily toneRose
class node_app_server,node_server_entry,node_database_config,node_mongodb,node_socket_server,node_email_provider,node_visitor toneIndigo
```

## Components

### Frontend

- [App shell](https://github.com/div641/hermes/blob/master/Frontend/src/app/App.jsx): `Frontend/src/app/App.jsx`
- [UI routes](https://github.com/div641/hermes/blob/master/Frontend/src/app/app.routes.jsx): `Frontend/src/app/app.routes.jsx`
- [Landing experience](https://github.com/div641/hermes/blob/master/Frontend/src/features/landing/Landing.jsx): `Frontend/src/features/landing/Landing.jsx`

### Authentication

- [Auth pages and state](https://github.com/div641/hermes/tree/master/Frontend/src/features/auth): `Frontend/src/features/auth`
- [Auth actions](https://github.com/div641/hermes/blob/master/Frontend/src/features/auth/hook/useAuth.js): `Frontend/src/features/auth/hook/useAuth.js`
- [Auth API client](https://github.com/div641/hermes/blob/master/Frontend/src/features/auth/service/auth.api.js): `Frontend/src/features/auth/service/auth.api.js`
- [Auth routes](https://github.com/div641/hermes/blob/master/Backend/src/routes/auth.routes.js): `Backend/src/routes/auth.routes.js`
- [Auth controller](https://github.com/div641/hermes/blob/master/Backend/src/controllers/auth.controller.js): `Backend/src/controllers/auth.controller.js`
- [Session middleware](https://github.com/div641/hermes/blob/master/Backend/src/middlewares/auth.middleware.js): `Backend/src/middlewares/auth.middleware.js`
- [User records](https://github.com/div641/hermes/blob/master/Backend/src/models/user.model.js): `Backend/src/models/user.model.js`
- [Verification email](https://github.com/div641/hermes/blob/master/Backend/src/services/mail.service.js): `Backend/src/services/mail.service.js`

### Chat workflow

- [Chat interface](https://github.com/div641/hermes/blob/master/Frontend/src/features/chat/pages/Dashboard.jsx): `Frontend/src/features/chat/pages/Dashboard.jsx`
- [Chat state and hooks](https://github.com/div641/hermes/tree/master/Frontend/src/features/chat): `Frontend/src/features/chat`
- [Chat API client](https://github.com/div641/hermes/blob/master/Frontend/src/features/chat/service/chat.api.js): `Frontend/src/features/chat/service/chat.api.js`
- [Socket client](https://github.com/div641/hermes/blob/master/Frontend/src/features/chat/service/chat.socket.js): `Frontend/src/features/chat/service/chat.socket.js`
- [Chat routes](https://github.com/div641/hermes/blob/master/Backend/src/routes/chat.routes.js): `Backend/src/routes/chat.routes.js`
- [Chat controller](https://github.com/div641/hermes/blob/master/Backend/src/controllers/chat.controller.js): `Backend/src/controllers/chat.controller.js`
- [Chat records](https://github.com/div641/hermes/blob/master/Backend/src/models/chat.model.js): `Backend/src/models/chat.model.js`
- [Message records](https://github.com/div641/hermes/blob/master/Backend/src/models/message.model.js): `Backend/src/models/message.model.js`

### AI and search

- [AI agent and titles](https://github.com/div641/hermes/blob/master/Backend/src/services/ai.service.js): `Backend/src/services/ai.service.js`
- [Internet search tool](https://github.com/div641/hermes/blob/master/Backend/src/services/internet.service.js): `Backend/src/services/internet.service.js`
- **Gemini and Mistral**
- **Tavily search**

### Runtime and state

- [Express application](https://github.com/div641/hermes/blob/master/Backend/src/app.js): `Backend/src/app.js`
- [HTTP and socket entry](https://github.com/div641/hermes/blob/master/Backend/server.js): `Backend/server.js`
- [Database connection](https://github.com/div641/hermes/blob/master/Backend/src/config/database.js): `Backend/src/config/database.js`
- **MongoDB**
- [Socket.IO server](https://github.com/div641/hermes/blob/master/Backend/src/sockets/server.socket.js): `Backend/src/sockets/server.socket.js`
- **Email service**

### Other components

- **Visitor**

## Connections

- Visitor → App shell: opens app
- App shell → UI routes: renders routes
- UI routes → Landing experience: serves public page
- UI routes → Auth pages and state: serves auth pages
- UI routes → Chat interface: protects dashboard
- Auth pages and state → Auth actions: invokes actions
- Auth actions → Auth API client: calls endpoints
- Auth API client → Express application: HTTP requests
- Express application → Auth routes: mounts auth routes
- Auth routes → Auth controller: dispatches handlers
- Auth routes → Session middleware: guards session routes
- Auth controller → User records: reads and writes
- Auth controller → Verification email: sends verification
- Verification email → Email service: delivers email
- Chat interface → Chat state and hooks: uses chat state
- Chat state and hooks → Chat API client: requests chat data
- Chat API client → Express application: HTTP requests
- Chat interface → Socket client: uses live client
- Socket client → Socket.IO server: Socket.IO connection
- Express application → Chat routes: mounts chat routes
- Chat routes → Session middleware: guards chat routes
- Chat routes → Chat controller: dispatches handlers
- Chat controller → Chat records: creates and queries
- Chat controller → Message records: creates and queries
- Chat controller → AI agent and titles: generates title and answer
- AI agent and titles → Gemini and Mistral: invokes models
- AI agent and titles → Internet search tool: exposes search tool
- Internet search tool → Tavily search: searches web
- HTTP and socket entry → Express application: creates HTTP server
- HTTP and socket entry → Socket.IO server: initializes sockets
- HTTP and socket entry → Database connection: connects database
- Database connection → MongoDB: opens connection
- User records → MongoDB: persists users
- Chat records → MongoDB: persists chats
- Message records → MongoDB: persists messages
