Skip to content

Latest commit

 

History

History
130 lines (129 loc) · 7.5 KB

File metadata and controls

130 lines (129 loc) · 7.5 KB

Project Structure

lite-chat/
├── docs/                              # Documentation
│   ├── setup.md                       # Setup & installation guide
│   ├── api-reference.md               # Full API endpoint reference
│   ├── backend-architecture.md        # Backend system design
│   ├── frontend-architecture.md       # Frontend system design
│   ├── testing.md                     # Testing guide
│   └── project-structure.md           # This file
│
├── backend/                           # FastAPI backend
│   ├── app/
│   │   ├── main.py                    # App entry, lifespan, CORS, routers
│   │   ├── config.py                  # All configuration settings
│   │   ├── database.py                # SQLite schema, connection, init
│   │   │
│   │   ├── routes/                    # API endpoint handlers
│   │   │   ├── chat.py                # POST /api/chat, /api/chat/regenerate
│   │   │   ├── conversations.py       # CRUD /api/conversations
│   │   │   ├── models.py             # GET /api/models, POST /api/models/pull
│   │   │   └── user.py               # GET/PUT /api/user
│   │   │
│   │   ├── services/                  # Business logic layer
│   │   │   ├── chat_service.py        # Streaming, context building, summarization
│   │   │   ├── conversation_service.py # CRUD, truncation, snapshots, AI titles
│   │   │   ├── model_service.py       # Ollama model management
│   │   │   └── user_service.py        # User preferences
│   │   │
│   │   ├── schemas/                   # Pydantic request/response models
│   │   │   ├── chat.py                # ChatRequest, ChatSSEEvent
│   │   │   ├── conversation.py        # ConversationCreate, MessageResponse
│   │   │   └── user.py               # UserProfile, UserPreferencesUpdate
│   │   │
│   │   └── prompts/                   # LLM prompt templates
│   │       └── summarize.py           # Conversation summarization prompt
│   │
│   ├── test/                          # Backend tests
│   │   ├── conftest.py                # Fixtures: in-memory DB, test client
│   │   ├── test_conversation_service.py  # 23 service unit tests
│   │   └── test_conversation_routes.py   # 10 API integration tests
│   │
│   ├── data/
│   │   └── chat.db                    # SQLite database (auto-created)
│   │
│   ├── requirements.txt               # Python dependencies
│   └── pytest.ini                     # Pytest configuration
│
├── frontend/                          # Next.js frontend
│   ├── src/
│   │   ├── app/                       # Next.js App Router pages
│   │   │   ├── layout.tsx             # Root layout, dark theme, providers
│   │   │   ├── page.tsx               # Home — empty state or active chat
│   │   │   ├── providers.tsx          # Toaster provider
│   │   │   ├── globals.css            # Tailwind + custom scrollbar styles
│   │   │   ├── chat/
│   │   │   │   └── [conversationId]/
│   │   │   │       └── page.tsx       # Conversation view
│   │   │   └── settings/
│   │   │       └── page.tsx           # User settings
│   │   │
│   │   ├── components/
│   │   │   ├── layout/                # App shell
│   │   │   │   ├── Sidebar.tsx        # Conversation list, new chat, settings
│   │   │   │   ├── SidebarItem.tsx    # Conversation row with context menu
│   │   │   │   └── Header.tsx         # Sidebar toggle, new chat, model selector
│   │   │   │
│   │   │   ├── chat/                  # Chat interface
│   │   │   │   ├── ChatView.tsx       # Main container (messages + input)
│   │   │   │   ├── MessageList.tsx    # Scrollable message area
│   │   │   │   ├── MessageBubble.tsx  # Message wrapper
│   │   │   │   ├── UserMessage.tsx    # User message with optional image
│   │   │   │   ├── AssistantMessage.tsx # AI response with thinking + markdown
│   │   │   │   ├── ThinkingBlock.tsx  # Collapsible reasoning display
│   │   │   │   ├── MessageActions.tsx # Copy, edit, delete, regenerate
│   │   │   │   ├── StreamingIndicator.tsx # Typing indicator
│   │   │   │   └── TokenStats.tsx     # Tokens/sec display
│   │   │   │
│   │   │   ├── input/                 # Message input
│   │   │   │   ├── ChatInput.tsx      # Text area + send button
│   │   │   │   ├── ImageUpload.tsx    # Image attachment handler
│   │   │   │   └── ImagePreview.tsx   # Attached image thumbnail
│   │   │   │
│   │   │   ├── models/
│   │   │   │   └── ModelSelector.tsx  # Model dropdown
│   │   │   │
│   │   │   ├── settings/
│   │   │   │   └── SettingsForm.tsx   # User preferences form
│   │   │   │
│   │   │   ├── shared/                # Shared components
│   │   │   │   ├── ConnectionStatus.tsx # Backend health indicator
│   │   │   │   ├── EmptyState.tsx     # "Start a conversation" screen
│   │   │   │   └── MarkdownRenderer.tsx # Markdown + code highlighting
│   │   │   │
│   │   │   └── ui/                    # shadcn/ui components
│   │   │       ├── button.tsx, input.tsx, textarea.tsx
│   │   │       ├── dialog.tsx, dropdown-menu.tsx
│   │   │       ├── scroll-area.tsx, separator.tsx
│   │   │       └── badge.tsx, skeleton.tsx, tooltip.tsx, sonner.tsx
│   │   │
│   │   ├── hooks/
│   │   │   └── useSidebar.ts          # Sidebar persist, drag-to-resize
│   │   │
│   │   ├── stores/                    # Zustand state management
│   │   │   ├── chatStore.ts           # Conversations, messages, streaming
│   │   │   ├── modelStore.ts          # Available models
│   │   │   └── userStore.ts           # User profile
│   │   │
│   │   └── lib/                       # Utilities and API clients
│   │       ├── types.ts               # TypeScript interfaces
│   │       ├── constants.ts           # API URL, limits, dimensions
│   │       ├── utils.ts               # Helpers (cn, groupByDate, etc.)
│   │       ├── parseThinking.ts       # Extract thinking from responses
│   │       ├── api.ts                 # Base fetch wrapper
│   │       └── api/                   # API endpoint functions
│   │           ├── chat.ts            # sendChatMessage, regenerate
│   │           ├── conversations.ts   # CRUD operations
│   │           ├── models.ts          # List/pull models
│   │           ├── user.ts            # Get/update user
│   │           └── health.ts          # Health check
│   │
│   ├── package.json
│   ├── tsconfig.json
│   ├── next.config.ts
│   └── tailwind.config.ts
│
├── README.md                          # Project overview & quick start
└── .gitignore