This document provides a comprehensive reference for LiteChat's project organization, helping developers understand where to find specific functionality and how the codebase is structured.
liteChat/
├── docs/ # Developer documentation
├── public/ # Static assets and manifest
├── src/ # Source code
├── package.json # Dependencies and scripts
├── README.md # Project overview
├── vite.config.ts # Vite build configuration
├── tailwind.config.js # Tailwind CSS configuration
├── tsconfig.json # TypeScript configuration
└── .github/ # GitHub Actions and templates
public/
├── index.html # Main HTML template
├── manifest.json # PWA manifest
├── favicon.ico # Application icon
├── icons/ # PWA icons in various sizes
└── dev.llm.txt # Development context file
src/
├── main.tsx # React app entry point
├── App.tsx # Root component with control module registration
├── index.css # Global styles and theme variables
└── vite-env.d.ts # Vite type definitions
src/components/
├── LiteChat/ # Main application components
│ ├── LiteChat.tsx # Primary orchestrator component
│ ├── canvas/ # Conversation display area
│ │ ├── ChatCanvas.tsx # Main conversation container
│ │ ├── InteractionCard.tsx # Individual message display
│ │ ├── StreamingRenderer.tsx # Real-time response rendering
│ │ └── MarkdownRenderer.tsx # Markdown and code highlighting
│ ├── chat/ # Sidebar and conversation management
│ │ ├── ChatControlWrapper.tsx # Chat control container
│ │ ├── ConversationList.tsx # Conversation sidebar
│ │ └── ProjectTree.tsx # Hierarchical project display
│ ├── common/ # Shared UI components
│ │ ├── ErrorBoundary.tsx # Error handling
│ │ ├── ModalManager.tsx # Modal system coordinator
│ │ ├── LoadingSpinner.tsx # Loading indicators
│ │ └── icons/ # Custom icon components
│ ├── file-manager/ # VFS interface components
│ │ ├── FileManager.tsx # Main file manager container
│ │ ├── FileManagerTable.tsx # File/folder listing
│ │ ├── FileManagerToolbar.tsx # File operations toolbar
│ │ └── FileManagerBreadcrumb.tsx # Navigation breadcrumb
│ ├── prompt/ # Prompt input area
│ │ ├── PromptWrapper.tsx # Prompt container and submission logic
│ │ ├── InputArea.tsx # Text input component
│ │ └── PromptControlWrapper.tsx # Control module container
│ ├── project-settings/ # Project configuration modals
│ │ ├── ProjectSettingsModal.tsx # Main project settings
│ │ └── tabs/ # Project settings tabs
│ └── settings/ # Application settings
│ ├── SettingsModal.tsx # Main settings modal
│ └── tabs/ # Settings tab components
├── ui/ # shadcn/ui primitive components
│ ├── button.tsx # Button component
│ ├── input.tsx # Input component
│ ├── dialog.tsx # Dialog/modal primitives
│ ├── tabs.tsx # Tab navigation
│ ├── select.tsx # Select dropdown
│ ├── switch.tsx # Toggle switch
│ ├── slider.tsx # Range slider
│ ├── textarea.tsx # Multi-line text input
│ ├── tooltip.tsx # Tooltip component
│ ├── popover.tsx # Popover component
│ ├── scroll-area.tsx # Custom scrollbar
│ ├── separator.tsx # Visual separator
│ ├── badge.tsx # Badge/chip component
│ ├── progress.tsx # Progress bar
│ └── sonner.tsx # Toast notifications
└── OnBoardingRant.tsx # Initial welcome screen
src/controls/
├── components/ # UI components for control modules
│ ├── assistant-settings/ # Assistant behavior settings
│ ├── auto-title/ # Auto-title generation control
│ ├── canvas-actions/ # Message action buttons
│ ├── file-control/ # File attachment control
│ ├── global-model-selector/ # Model selection control
│ ├── image-generation/ # Image generation control
│ ├── parameter-control/ # AI parameter controls
│ ├── provider-settings/ # Provider configuration
│ ├── reasoning-control/ # Reasoning mode toggle
│ ├── system-prompt/ # System prompt override
│ ├── usage-display/ # Token usage indicator
│ ├── vfs-control/ # VFS file selection
│ └── web-search/ # Web search toggle
└── modules/ # Control module implementations
├── AssistantSettingsModule.ts # Assistant settings tab
├── AutoTitleControlModule.ts # Auto-title functionality
├── CopyActionControlModule.ts # Copy message action
├── FileControlModule.ts # File attachment system
├── GeneralSettingsModule.ts # General settings tab
├── GitToolsModule.ts # Git operation tools
├── GlobalModelSelectorModule.ts # Global model selection
├── ImageGenerationControlModule.ts # Image generation
├── ParameterControlModule.ts # AI parameter controls
├── ProviderSettingsModule.ts # Provider management
├── ReasoningControlModule.ts # Reasoning mode
├── RegenerateActionControlModule.ts # Regenerate response
├── SystemPromptControlModule.ts # System prompt override
├── ThemeSettingsControlModule.ts # Theme settings
├── UrlParameterControlModule.ts # URL parameter handling
├── UsageDisplayControlModule.ts # Token usage display
├── VfsControlModule.ts # VFS file selection
├── VfsToolsModule.ts # VFS AI tools
└── WebSearchControlModule.ts # Web search functionality
src/store/
├── conversation.store.ts # Conversations and sync repositories
├── interaction.store.ts # AI interactions and streaming
├── project.store.ts # Project hierarchy management
├── provider.store.ts # AI provider and model configuration
├── settings.store.ts # Application settings
├── ui.store.ts # UI state (modals, panels, etc.)
├── vfs.store.ts # Virtual file system state
├── input.store.ts # Prompt input and file attachments
├── prompt.store.ts # Next prompt state
├── control.store.ts # Control module registry
├── mod.store.ts # Modding system state
└── rules.store.ts # Rules and tags for prompt engineering
src/services/
├── ai.service.ts # AI model interaction and streaming
├── conversation.service.ts # Conversation management logic
├── interaction.service.ts # Interaction processing
├── persistence.service.ts # Database operations
├── import-export.service.ts # Data import/export functionality
├── sync.service.ts # Git synchronization logic
├── model-fetcher.ts # AI model list fetching
└── event-action-coordinator.service.ts # Event-to-store routing
src/lib/
├── litechat/ # Core LiteChat utilities
│ ├── initialization.ts # App startup and module initialization
│ ├── event-emitter.ts # Central event bus
│ ├── db.ts # Dexie database schema
│ ├── vfs-operations.ts # VFS file operations
│ ├── vfs-git-operations.ts # Git operations on VFS
│ ├── file-manager-utils.ts # File path utilities
│ ├── provider-helpers.ts # AI provider utilities
│ ├── ai-helpers.ts # AI interaction helpers
│ ├── constants.ts # Application constants
│ └── markdown-utils.ts # Markdown processing utilities
└── utils.ts # General utility functions
src/types/
├── litechat/ # LiteChat-specific types
│ ├── events/ # Event definitions
│ │ ├── app.events.ts # Application lifecycle events
│ │ ├── conversation.events.ts # Conversation events
│ │ ├── interaction.events.ts # AI interaction events
│ │ ├── project.events.ts # Project management events
│ │ ├── provider.events.ts # Provider configuration events
│ │ ├── settings.events.ts # Settings events
│ │ ├── ui.events.ts # UI state events
│ │ ├── vfs.events.ts # VFS events
│ │ ├── prompt.events.ts # Prompt events
│ │ ├── input.events.ts # Input events
│ │ ├── mod.events.ts # Modding events
│ │ ├── rules.events.ts # Rules and tags events
│ │ ├── sync.events.ts # Sync events
│ │ ├── canvas.events.ts # Canvas events
│ │ └── control.registry.events.ts # Control registry events
│ ├── chat.ts # Conversation and message types
│ ├── interaction.ts # AI interaction types
│ ├── project.ts # Project structure types
│ ├── provider.ts # AI provider and model types
│ ├── settings.ts # Application settings types
│ ├── vfs.ts # Virtual file system types
│ ├── prompt.ts # Prompt and input types
│ ├── control.ts # Control module types
│ ├── modding.ts # Modding system types
│ ├── rules.ts # Rules and tags types
│ └── sync.ts # Git sync types
└── vite-env.d.ts # Vite environment types
src/modding/
├── api-factory.ts # Creates ModApi instances for mods
└── loader.ts # Loads and executes mod scripts
src/hooks/
├── useItemEditing.ts # Generic item editing state
├── useScrollToBottom.ts # Auto-scroll behavior
├── useDebounce.ts # Debounced values
└── useLocalStorage.ts # Local storage integration
App.tsx- DefinescontrolModulesToRegisterarrayLiteChat.tsx- CallsperformFullInitializationinitialization.ts- Handles module instantiation and registration- Control modules register UI components via ModApi
- Component wrappers render registered controls
event-emitter.ts- Central mitt instanceevents/directory - Event name and payload definitionsmodding.ts-ModEventPayloadMapaggregates all event typesevent-action-coordinator.service.ts- Routes events to stores- Stores register action handlers for events
- Components emit request events
EventActionCoordinatorServiceroutes to store actions- Stores update state using Immer middleware
- Stores emit change events
- Components react to state changes
LiteChat.tsx- Determines VFS context based on selectionvfs.store.ts- Manages VFS initialization and switchingvfs-operations.ts- Low-level file operationsfile-manager/components - UI for file operations
vite.config.ts- Vite bundler configuration with pluginstsconfig.json- TypeScript compiler optionstailwind.config.js- Tailwind CSS customization
package.json- Dependencies, scripts, and metadata.github/workflows/- CI/CD pipeline definitions
- Components: PascalCase (e.g.,
ChatCanvas.tsx) - Stores: kebab-case with
.store.tssuffix - Services: kebab-case with
.service.tssuffix - Types: kebab-case with
.tssuffix - Events: kebab-case with
.events.tssuffix
// External libraries
import React from 'react';
import { create } from 'zustand';
// Internal components
import { Button } from '@/components/ui/button';
import { ChatCanvas } from '@/components/LiteChat/canvas/ChatCanvas';
// Services and utilities
import { PersistenceService } from '@/services/persistence.service';
import { emitter } from '@/lib/litechat/event-emitter';
// Types
import type { Conversation } from '@/types/litechat/chat';- Components: Group by feature area (e.g.,
canvas/,prompt/) - Stores: One store per domain with clear responsibilities
- Services: Business logic separated from UI concerns
- Types: Mirror the directory structure for easy navigation
This file structure supports LiteChat's modular architecture while maintaining clear separation of concerns and making the codebase navigable for developers.