# ganjeliyajay/voice-assistant-in-mern architecture

> Architecture diagram of the GitHub repository ganjeliyajay/voice-assistant-in-mern, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ganjeliyajay/voice-assistant-in-mern
- Repository: https://github.com/ganjeliyajay/voice-assistant-in-mern

## Overview

1. This repository is split into two deployed boundaries: `Client/` is a React SPA built with Vite, and `Server/` is an Express + Node API. The frontend talks to the backend over HTTP, and the backend talks to MongoDB and an external AI service.

2. The frontend entry point is `Client/src/main.jsx`, which mounts `App.jsx` and the global styles. The UI is organized into `Pages/` for route-level screens and `Components/` for reusable pieces like `Hero.jsx`.

3. The main user-facing flows are authentication and assistant interaction. The page set includes `Login`, `Register`, `Logout`, `Home`, plus `AddAssistantName` and `UpdateAssistantName`, which suggests a user-specific assistant profile or personalization setting.

4. Client state management is centralized in Redux. `Redux/Store.jsx` wires the store, while `UserSlice`/`UserThunk` handle auth or profile data and `GeminiSlice`/`GeminiThunk` handle assistant/AI request state. This is the main client-side boundary between UI and backend I/O.

5. The app’s voice features are browser-side and depend on the Web Speech API, as noted in the README. Speech recognition captures user input, and text-to-speech likely reads assistant responses back to the user. Chrome is called out because speech support is more reliable there.

6. The backend entry point is `Server/index.js`, which likely initializes Express, middleware, routes, and DB connection. `Configs/db.js` handles MongoDB connectivity, while `Configs/isAuth.js` and `Configs/token.js` provide authentication middleware and JWT/token helpers.

7. Authentication is a dedicated backend subsystem. `Routes/AuthRoutes.js` connects to `Controllers/AuthControllers.js`, and `Modules/UserModule.js` represents the user data model. This suggests registration, login, logout, and protected profile/assistant-name operations are all handled server-side.

8. The assistant/AI subsystem is separate from auth. `Controllers/GeminiController.js` and `Gemini.js` imply integration with an external Gemini API or SDK, with the backend acting as a proxy/adapter so the frontend never calls the AI service directly.

9. The primary data flow is: user speaks in the browser → frontend converts speech to text → Redux thunk sends the request to the backend → backend authenticates if needed and forwards to Gemini or reads/writes MongoDB → response returns to the client → UI updates and may speak the answer aloud.

10. Persistence appears to be centered on MongoDB for user records and assistant-related settings, not on local client storage. The presence of assistant-name pages implies the backend stores that preference with the user record or a related user document.

11. Cross-origin deployment is an important boundary. The README shows a Netlify frontend and Render backend, so `cors` and cookie/JWT settings matter. `CLIENT_URL`, `VITE_API_URL`, `MONGO_URI`, and `JWT_SECRET` are the key environment variables shaping runtime behavior.

12. For an architecture diagram, the core boxes are: Browser UI, Redux state layer, Express API, MongoDB, and Gemini external service. The main arrows are speech input/output in the browser, authenticated API calls from Redux thunks, DB reads/writes for users, and backend-to-Gemini AI requests.

Main entry points: [`Server/index.js`](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/index.js) (Express API), [`Client/src/App.jsx`](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/App.jsx) (App shell), [`Server/Controllers/AuthControllers.js`](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Controllers/AuthControllers.js) (Auth controller), [`Client/src/Redux/Store.jsx`](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/Redux/Store.jsx) (Redux store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_browser_ui["Browser UI<br/>spa shell<br/>[main.jsx]"]
  node_app_shell["App shell<br/>react root<br/>[App.jsx]"]
  node_pages["Pages<br/>route screens"]
  node_components["Components<br/>ui pieces"]
  node_redux_store["Redux store<br/>state root<br/>[Store.jsx]"]
  node_user_slice["User state<br/>redux slice<br/>[UserSlice.jsx]"]
  node_user_thunk["User thunk<br/>async auth<br/>[UserThunk.jsx]"]
  node_gemini_slice["Assistant state<br/>redux slice<br/>[GeminiSlice.jsx]"]
  node_gemini_thunk["AI thunk<br/>async ai<br/>[GeminiThunk.jsx]"]
  node_speech_api(("Speech API<br/>browser api"))
end

subgraph group_server["Server"]
  node_express_api["Express API<br/>http backend<br/>[index.js]"]
  node_auth_routes["Auth routes<br/>route layer<br/>[AuthRoutes.js]"]
  node_auth_controller["Auth controller<br/>[AuthControllers.js]"]
  node_user_model[("User model<br/>mongo model<br/>[UserModule.js]")]
  node_auth_helpers["Auth helpers<br/>jwt middleware<br/>[token.js]"]
  node_db_config["DB config<br/>mongo connect<br/>[db.js]"]
  node_gemini_controller["AI controller"]
  node_gemini_sdk{{"Gemini service<br/>external ai<br/>[Gemini.js]"}}
  node_mongo_db[("MongoDB<br/>database")]
end

node_browser_ui -->|"mounts"| node_app_shell
node_app_shell -->|"renders"| node_pages
node_app_shell -->|"uses"| node_components
node_app_shell -->|"wraps"| node_redux_store
node_pages -->|"reads/writes"| node_redux_store
node_redux_store -->|"includes"| node_user_slice
node_redux_store -->|"includes"| node_gemini_slice
node_user_slice -->|"uses"| node_user_thunk
node_gemini_slice -->|"uses"| node_gemini_thunk
node_speech_api -->|"feeds input"| node_pages
node_user_thunk -->|"http"| node_express_api
node_gemini_thunk -->|"http"| node_express_api
node_express_api -->|"routes"| node_auth_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"verifies"| node_auth_helpers
node_auth_controller -->|"persists"| node_user_model
node_user_model -->|"stores"| node_mongo_db
node_express_api -->|"connects"| node_db_config
node_express_api -->|"routes"| node_gemini_controller
node_gemini_controller -->|"calls"| node_gemini_sdk
node_gemini_controller -->|"responds"| node_express_api
node_auth_controller -->|"responds"| node_express_api

click node_browser_ui "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/main.jsx"
click node_app_shell "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/App.jsx"
click node_pages "https://github.com/ganjeliyajay/voice-assistant-in-mern/tree/main/Client/src/Pages"
click node_components "https://github.com/ganjeliyajay/voice-assistant-in-mern/tree/main/Client/src/Components"
click node_redux_store "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/Redux/Store.jsx"
click node_user_slice "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/Redux/Slice/UserSlice.jsx"
click node_user_thunk "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/Redux/Thunk/UserThunk.jsx"
click node_gemini_slice "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/Redux/Slice/GeminiSlice.jsx"
click node_gemini_thunk "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/Redux/Thunk/GeminiThunk.jsx"
click node_express_api "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/index.js"
click node_auth_routes "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Routes/AuthRoutes.js"
click node_auth_controller "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Controllers/AuthControllers.js"
click node_user_model "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Modules/UserModule.js"
click node_auth_helpers "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Configs/token.js"
click node_db_config "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Configs/db.js"
click node_gemini_controller "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Controllers/GeminiController.js"
click node_gemini_sdk "https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Gemini.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_browser_ui,node_app_shell,node_pages,node_components,node_redux_store,node_user_slice,node_user_thunk,node_gemini_slice,node_gemini_thunk,node_speech_api toneBlue
class node_express_api,node_auth_routes,node_auth_controller,node_user_model,node_auth_helpers,node_db_config,node_gemini_controller,node_gemini_sdk,node_mongo_db toneAmber
```

## Components

### Client

React SPA built with Vite; browser UI, Redux state, and speech features

- [Browser UI](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/main.jsx): spa shell · Mounted React app with route-level screens and reusable UI · `Client/src/main.jsx`
- [App shell](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/App.jsx): react root · Top-level client composition and global styling · `Client/src/App.jsx`
- [Pages](https://github.com/ganjeliyajay/voice-assistant-in-mern/tree/main/Client/src/Pages): route screens · Login, register, home, logout, and assistant-name screens · `Client/src/Pages`
- [Components](https://github.com/ganjeliyajay/voice-assistant-in-mern/tree/main/Client/src/Components): ui pieces · Reusable presentation components such as Hero · `Client/src/Components`
- [Redux store](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/Redux/Store.jsx): state root · Central client state wiring for auth and assistant flows · `Client/src/Redux/Store.jsx`
- [User state](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/Redux/Slice/UserSlice.jsx): redux slice · Auth and profile state for the current user · `Client/src/Redux/Slice/UserSlice.jsx`
- [User thunk](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/Redux/Thunk/UserThunk.jsx): async auth · Client-side async actions for user login and profile updates · `Client/src/Redux/Thunk/UserThunk.jsx`
- [Assistant state](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/Redux/Slice/GeminiSlice.jsx): redux slice · Assistant request and response state · `Client/src/Redux/Slice/GeminiSlice.jsx`
- [AI thunk](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Client/src/Redux/Thunk/GeminiThunk.jsx): async ai · Client-side async actions that call the backend for assistant responses · `Client/src/Redux/Thunk/GeminiThunk.jsx`
- **Speech API**: browser api · Browser speech recognition and text-to-speech integration

### Server

Express API, authentication, AI proxy, and MongoDB persistence

- [Express API](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/index.js): http backend · Server entry point that wires routes, middleware, and services · `Server/index.js`
- [Auth routes](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Routes/AuthRoutes.js): route layer · HTTP endpoints for registration, login, logout, and profile actions · `Server/Routes/AuthRoutes.js`
- [Auth controller](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Controllers/AuthControllers.js): controller · Request handlers for user authentication and assistant-name updates · `Server/Controllers/AuthControllers.js`
- [User model](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Modules/UserModule.js): mongo model · User document shape and persistence boundary · `Server/Modules/UserModule.js`
- [Auth helpers](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Configs/token.js): jwt middleware · Token creation and protected-route checks · `Server/Configs/token.js`
- [DB config](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Configs/db.js): mongo connect · MongoDB connection setup · `Server/Configs/db.js`
- [AI controller](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Controllers/GeminiController.js): controller · Backend adapter for assistant requests to the external AI service · `Server/Controllers/GeminiController.js`
- [Gemini service](https://github.com/ganjeliyajay/voice-assistant-in-mern/blob/main/Server/Gemini.js): external ai · External Gemini API or SDK integration · `Server/Gemini.js`
- **MongoDB**: database · Persistent store for users and assistant settings

## Connections

- Browser UI → App shell: mounts · The entry point mounts the root app
- App shell → Pages: renders · App composes route-level screens
- App shell → Components: uses · App and pages reuse shared UI pieces
- App shell → Redux store: wraps · The client is connected to the Redux provider
- Pages → Redux store: reads/writes · Screens consume centralized state
- Redux store → User state: includes · Store registers user state
- Redux store → Assistant state: includes · Store registers assistant state
- User state → User thunk: uses · User state is driven by async auth actions
- Assistant state → AI thunk: uses · Assistant state is driven by async AI actions
- Speech API → Pages: feeds input · Voice capture and playback happen in the browser UI
- User thunk → Express API: http · Auth and profile requests go to the backend
- AI thunk → Express API: http · Assistant requests are sent through the API
- Express API → Auth routes: routes · Server exposes authentication endpoints
- Auth routes → Auth controller: dispatches · Routes delegate to auth handlers
- Auth controller → Auth helpers: verifies · Protected flows use token and auth middleware
- Auth controller → User model: persists · Auth and assistant-name data are stored on user records
- User model → MongoDB: stores · User documents live in MongoDB
- Express API → DB config: connects · Server initializes the database connection
- Express API → AI controller: routes · AI requests are handled by a dedicated controller
- AI controller → Gemini service: calls · Backend proxies requests to the external Gemini service
- AI controller → Express API: responds · Assistant results return to the HTTP layer
- Auth controller → Express API: responds · Auth results return to the HTTP layer
