Overall Architecture โ
This document describes the overall architecture design of the HaloLight project, including directory structure, layered design, and core patterns.
Directory Structure Specification โ
Standard Directory Layout โ
src/
โโโ app/ # Page routes (Next.js) or views/ (Vue)
โ โโโ (admin)/ # Admin route group
โ โ โโโ dashboard/ # Dashboard
โ โ โโโ users/ # User management
โ โ โโโ roles/ # Role management
โ โ โโโ permissions/ # Permission management
โ โ โโโ settings/ # System settings
โ โ โโโ profile/ # User profile
โ โโโ (auth)/ # Auth route group
โ โโโ login/ # Login
โ โโโ register/ # Register
โ โโโ forgot-password/
โ โโโ reset-password/
โโโ components/ # Reusable components
โ โโโ ui/ # Basic UI components (shadcn/ui)
โ โโโ layout/ # Layout components
โ โโโ dashboard/ # Dashboard components
โ โโโ charts/ # Chart components
โ โโโ shared/ # Shared business components
โโโ hooks/ (composables/) # Reusable logic
โโโ stores/ # State management
โโโ services/ # API service layer
โโโ lib/ # Utility library
โโโ types/ # TypeScript type definitions
โโโ styles/ # Global styles
โโโ mocks/ # Mock dataLayered Architecture โ
Four-Layer Architecture Design โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ View Layer โ
โ Pages / Views / Routes โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Component Layer โ
โ UI Components / Layout / Dashboard โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ State Layer โ
โ Stores / Composables / Hooks โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Service Layer โ
โ API Services / Data Fetching / Cache โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโLayer Responsibilities โ
| Layer | Responsibility | Framework Implementation |
|---|---|---|
| View Layer | Page routing, layout assembly | Next.js Pages / Vue Views |
| Component Layer | UI rendering, user interaction | React/Vue/Svelte Components |
| State Layer | Application state, business logic | Zustand / Pinia / Stores |
| Service Layer | API calls, data caching | TanStack Query / Axios |
Provider Hierarchy โ
React/Next.js Provider Chain โ
<ThemeProvider>
<MockProvider>
<QueryClientProvider>
<AuthProvider>
<PermissionProvider>
<WebSocketProvider>
<ErrorProvider>
<ToastProvider>
{children}
</ToastProvider>
</ErrorProvider>
</WebSocketProvider>
</PermissionProvider>
</AuthProvider>
</QueryClientProvider>
</MockProvider>
</ThemeProvider>Vue Plugin Registration Order โ
app.use(pinia)
app.use(router)
app.use(i18n)
app.use(mockPlugin)
app.use(queryPlugin)
app.use(permissionPlugin)Layout System โ
AdminLayout Structure โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Header โ
โ [Logo] [Breadcrumb] [Search] [User] [Settings]
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ โ
โ Sidebar โ Content โ
โ โ โ
โ - Menu โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ - Nav โ โ Page Content โ โ
โ โ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Footer โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโAuthLayout Structure โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ โโโโโโโโโโโโโโ โ
โ โ โ โ
โ โ Auth Form โ โ
โ โ โ โ
โ โโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโRoute Configuration Specification โ
Route Meta Information โ
interface RouteMeta {
title: string // Page title
icon?: string // Menu icon
permission?: string // Required permission
hidden?: boolean // Hidden in menu
keepAlive?: boolean // Cache component
breadcrumb?: boolean // Show breadcrumb
}Standard Route Table โ
| Path | Page | Permission |
|---|---|---|
/dashboard | Dashboard | dashboard:view |
/users | User list | users:list |
/users/create | Create user | users:create |
/users/:id | User detail | users:view |
/users/:id/edit | Edit user | users:update |
/roles | Role list | roles:list |
/permissions | Permission management | permissions:list |
/settings | System settings | settings:view |
/profile | User profile | - (authenticated) |
Environment Variable Specification โ
Variable Naming Convention โ
| Prefix | Framework | Description |
|---|---|---|
NEXT_PUBLIC_ | Next.js | Client-side visible |
VITE_ | Vue/Vite | Client-side visible |
PUBLIC_ | SvelteKit | Client-side visible |
| No prefix | All | Server-side only |
Required Environment Variables โ
# API Configuration
*_API_BASE_URL=http://localhost:3000/api
*_API_TIMEOUT=30000
# Authentication Configuration
*_AUTH_SECRET=your-secret-key
*_TOKEN_EXPIRES=7d
# Mock Toggle
*_ENABLE_MOCK=true
# Feature Toggles
*_ENABLE_WEBSOCKET=true
*_ENABLE_ANALYTICS=falseCode Organization Principles โ
1. Feature First โ
Organize code by feature modules, not by file types:
# Recommended โ
features/
โโโ users/
โ โโโ components/
โ โโโ hooks/
โ โโโ services/
โ โโโ types/
# Avoid โ
components/
โโโ UserList.tsx
โโโ UserForm.tsx
hooks/
โโโ useUsers.ts
services/
โโโ userService.ts2. Proximity Principle โ
Place component-specific styles, types, and utilities in the component directory:
components/
โโโ UserCard/
โโโ index.tsx
โโโ UserCard.module.css
โโโ UserCard.types.ts
โโโ useUserCard.ts3. Shared Extraction โ
Extract code used in multiple places to shared locations:
# Used by 2+ components โ Extract to components/shared/
# Used in 3+ places โ Extract to lib/ or utils/4. Specification First โ
When adding or modifying features, first clarify interfaces, constraints, and directory structure in halolight/docs, then sync to halolight and halolight-vue to avoid implementation divergence.