- Executive Summary
- UI/UX Architecture & Component Hierarchy
- Global State Architecture (Zustand Store Slices)
- Interactive Component Specifications
- Networking & API Integration Strategy
- Design System & Styling Tokens
- Performance, Accessibility & Security Optimizations
- Exhaustive Code Base Directory Structure
- Developer Operations & Testing Guide
The Drive AI Client Application is a high-performance single-page web interface built on Next.js (App Router Architecture), TailwindCSS, and Zustand. It renders an interactive Google Drive workspace integrated with real-time AI tools:
- Google Drive Workspace Experience: Supports drag-and-drop navigation, dynamic Grid/List view switching, nested folder trees, search filtering, and multi-item batch operations.
- Real-Time Visual Upload Tracking: A floating status widget tracks multi-file upload progress sequentially through real-time job status tags (
PENDING,UPLOADING,INDEXING,DONE,FAILED). - Grounded AI Copilot Drawer: An interactive slide-in panel offering voice dictation, conversation threads, citation cards, and file-scoped Q&A context.
- One-Click Translation: An interactive modal allowing users to translate documents into 13 target languages and export them as PDF, DOCX, or TXT files.
| Category | Technology | Version | Purpose in Client Architecture | Selection Rationale & Advantage |
|---|---|---|---|---|
| Framework & Engine | Next.js (App Router) | ^15.1.0 |
Client Framework & Server Rendering | Provides automatic route optimization, layout composition, server-side font optimization (next/font), and React Server Components support. |
| UI Library | React | ^19.0.0 |
UI Component Engine | Declarative component model utilizing custom hooks (useState, useEffect, useCallback, useRef) for smooth reactivity. |
| Language | TypeScript | ^5.7.3 |
Type-Safe Architecture | Guarantees strict compile-time verification across Zustand stores, API payload DTOs, and component props interfaces. |
| State Management | Zustand | ^5.0.0 |
Global State Slices Engine | Unopinionated, lightweight store manager using atomic slices (useDriveStore, useAiStore, useAuthStore) without Context Provider wrapper boilerplate or unnecessary re-renders. |
| Styling & Theme | TailwindCSS | ^3.4.1 |
Utility-First Styling System | Rapid development utility classes coupled with custom design tokens for glassmorphism, responsive breakpoints, and dark mode themes. |
| Vanilla CSS Tokens | CSS3 Variables | Core Color & Theme Variables | CSS variables defining HSL custom surface values, backdrop blurs, slide-in transitions, and card container states. | |
| API Client Adapter | Axios | ^1.7.9 |
HTTP Communications Gateway | Intercepts all outgoing requests to inject JWT Bearer Authorization headers automatically while standardizing error handling. |
| Icons & Design Assets | Lucide React | ^0.474.0 |
Vector UI Component Icons | Lightweight, consistent vector graphics rendered directly as React component SVGs. |
| Notifications | Sonner | ^1.7.2 |
Non-Blocking Toast Provider | Stackable toast notifications for tracking upload status, download completions, and server exceptions. |
| Audio Capture | HTML5 MediaRecorder | Browser Native | Microphone Audio Stream Dictation | Captures microphone audio streams (.webm) directly in the browser for voice-to-text dictation. |
| Testing Suite | Vitest | ^4.1.10 |
Vite-Powered Unit Test Runner | Ultra-fast unit testing runner executing component mocks and store slice tests. |
graph TD
%% Main Layout Root
subgraph Dashboard Viewport [Next.js App Router: /dashboard/page.tsx]
SearchHeader[SearchHeader Component]
Sidebar[Sidebar Component]
subgraph Canvas Workspace [Workspace Canvas Engine]
Toolbar[Toolbar Action Bar]
Explorer[ExplorerPane Component]
subgraph Explorer Components [Explorer Layout Modes]
GridView[Grid View Canvas]
ListView[List View Table]
CommandBar[Floating Bulk Command Bar]
end
end
subgraph Floating Overlays [Floating Utility Layers]
UploadWidget[Floating Upload Progress Widget]
CopilotDrawer[AiCopilotDrawer Slide-in Panel]
TranslateModal[TranslateModal Overlay]
ConfirmModal[ConfirmDialog Overlay]
end
end
%% State Orchestration
DriveStore[(Zustand: useDriveStore)]
AiStore[(Zustand: useAiStore)]
AuthStore[(Zustand: useAuthStore)]
Explorer -->|Updates Checked Set| DriveStore
DriveStore -->|Controls Visibility| CommandBar
Explorer -->|Attaches File & Opens Drawer| AiStore
AiStore -->|Controls Visibility| CopilotDrawer
Explorer -->|Opens Translation Options| TranslateModal
To prevent component re-rendering issues, global client state is organized into modular Zustand store slices:
ββββββββββββββββββββββββββ
β Zustand Store Root β
βββββββββββββ¬βββββββββββββ
β
ββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β useDriveStore β β useAiStore β β useAuthStore β
ββββββββββββββββββββ€ ββββββββββββββββββββ€ ββββββββββββββββββββ€
β - folderUuid β β - isDrawerOpen β β - token β
β - selectedUuids β β - activeFileUuid β β - user β
β - activeTab β β - activeFileName β β - isAuthenticatedβ
β - viewMode β β - chatMessages β ββββββββββββββββββββ
β - searchQuery β β - isRecording β
ββββββββββββββββββββ ββββββββββββββββββββ
Manages directory navigation, selection sets, and workspace filters:
currentFolderUuid: Active directory UUID (nullfor root).selectedUuids:Set<string>containing currently checked file and folder UUIDs.activeTab: Workspaces scope ("drive" | "trash" | "starred").viewMode: Visualization format ("grid" | "list").searchQuery: String query used for real-time item name filtering.
Manages the AI Copilot side-drawer panel and conversational contexts:
isDrawerOpen: Boolean controlling drawer slide-in positioning.activeFileUuid/activeFileName: Stores the file currently locked to conversation context.chatMessages: Array of thread objects containing messages, timestamps, and citation sources.openDrawerForFile(fileUuid, fileName): Atomically locks the active file context and opens the drawer.
Manages JWT tokens and identity session states persisted across reloads.
Located at bottom-22 right-6, this widget provides feedback during multi-file uploads:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Uploading 3 items [ _ ] [ X ]β
β βββββββββββββββββββββββββββββββββββββββββββ 66% β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π project_proposal.pdf [ INDEXING ] β
β π financial_report.xlsx [ UPLOADING ] β
β πΌοΈ architecture_diagram.png [ PENDING ] β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Sequential Execution: Posts files sequentially via Axios to maintain responsive UI feedback.
- Live Status Tag Machine:
PENDING: Waiting in upload queue.UPLOADING: Binary bytes streaming to backend gateway.INDEXING: Backend is parsing text and generating vector embeddings.DONE: Successfully saved and indexed.FAILED: Error occurred (e.g. format rejection).
- Checkboxes: Checked items display checkboxes on hover (Grid view) or inline table rows (List view).
- Master Select-All Header: List view table header features an indeterminate checkbox.
- Global Workspace Select-All: A Select All / Deselect All action button in the header selects or clears all visible files and folders across both Grid and List modes.
- Floating Command Bar: Positioned at
bottom-6 left-1/2 -translate-x-1/2:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 3 items selected β [Move to Trash] [Restore] [Cancel (X)] β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Implemented inside AiCopilotDrawer:
sequenceDiagram
autonumber
actor User
participant Component as AiCopilotDrawer Component
participant Media as Browser MediaRecorder API
participant API as POST /ai/transcribe Endpoint
User->>Component: Click Microphone Icon
Component->>Media: navigator.mediaDevices.getUserMedia({ audio: true })
Media-->>Component: Audio Stream Active
Component->>Component: Update UI (pulsing red stop button)
User->>Component: Click Stop Button
Component->>Media: mediaRecorder.stop()
Media-->>Component: Audio Blob (.webm)
Component->>API: Post FormData(audioBlob)
API-->>Component: { text: "Summarize this document" }
Component->>Component: Automatically populate chat input field
TranslateModal.tsx provides an interface to translate and export documents:
- Selected File Name: Displays target file title.
- Target Language Selector: Choice of 13 languages (Hindi, English, Spanish, French, German, Italian, Japanese, Chinese, Marathi, Tamil, Telugu, Kannada, Bengali).
- Export Format Selector: PDF (.pdf), DOCX (.docx), or TXT (.txt).
- Auto-Refresh: Triggers
onSuccess()to refresh directory files upon completion.
When a user selects "Ask AI" on any file:
openDrawerForFile(fileUuid, fileName)opens the side drawer.- A file tag is rendered above the chat composer:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π financial_audit.pdf [β] β
β βββββββββββββββββββββββββββββββββββββββββ¬βββββββββββββββ β
β β Ask AI a question... β [ποΈ] [ Send]β β
β βββββββββββββββββββββββββββββββββββββββββ΄βββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Submitting queries passes
fileUuidin the POST body to/ai/chat. The backend scopes the RAG vector search exclusively to that document. - Clicking
[β]clearsactiveFileUuidandactiveFileName, returning the chat to general workspace mode.
API calls are routed through a centralized Axios client (src/lib/axios.ts):
// Automatic JWT Bearer Token Injection
api.interceptors.request.use((config) => {
const token = useAuthStore.getState().token;
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});- Error Handling: Handles errors using Sonner toast notifications:
toast.error(err.response?.data?.message || "Failed to process request");
The application uses TailwindCSS utilities with custom CSS variables (src/app/globals.css):
:root {
--background: #090d16;
--surface: #111827;
--surface-hover: #1f2937;
--card: #131b2e;
--border: #1f293d;
--foreground: #f9fafb;
--muted-foreground: #9ca3af;
--primary: #6366f1;
}- Glassmorphic Overlays:
backdrop-blur-md bg-card/80 border border-border/50 shadow-2xl - Animations: Fluid slide-in panels (
animate-in fade-in slide-in-from-right-4 duration-300) and soft pulse glows.
- Virtual DOM Cleanup: Clears audio tracks and blob streams on component unmount.
- Keyboard Accessibility: Supports
ESCkey bindings to close active modals. - Event Propagation Safety: Uses
e.stopPropagation()on context buttons to avoid unwanted file downloads or parent selections.
p-1-frontend/
βββ src/
β βββ app/
β β βββ globals.css # Design tokens & dark theme variables
β β βββ layout.tsx # Root HTML wrapper and font providers
β β βββ page.tsx # Landing redirection controller
β β βββ (auth)/
β β β βββ login/page.tsx # Secure Login view page
β β βββ (dashboard)/
β β βββ dashboard/page.tsx # Core workspace canvas & upload status manager
β βββ features/
β β βββ auth/components/ # Login/Signup forms
β β βββ drive/
β β βββ types.ts # Frontend data structures
β β βββ components/
β β βββ Sidebar.tsx # Directory tree navigation
β β βββ SearchHeader.tsx# Header query input
β β βββ Toolbar.tsx # View mode toggles
β β βββ ExplorerPane.tsx# Grid/List file canvas & command bar
β β βββ AiCopilotDrawer.tsx # Chat drawer & voice dictation
β β βββ TranslateModal.tsx # Document translation dialog
β β βββ ShareModal.tsx # Sharing & public link generator
β β βββ ConfirmDialog.tsx # Destruction warning dialogs
β β βββ AuditPane.tsx # System activity logs
β βββ lib/
β β βββ axios.ts # Axios client with JWT interceptor
β β βββ logger.ts # Component log formatter
β βββ store/
β βββ authStore.ts # Authentication state slice
β βββ driveStore.ts # Selection sets & directory state slice
β βββ aiStore.ts # Drawer & file attachment state slice
# π Server & Connection Config
PORT=3000
NODE_ENV=development
# π Logging Configuration (debug, info, warn, error)
NEXT_PUBLIC_LOG_LEVEL="debug"
# π Backend API Connection (Exposed to Client Side)
# Next.js requires NEXT_PUBLIC_ prefix to expose variables to browser code
NEXT_PUBLIC_API_URL="http://localhost:7001" // or you backend url
# π Localization Settings
NEXT_PUBLIC_DEFAULT_TIMEZONE="Asia/Kolkata"# Install dependencies
npm install
# Start Next.js development server
npm run devOpen http://localhost:3000 to launch the workspace dashboard.
# Run Vitest test runner (26 unit tests)
npm test
# Run ESLint quality audit
npx eslint src/Contributions, issues, and feature requests are welcome! Feel free to check out the repository or reach out:
- Developer Portfolio & Info: https://www.liladhar.com/