Complete project architecture and structure guide. Use when exploring the codebase, understanding project organization, finding files, or needing comprehensive architectural context...
The directory listings below are a curated map of key locations, not an exhaustive tree.
packages/,src/store/, route groups etc. grow over time ā runlsagainst the real directory for the current set.
Open-source, modern-design AI Agent Workspace: LobeHub (previously LobeChat).
This repo is the open-source root (github.com/lobehub/lobehub, package @lobehub/lobehub).
Supported platforms:
apps/desktopLogo emoji: š¤Æ
| Category | Technology |
|---|---|
| Framework | Next.js 16 + React 19 |
| Routing | SPA inside Next.js with react-router-dom |
| Language | TypeScript |
| UI Components | @lobehub/ui, antd |
| CSS-in-JS | antd-style |
| Icons | lucide-react, @ant-design/icons |
| i18n | react-i18next |
| State | zustand |
| URL Params | nuqs |
| Data Fetching | SWR |
| React Hooks | aHooks |
| Date/Time | dayjs |
| Utilities | es-toolkit |
| API | TRPC (type-safe) |
| Database | Neon PostgreSQL + Drizzle ORM |
| Testing | Vitest |
Exact versions live in the root
package.jsonā check there, not here.
Flat layout ā apps/, packages/, and src/ all sit at the repo root. No
git submodules.
(repo root)
āāā apps/
ā āāā cli/ # LobeHub CLI
ā āāā desktop/ # Electron desktop app
ā āāā device-gateway/ # Device gateway service
ā āāā server/ # Next.js-backed server (`@/server/*` alias)
ā āāā src/
ā āāā router-hono/ # Hono endpoint routers and standalone runtime
ā āāā ... # featureFlags, globalConfig, modules, routers, services, utils, workflows
āāā docs/ # changelog, development, self-hosting, usage
āāā locales/ # en-US, zh-CN, ...
āāā packages/ # ~80 @lobechat/* workspace packages ā `ls` for the full set. Key ones:
ā āāā agent-runtime/ # Agent runtime core
ā āāā agent-signal/ # Agent Signal pipeline
ā āāā agent-tracing/ # Tracing / snapshots
ā āāā builtin-tool-*/ # Per-tool packages (calculator, web-browsing, claude-code, ...)
ā āāā builtin-tools/ # Central registries that compose builtin-tool-*
ā āāā context-engine/
ā āāā database/ # src/{models,schemas,repositories}
ā āāā model-bank/ # Model definitions & provider cards
ā āāā model-runtime/ # src/{core,providers}
ā āāā locales/ # i18n source of truth: packages/locales/src/default/
ā āāā env/ # env schemas (@/envs/* ā packages/env/src/*)
ā āāā app-config/
ā āāā business/ # Open-source stubs (config, const, model-bank, model-runtime) ā overridden by cloud
ā āāā types/
ā āāā utils/
āāā src/
āāā app/
ā āāā (backend)/ # api, f, market, middleware, oidc, trpc, webapi
ā āāā spa/ # SPA HTML template service
ā āāā spa-auth/ # Auth HTML shell (SSR)
āāā routes/ # SPA page segments (thin ā delegate to features/)
ā āāā (main)/ (mobile)/ (desktop)/ (popup)/ auth/ onboarding/ share/
āāā spa/ # SPA entries + router config
ā āāā entry.{web,mobile,desktop,popup}.tsx
ā āāā router/
āāā business/ # Open-source stubs (client/server) ā cloud repo provides real impls
āāā features/ # Domain business components
āāā store/ # ~30 zustand stores ā `ls` for the full set
āāā ... # components, hooks, layout, libs, services, types, utils
| Layer | Location |
|---|---|
| UI Components | src/components, src/features |
| SPA Pages | src/routes/ |
| React Router | src/spa/router/ |
| Global Providers | src/layout |
| Zustand Stores | src/store |
| Client Services | src/services/ |
| REST API | src/app/(backend)/webapi |
| tRPC Routers | apps/server/src/routers/{async|lambda|mobile|tools} |
| Server Services | apps/server/src/services (can access DB) |
| Server Modules | apps/server/src/modules (no DB access) |
| Feature Flags | apps/server/src/featureFlags |
| Global Config | apps/server/src/globalConfig |
| DB Schema | packages/database/src/schemas |
| DB Model | packages/database/src/models |
| DB Repository | packages/database/src/repositories |
| Third-party | src/libs (analytics, oidc, etc.) |
| Builtin Tools | packages/builtin-tool-*, packages/builtin-tools |
| Open-source stub | src/business/*, packages/business/* (this repo) |
React UI ā Store Actions ā Client Service ā TRPC Lambda ā Server Services ā DB Model ā PostgreSQL
This open-source repo is consumed by a separate, private cloud (SaaS) repo
as a git submodule mounted at lobehub/. The cloud repo provides:
src/business/{client,server} and packages/business/* implementations
that override the stubs shipped here.(cloud)/, embed/), cloud-only stores (e.g.
subscription/), cloud-only TRPC routers (billing, budget, risk control, ā¦),
and Vercel cron routes under src/app/(backend)/cron/.@/store/x ā cloud src/store/x first, then
lobehub/packages/store/src/x, then lobehub/src/store/x. Cloud override wins.When working in this repo alone, ignore the cloud layer ā the stubs in
src/business/ and packages/business/ are the source of truth here.