How lengvietcuong/examinai works
Main Project Components
• Frontend (Next.js Application)
• The “app” directory shows Next.js’s file-based routing with files like layout.tsx and page.tsx.
• Different UI sections such as the header, sidebar, and chat interface are implemented in the “components” folder.
• Chat Module
• Under “components/chat”, there are several subcomponents for conversations, greetings, messages, and user inputs.
• Components to show the chat’s structure (conversation handling, scoring, corrections, etc.).
• Header and Sidebar UI
• The “components/header” folder contains items for control and profile areas, while “components/sidebar” has UI for conversation history and chat controls.
• Shared UI and Utility Components
• The “components/ui” directory contains reusable UI components (buttons, dialogs, dropdowns) that maintain a consistent look and feel.
• External Integrations / Libraries
• The “lib” folder includes integrations with external services like Deepgram (likely for speech processing) and Firebase (for authentication or data storage).
• The “public” folder holds JSON files with band descriptors and speaking questions that likely drive the examiner’s feedback.
• State Management
• The “stores” directory indicates the use of global state management (e.g., conversationStore, examinerStateStore) to coordinate UI state across components.
• Utility Functions and Types
• The “utils” folder holds helper functions for essay submission, prompt extraction, streaming responses, etc.
• Custom TypeScript types are maintained in the “types” folder.
Relationships and Interactions
• The User Interface (frontend) consists of interrelated components where:
• The Header shows user-related actions (sign in, profile details).
• The Sidebar provides navigation for conversation history and initiating new chats.
• The Chat interface (with its subcomponents) handles user interaction, message display, correction feedback, and suggestions.
• State Management:
• The various “stores” modules interact with UI components to maintain a consistent conversation flow and examiner state.
• Backend / External Services:
• API calls and integrations (found under “lib”) facilitate features like real-time speech-to-text (Deepgram) and storing sessions or user data (Firebase).
• Data Flow:
• User actions trigger frontend events that update state stores, and these can in turn invoke API functions from “lib” or utility functions in “utils” to process submissions or stream responses.
Architectural Patterns and Design Principles
• Component-Based Design:
• The clear separation of concerns with modular React components (organized by feature domains such as chat, header, sidebar, etc.) follows a component-based design strategy.
• Separation of UI and Logic:
• Business logic and side effects are abstracted into utilities, libraries, and state management stores, keeping the UI components focused mainly on rendering.
• Integration with External APIs:
• The code structure supports external integrations (Deepgram and Firebase) which are decoupled from the UI, suggesting the use of service layer abstraction.
• Next.js Conventions:
• Use of file-based routing and global CSS within the “app” folder implies adherence to Next.js architectural norms.