# dakshchauhan2005/snapseek architecture

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

- Interactive diagram: https://gitdiagram.com/dakshchauhan2005/snapseek
- Repository: https://github.com/dakshchauhan2005/snapseek

## Overview

SnapSeek is a React chat workspace backed by an Express API. Users register or sign in, then create and manage persistent chats; sending a message saves it through HTTP before assistant generation streams over Socket.IO and the completed reply is persisted. The map also includes email and Google authentication, device-aware sessions, and optional web search. Relationships come from the shown source and README; unsampled UI and integration details are included only where documented.

Main entry points: [`BACKEND/controller/auth.controller.js`](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/controller/auth.controller.js) (Auth controller), [`BACKEND/controller/chat.controller.js`](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/controller/chat.controller.js) (Chat controller), [`BACKEND/routes/auth.routes.js`](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/routes/auth.routes.js) (Auth routes), [`BACKEND/model/device.model.js`](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/model/device.model.js) (Device sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Frontend experience"]
  node_routes_ui["App routing<br/>[app.routes.jsx]"]
  node_auth_ui["Auth pages<br/>[Login.jsx]"]
  node_auth_hook["Auth actions<br/>[useAuth.js]"]
  node_auth_api["Auth API client<br/>[auth.api.js]"]
  node_chat_ui["Chat dashboard<br/>[Dashboard.jsx]"]
  node_chat_hook["Chat actions<br/>[useChat.js]"]
  node_chat_state["Chat state and socket<br/>[chat.slice.js]"]
  node_chat_api["Chat API client<br/>[chat.api.js]"]
end

subgraph group_identity["Identity and sessions"]
  node_api_app["Express application<br/>[app.js]"]
  node_auth_routes["Auth routes<br/>[auth.routes.js]"]
  node_auth_controller["Auth controller<br/>[auth.controller.js]"]
  node_google_controller["Google OAuth controller"]
  node_google_service["Google account resolver"]
  node_session_service["Session service<br/>[session.service.js]"]
  node_mail_service["Email delivery<br/>[mail.service.js]"]
end

subgraph group_conversation["Chat and generation"]
  node_chat_routes["Chat routes<br/>[chat.routes.js]"]
  node_chat_controller["Chat controller<br/>[chat.controller.js]"]
  node_ai_service["AI generation<br/>[ai.service.js]"]
  node_socket_server["Socket.IO server<br/>[server.socket.js]"]
end

subgraph group_data["Persistence and integrations"]
  node_user_store[("User records<br/>[user.model.js]")]
  node_device_store[("Device sessions<br/>[device.model.js]")]
  node_chat_store[("Chat records<br/>[chat.model.js]")]
  node_message_store[("Message records<br/>[message.model.js]")]
  node_db_config["MongoDB connection<br/>[db.js]"]
end

node_visitor(("User"))
node_mongo[("MongoDB")]
node_email_provider["Email provider"]
node_google["Google OAuth"]
node_groq["Groq model"]
node_tavily["Tavily search"]

node_visitor -->|"uses"| node_routes_ui
node_routes_ui -->|"routes to"| node_auth_ui
node_routes_ui -->|"routes to"| node_chat_ui
node_auth_ui -->|"uses"| node_auth_hook
node_auth_hook -->|"calls"| node_auth_api
node_auth_api -->|"calls"| node_auth_routes
node_chat_hook -->|"calls"| node_chat_api
node_chat_hook -->|"updates"| node_chat_state
node_chat_api -->|"calls"| node_chat_routes
node_chat_ui -.->|"uses"| node_chat_hook
node_api_app -->|"mounts"| node_auth_routes
node_api_app -->|"mounts"| node_chat_routes
node_api_app -->|"connects"| node_db_config
node_auth_routes -->|"routes to"| node_auth_controller
node_auth_routes -->|"routes to"| node_google_controller
node_auth_controller -->|"reads and writes"| node_user_store
node_auth_controller -->|"deletes"| node_device_store
node_auth_controller -->|"starts session"| node_session_service
node_auth_controller -->|"sends mail"| node_mail_service
node_google_controller -->|"resolves account"| node_google_service
node_google_controller -->|"starts session"| node_session_service
node_google -->|"returns callback"| node_auth_routes
node_session_service -->|"upserts session"| node_device_store
node_mail_service -->|"delivers email"| node_email_provider
node_chat_routes -->|"routes to"| node_chat_controller
node_chat_controller -->|"reads and writes"| node_chat_store
node_chat_controller -->|"reads and writes"| node_message_store
node_chat_controller -->|"generates reply"| node_ai_service
node_chat_controller -->|"emits events"| node_socket_server
node_socket_server -->|"checks ownership"| node_chat_store
node_socket_server -->|"checks session"| node_device_store
node_ai_service -->|"generates tokens"| node_groq
node_ai_service -.->|"searches optionally"| node_tavily
node_db_config -->|"connects"| node_mongo
node_user_store -->|"persists in"| node_mongo
node_device_store -->|"persists in"| node_mongo
node_chat_store -->|"persists in"| node_mongo
node_message_store -->|"persists in"| node_mongo

click node_routes_ui "https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/app/app.routes.jsx"
click node_auth_ui "https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/auth/pages/Login.jsx"
click node_auth_hook "https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/auth/hook/useAuth.js"
click node_auth_api "https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/auth/services/auth.api.js"
click node_chat_ui "https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/chat/pages/Dashboard.jsx"
click node_chat_hook "https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/chat/hooks/useChat.js"
click node_chat_state "https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/chat/chat.slice.js"
click node_chat_api "https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/chat/services/chat.api.js"
click node_api_app "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/src/app.js"
click node_auth_routes "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/routes/auth.routes.js"
click node_auth_controller "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/controller/auth.controller.js"
click node_google_controller "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/controller/googleAuth.controller.js"
click node_google_service "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/services/googleAuth.service.js"
click node_session_service "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/services/session.service.js"
click node_mail_service "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/services/mail.service.js"
click node_chat_routes "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/routes/chat.routes.js"
click node_chat_controller "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/controller/chat.controller.js"
click node_ai_service "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/services/ai.service.js"
click node_socket_server "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/socket/server.socket.js"
click node_user_store "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/model/user.model.js"
click node_device_store "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/model/device.model.js"
click node_chat_store "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/model/chat.model.js"
click node_message_store "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/model/message.model.js"
click node_db_config "https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/config/db.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_routes_ui,node_auth_ui,node_auth_hook,node_auth_api,node_chat_ui,node_chat_hook,node_chat_state,node_chat_api,node_visitor toneBlue
class node_api_app,node_auth_routes,node_auth_controller,node_google_controller,node_google_service,node_session_service,node_mail_service,node_mongo toneAmber
class node_chat_routes,node_chat_controller,node_ai_service,node_socket_server toneMint
class node_user_store,node_device_store,node_chat_store,node_message_store,node_db_config toneRose
class node_email_provider,node_google,node_groq,node_tavily toneIndigo
```

## Components

### Frontend experience

- [App routing](https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/app/app.routes.jsx): `FRONTEND/src/app/app.routes.jsx`
- [Auth pages](https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/auth/pages/Login.jsx): `FRONTEND/src/features/auth/pages/Login.jsx`
- [Auth actions](https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/auth/hook/useAuth.js): `FRONTEND/src/features/auth/hook/useAuth.js`
- [Auth API client](https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/auth/services/auth.api.js): `FRONTEND/src/features/auth/services/auth.api.js`
- [Chat dashboard](https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/chat/pages/Dashboard.jsx): `FRONTEND/src/features/chat/pages/Dashboard.jsx`
- [Chat actions](https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/chat/hooks/useChat.js): `FRONTEND/src/features/chat/hooks/useChat.js`
- [Chat state and socket](https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/chat/chat.slice.js): `FRONTEND/src/features/chat/chat.slice.js`
- [Chat API client](https://github.com/dakshchauhan2005/snapseek/blob/main/FRONTEND/src/features/chat/services/chat.api.js): `FRONTEND/src/features/chat/services/chat.api.js`

### Identity and sessions

- [Express application](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/src/app.js): `BACKEND/src/app.js`
- [Auth routes](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/routes/auth.routes.js): `BACKEND/routes/auth.routes.js`
- [Auth controller](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/controller/auth.controller.js): `BACKEND/controller/auth.controller.js`
- [Google OAuth controller](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/controller/googleAuth.controller.js): `BACKEND/controller/googleAuth.controller.js`
- [Google account resolver](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/services/googleAuth.service.js): `BACKEND/services/googleAuth.service.js`
- [Session service](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/services/session.service.js): `BACKEND/services/session.service.js`
- [Email delivery](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/services/mail.service.js): `BACKEND/services/mail.service.js`

### Chat and generation

- [Chat routes](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/routes/chat.routes.js): `BACKEND/routes/chat.routes.js`
- [Chat controller](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/controller/chat.controller.js): `BACKEND/controller/chat.controller.js`
- [AI generation](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/services/ai.service.js): `BACKEND/services/ai.service.js`
- [Socket.IO server](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/socket/server.socket.js): `BACKEND/socket/server.socket.js`

### Persistence and integrations

- [User records](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/model/user.model.js): `BACKEND/model/user.model.js`
- [Device sessions](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/model/device.model.js): `BACKEND/model/device.model.js`
- [Chat records](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/model/chat.model.js): `BACKEND/model/chat.model.js`
- [Message records](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/model/message.model.js): `BACKEND/model/message.model.js`
- [MongoDB connection](https://github.com/dakshchauhan2005/snapseek/blob/main/BACKEND/config/db.js): `BACKEND/config/db.js`

### Other components

- **User**
- **MongoDB**
- **Email provider**
- **Google OAuth**
- **Groq model**
- **Tavily search**

## Connections

- User → App routing: uses (evidence: `FRONTEND/src/app/app.routes.jsx`)
- App routing → Auth pages: routes to (evidence: `FRONTEND/src/app/app.routes.jsx`)
- App routing → Chat dashboard: routes to (evidence: `FRONTEND/src/app/app.routes.jsx`)
- Auth pages → Auth actions: uses (evidence: `FRONTEND/src/features/auth/pages/Login.jsx`)
- Auth actions → Auth API client: calls (evidence: `FRONTEND/src/features/auth/hook/useAuth.js`)
- Auth API client → Auth routes: calls (evidence: `README.md`)
- Chat actions → Chat API client: calls (evidence: `FRONTEND/src/features/chat/hooks/useChat.js`)
- Chat actions → Chat state and socket: updates (evidence: `FRONTEND/src/features/chat/hooks/useChat.js`)
- Chat API client → Chat routes: calls (evidence: `README.md`)
- Chat dashboard → Chat actions: uses
- Express application → Auth routes: mounts (evidence: `BACKEND/src/app.js`)
- Express application → Chat routes: mounts (evidence: `BACKEND/src/app.js`)
- Express application → MongoDB connection: connects (evidence: `BACKEND/src/app.js`)
- Auth routes → Auth controller: routes to (evidence: `BACKEND/routes/auth.routes.js`)
- Auth routes → Google OAuth controller: routes to (evidence: `BACKEND/routes/auth.routes.js`)
- Auth controller → User records: reads and writes (evidence: `BACKEND/controller/auth.controller.js`)
- Auth controller → Device sessions: deletes (evidence: `BACKEND/controller/auth.controller.js`)
- Auth controller → Session service: starts session (evidence: `BACKEND/controller/auth.controller.js`)
- Auth controller → Email delivery: sends mail (evidence: `BACKEND/controller/auth.controller.js`)
- Google OAuth controller → Google account resolver: resolves account (evidence: `BACKEND/controller/googleAuth.controller.js`)
- Google OAuth controller → Session service: starts session (evidence: `BACKEND/controller/googleAuth.controller.js`)
- Google OAuth → Auth routes: returns callback (evidence: `README.md`)
- Session service → Device sessions: upserts session (evidence: `BACKEND/services/session.service.js`)
- Email delivery → Email provider: delivers email (evidence: `README.md`)
- Chat routes → Chat controller: routes to (evidence: `BACKEND/routes/chat.routes.js`)
- Chat controller → Chat records: reads and writes (evidence: `BACKEND/controller/chat.controller.js`)
- Chat controller → Message records: reads and writes (evidence: `BACKEND/controller/chat.controller.js`)
- Chat controller → AI generation: generates reply (evidence: `BACKEND/controller/chat.controller.js`)
- Chat controller → Socket.IO server: emits events (evidence: `BACKEND/controller/chat.controller.js`)
- Socket.IO server → Chat records: checks ownership (evidence: `BACKEND/socket/server.socket.js`)
- Socket.IO server → Device sessions: checks session (evidence: `BACKEND/socket/server.socket.js`)
- AI generation → Groq model: generates tokens (evidence: `README.md`)
- AI generation → Tavily search: searches optionally (evidence: `README.md`)
- MongoDB connection → MongoDB: connects (evidence: `README.md`)
- User records → MongoDB: persists in (evidence: `README.md`)
- Device sessions → MongoDB: persists in (evidence: `README.md`)
- Chat records → MongoDB: persists in (evidence: `README.md`)
- Message records → MongoDB: persists in (evidence: `README.md`)
