How bhagwatjadhav9422/geniev2frontend works
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: ProtectedRoute.jsx Protected route · useAuth.jsx Auth state · api.js API definitions · App.jsx Application shell
Components 20
App shell
- Vite browser runtime · Serves the React single-page application.
vite.config.js - React entry
src/main.jsx - Application shell · Selects page views and applies route protection.
src/App.jsx - Admin panel
src/pages/AdminPanel.jsx
Authentication
- Protected route
src/components/auth/ProtectedRoute.jsx - Admin route
src/components/auth/AdminRoute.jsx - Auth state · Coordinates client session credentials with the backend.
src/hooks/useAuth.jsx - Token storage
src/utils/token.utils.js - Login and signup
src/pages/Login.jsx
Chat workspace
- Chat page
src/pages/ChatPage.jsx - Chat and conversations · Loads conversations and performs chat backend operations.
src/hooks/useChat.js - Chat window
src/components/Chat/ChatWindow.jsx - Message input and files
src/components/Chat/ChatInput.jsx - Messages and citations
src/components/Chat/MessageBubble.jsx - Conversation sidebar
src/components/Sidebar/Sidebar.jsx
Documents
- Documents page
src/pages/DocumentsPage.jsx - Document state · Manages document API state and actions.
src/hooks/useDocuments.js - Document table and upload
src/components/Documents/DocumentTable.jsx
External boundary
- API definitions · Centralizes external endpoint configuration.
src/config/api.js - Backend services · Provides APIs, persistence, ingestion, inference, and server-side authorization.
Connections 23
- 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