# bhagwatjadhav9422/geniev2frontend architecture

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

- Interactive diagram: https://gitdiagram.com/bhagwatjadhav9422/geniev2frontend
- Repository: https://github.com/bhagwatjadhav9422/geniev2frontend

## Overview

#### Purpose and Runtime
This is a Vite-served React frontend for an authenticated document-backed chat product. It provides user login/signup, chat conversations with citations and file upload, document management, and an admin area. Browser UI code is rooted at `src/main.jsx`, with the application shell in `src/App.jsx`; API endpoint configuration is centralized in `src/config/api.js`.

#### Application Composition and Navigation
`src/App.jsx` is the top-level composition point, expected to select page-level views and apply route protection. The principal screens are:
- Chat workspace: `src/pages/ChatPage.jsx`
- Document management: `src/pages/DocumentsPage.jsx`
- Administration: `src/pages/AdminPanel.jsx`
- Authentication: `src/pages/Login.jsx`, `src/pages/Signup.jsx`

`src/components/auth/ProtectedRoute.jsx` establishes the authenticated-user boundary, while `src/components/auth/AdminRoute.jsx` adds role-based access control for administration.

#### Authentication and Session Boundary
`src/hooks/useAuth.jsx` owns client-side authentication state and likely coordinates credentials/tokens with the configured backend. `src/utils/token.utils.js` is the token persistence/handling boundary. Login and signup screens feed this flow, and protected routes consume it to gate the main application.

#### Chat Conversation Flow
The chat domain is organized around state hooks and presentational components:
- Chat/conversation state and backend operations: `src/hooks/useChat.js`, `src/hooks/useConversations.js`
- Workspace container: `src/components/Chat/ChatWindow.jsx`
- User submission and attachments: `src/components/Chat/ChatInput.jsx`, `src/components/Chat/FileUpload.jsx`
- Rendered responses and source references: `src/components/Chat/MessageBubble.jsx`, `src/components/Chat/CitationCard.jsx`

A user selects or creates a conversation, submits text and potentially files, then the UI renders messages and associated citations. Conversation navigation/history is separated into `src/components/Sidebar/Sidebar.jsx` and `src/components/Sidebar/ChatHistoryList.jsx`.

#### Document Lifecycle
Documents are a distinct managed resource rather than only transient chat attachments. `src/hooks/useDocuments.js` encapsulates document API state/actions. `src/components/Documents/DocumentTable.jsx` displays the managed corpus, while `src/components/Documents/DocumentUploadModal.jsx` provides an upload entry point. `src/pages/DocumentsPage.jsx` forms the page-level boundary for this workflow.

#### Shared Resilience and UI State
Cross-cutting UI states are centralized in reusable components: `src/components/common/ErrorBoundary.jsx` for render failure containment, `src/components/common/Toast.jsx` for transient feedback, and `src/components/common/SkeletonLoader.jsx` / `src/components/common/EmptyState.jsx` for loading and absent-data states. Styles are domain-separated under `src/styles/`, notably `src/styles/chat.css`, `src/styles/layout.css`, and `src/styles/admin.css`.

#### External Boundary and Infrastructure
The frontend communicates with an external backend through API definitions in `src/config/api.js`; backend implementation, persistence, document ingestion/indexing, AI inference, and authorization enforcement are outside this repository. Build and local development infrastructure are Vite-based (`vite.config.js`, `package.json`) and deploy as a browser single-page application.

Main entry points: [`src/components/auth/ProtectedRoute.jsx`](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/auth/ProtectedRoute.jsx) (Protected route), [`src/hooks/useAuth.jsx`](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/hooks/useAuth.jsx) (Auth state), [`src/config/api.js`](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/config/api.js) (API definitions), [`src/App.jsx`](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/App.jsx) (Application shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["App shell"]
  node_vite{{"Vite browser runtime<br/>build runtime<br/>[vite.config.js]"}}
  node_main["React entry<br/>frontend entry<br/>[main.jsx]"]
  node_app["Application shell<br/>route composition<br/>[App.jsx]"]
  node_admin["Admin panel<br/>page<br/>[AdminPanel.jsx]"]
end

subgraph group_auth["Authentication"]
  node_protected_route["Protected route<br/>auth guard<br/>[ProtectedRoute.jsx]"]
  node_admin_route["Admin route<br/>role guard<br/>[AdminRoute.jsx]"]
  node_auth_state["Auth state<br/>React hook<br/>[useAuth.jsx]"]
  node_token_utils["Token storage<br/>session utility<br/>[token.utils.js]"]
  node_auth_pages["Login and signup<br/>auth screens<br/>[Login.jsx]"]
end

subgraph group_chat["Chat workspace"]
  node_chat_page["Chat page<br/>[ChatPage.jsx]"]
  node_chat_state["Chat and conversations<br/>state hooks<br/>[useChat.js]"]
  node_chat_window["Chat window<br/>workspace container<br/>[ChatWindow.jsx]"]
  node_chat_input["Message input and files<br/>submission UI<br/>[ChatInput.jsx]"]
  node_messages["Messages and citations<br/>response UI<br/>[MessageBubble.jsx]"]
  node_sidebar["Conversation sidebar<br/>history navigation<br/>[Sidebar.jsx]"]
end

subgraph group_documents["Documents"]
  node_documents_page["Documents page<br/>[DocumentsPage.jsx]"]
  node_documents_state["Document state<br/>React hook<br/>[useDocuments.js]"]
  node_document_ui["Document table and upload<br/>document UI<br/>[DocumentTable.jsx]"]
end

subgraph group_external["External boundary"]
  node_api_config["API definitions<br/>backend client config<br/>[api.js]"]
  node_backend[("Backend services<br/>external backend")]
end

node_vite -->|"serves"| node_main
node_main -->|"mounts"| node_app
node_app -->|"guards app routes"| node_protected_route
node_app -->|"routes unauthenticated users"| node_auth_pages
node_protected_route -->|"permits"| node_chat_page
node_protected_route -->|"permits"| node_documents_page
node_protected_route -->|"passes admin route"| node_admin_route
node_admin_route -->|"permits admins"| node_admin
node_auth_pages -->|"authenticate"| node_auth_state
node_protected_route -->|"checks session"| node_auth_state
node_auth_state -->|"persists token"| node_token_utils
node_auth_state -->|"uses endpoints"| node_api_config
node_chat_page -->|"hosts"| node_chat_window
node_chat_page -->|"hosts"| node_sidebar
node_chat_window -->|"accepts submissions"| node_chat_input
node_chat_window -->|"renders responses"| node_messages
node_sidebar -->|"selects conversations"| node_chat_state
node_chat_input -->|"sends messages and files"| node_chat_state
node_chat_state -->|"calls API"| node_api_config
node_documents_page -->|"hosts"| node_document_ui
node_document_ui -->|"manages corpus"| node_documents_state
node_documents_state -->|"calls API"| node_api_config
node_api_config -->|"HTTP API"| node_backend

click node_vite "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/vite.config.js"
click node_main "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/main.jsx"
click node_app "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/App.jsx"
click node_protected_route "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/auth/ProtectedRoute.jsx"
click node_admin_route "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/auth/AdminRoute.jsx"
click node_auth_state "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/hooks/useAuth.jsx"
click node_token_utils "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/utils/token.utils.js"
click node_auth_pages "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/pages/Login.jsx"
click node_chat_page "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/pages/ChatPage.jsx"
click node_chat_state "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/hooks/useChat.js"
click node_chat_window "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/Chat/ChatWindow.jsx"
click node_chat_input "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/Chat/ChatInput.jsx"
click node_messages "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/Chat/MessageBubble.jsx"
click node_sidebar "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/Sidebar/Sidebar.jsx"
click node_documents_page "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/pages/DocumentsPage.jsx"
click node_documents_state "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/hooks/useDocuments.js"
click node_document_ui "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/Documents/DocumentTable.jsx"
click node_admin "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/pages/AdminPanel.jsx"
click node_api_config "https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/config/api.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_vite,node_main,node_app,node_admin toneBlue
class node_protected_route,node_admin_route,node_auth_state,node_token_utils,node_auth_pages toneAmber
class node_chat_page,node_chat_state,node_chat_window,node_chat_input,node_messages,node_sidebar toneMint
class node_documents_page,node_documents_state,node_document_ui toneRose
class node_api_config,node_backend toneIndigo
```

## Components

### App shell

- [Vite browser runtime](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/vite.config.js): build runtime · Serves the React single-page application. · `vite.config.js`
- [React entry](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/main.jsx): frontend entry · `src/main.jsx`
- [Application shell](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/App.jsx): route composition · Selects page views and applies route protection. · `src/App.jsx`
- [Admin panel](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/pages/AdminPanel.jsx): page · `src/pages/AdminPanel.jsx`

### Authentication

- [Protected route](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/auth/ProtectedRoute.jsx): auth guard · `src/components/auth/ProtectedRoute.jsx`
- [Admin route](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/auth/AdminRoute.jsx): role guard · `src/components/auth/AdminRoute.jsx`
- [Auth state](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/hooks/useAuth.jsx): React hook · Coordinates client session credentials with the backend. · `src/hooks/useAuth.jsx`
- [Token storage](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/utils/token.utils.js): session utility · `src/utils/token.utils.js`
- [Login and signup](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/pages/Login.jsx): auth screens · `src/pages/Login.jsx`

### Chat workspace

- [Chat page](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/pages/ChatPage.jsx): page · `src/pages/ChatPage.jsx`
- [Chat and conversations](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/hooks/useChat.js): state hooks · Loads conversations and performs chat backend operations. · `src/hooks/useChat.js`
- [Chat window](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/Chat/ChatWindow.jsx): workspace container · `src/components/Chat/ChatWindow.jsx`
- [Message input and files](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/Chat/ChatInput.jsx): submission UI · `src/components/Chat/ChatInput.jsx`
- [Messages and citations](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/Chat/MessageBubble.jsx): response UI · `src/components/Chat/MessageBubble.jsx`
- [Conversation sidebar](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/Sidebar/Sidebar.jsx): history navigation · `src/components/Sidebar/Sidebar.jsx`

### Documents

- [Documents page](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/pages/DocumentsPage.jsx): page · `src/pages/DocumentsPage.jsx`
- [Document state](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/hooks/useDocuments.js): React hook · Manages document API state and actions. · `src/hooks/useDocuments.js`
- [Document table and upload](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/components/Documents/DocumentTable.jsx): document UI · `src/components/Documents/DocumentTable.jsx`

### External boundary

- [API definitions](https://github.com/bhagwatjadhav9422/geniev2frontend/blob/main/src/config/api.js): backend client config · Centralizes external endpoint configuration. · `src/config/api.js`
- **Backend services**: external backend · Provides APIs, persistence, ingestion, inference, and server-side authorization.

## Connections

- Vite browser runtime → React entry: serves
- React entry → Application shell: mounts
- Application shell → Protected route: guards app routes
- Application shell → Login and signup: routes unauthenticated users
- Protected route → Chat page: permits
- Protected route → Documents page: permits
- Protected route → Admin route: passes admin route
- Admin route → Admin panel: permits admins
- Login and signup → Auth state: authenticate
- Protected route → Auth state: checks session
- Auth state → Token storage: persists token
- Auth state → API definitions: uses endpoints
- Chat page → Chat window: hosts
- Chat page → Conversation sidebar: hosts
- Chat window → Message input and files: accepts submissions
- Chat window → Messages and citations: renders responses
- Conversation sidebar → Chat and conversations: selects conversations
- Message input and files → Chat and conversations: sends messages and files
- Chat and conversations → API definitions: calls API
- Documents page → Document table and upload: hosts
- Document table and upload → Document state: manages corpus
- Document state → API definitions: calls API
- API definitions → Backend services: HTTP API
