You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: contributing/Basic/Feature-Development.md
+11-11
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,14 @@ This document aims to guide developers on how to develop a complete feature requ
4
4
5
5
We will use the implementation of sessionGroup as an example: [✨ feat: add session group manager](https://github.com/lobehub/lobe-chat/pull/1055), and explain the complete implementation process through the following six main sections:
6
6
7
-
1. Data Model / Database Definition
8
-
2. Service Implementation / Model Implementation
9
-
3. Frontend Data Flow Store Implementation
10
-
4. UI Implementation and Action Binding
11
-
5. Data Migration
12
-
6. Data Import and Export
7
+
1.[Data Model / Database Definition](#1-data-model--database-definition)
8
+
2.[Service Implementation / Model Implementation](#2-service-implementation--model-implementation)
9
+
3.[Frontend Data Flow Store Implementation](#3-frontend-data-flow-store-implementation)
10
+
4.[UI Implementation and Action Binding](#4-ui-implementation-and-action-binding)
11
+
5.[Data Migration](#5-data-migration)
12
+
6.[Data Import and Export](#6-data-import-and-export)
13
13
14
-
## 1. Database Section
14
+
## 1. Data Model / Database Definition
15
15
16
16
To implement the Session Group feature, it is necessary to define the relevant data model and indexes at the database level.
17
17
@@ -119,7 +119,7 @@ As a result, you can now view the `sessionGroups` table in the `LOBE_CHAT_DB` in
## 2. Service Implementation / Model Implementation
123
123
124
124
### Define Model
125
125
@@ -176,7 +176,7 @@ class SessionService {
176
176
}
177
177
```
178
178
179
-
## 3. Store Action Section
179
+
## 3. Frontend Data Flow Store Implementation
180
180
181
181
In the LobeChat application, the Store module is used to manage the frontend state of the application. The Actions within it are functions that trigger state updates, usually by calling methods in the service layer to perform actual data processing operations and then updating the state in the Store. We use `zustand` as the underlying dependency for the Store module. For a detailed practical introduction to state management, you can refer to [📘 Best Practices for State Management](../State-Management/State-Management-Intro.zh-CN.md).
182
182
@@ -351,7 +351,7 @@ Since all data retrieval in the UI is implemented using syntax like `useSessionS
351
351
>
352
352
> If you are not familiar with the concept and functionality of selectors, you can refer to the section [📘 Data Storage and Retrieval Module](./State-Management-Selectors.en-US) for relevant information.
353
353
354
-
## IV. UI Section
354
+
## 4. UI Implementation and Action Binding
355
355
356
356
Bind Store Action in the UI component to implement interactive logic, for example `CreateGroupModal`:
357
357
@@ -570,7 +570,7 @@ export class LocalDB extends Dexie {
570
570
571
571
This is our data migration strategy. When performing the migration, it is essential to ensure the correctness of the migration script and validate the migration results through thorough testing.
572
572
573
-
## VI. Data Import and Export
573
+
## 6. Data Import and Export
574
574
575
575
In LobeChat, the data import and export feature is designed to ensure that users can migrate their data between different devices. This includes session, topic, message, and settings data. In the implementation of the Session Group feature, we also need to handle data import and export to ensure that the complete exported data can be restored exactly the same on other devices.
Welcome to the LobeChat technical development getting started guide. LobeChat is an AI conversation application built on the Next.js framework, which integrates a series of technology stacks to achieve diverse functions and features. This guide will provide a detailed introduction to the main technical components of LobeChat and how to configure and use these technologies in your development environment.
3
+
Welcome to the LobeChat Technical Development Getting Started Guide. LobeChat is an AI conversation application built on the Next.js framework, incorporating a range of technology stacks to achieve diverse functionalities and features. This guide will detail the main technical components of LobeChat and how to configure and use these technologies in your development environment.
-[Appendix: Resources and References](#appendix-resources-and-references)
9
13
10
14
## Basic Technology Stack
11
15
12
-
The core technology stack of LobeChat includes:
16
+
The core technology stack of LobeChat is as follows:
13
17
14
-
-**Framework**: We have chosen [Next.js](https://nextjs.org/), a powerful React framework that provides key features such as server-side rendering, routing framework, and Router Handler for our project.
15
-
-**Component Library**: We use [Ant Design (antd)](https://ant.design/) as the basic component library, and also introduce[lobe-ui](https://github.com/lobehub/lobe-ui) as our business component library.
16
-
-**State Management**: We have opted for[zustand](https://github.com/pmndrs/zustand), a lightweight and easy-to-use state management library.
18
+
-**Framework**: We chose [Next.js](https://nextjs.org/), a powerful React framework that provides key features such as server-side rendering, routing framework, and Router Handler.
19
+
-**Component Library**: We use [Ant Design (antd)](https://ant.design/) as the basic component library, along with[lobe-ui](https://github.com/lobehub/lobe-ui) as our business component library.
20
+
-**State Management**: We selected[zustand](https://github.com/pmndrs/zustand), a lightweight and easy-to-use state management library.
17
21
-**Network Requests**: We use [swr](https://swr.vercel.app/), a React Hooks library for data fetching.
18
-
-**Routing**: For routing management, we directly use the solution provided by [Next.js](https://nextjs.org/) itself.
19
-
-**Internationalization**: We use [i18next](https://www.i18next.com/) to implement multi-language support for the application.
22
+
-**Routing**: For routing management, we directly use the solution provided by [Next.js](https://nextjs.org/).
23
+
-**Internationalization**: We use [i18next](https://www.i18next.com/) to support multiple languages in the application.
20
24
-**Styling**: We use [antd-style](https://github.com/ant-design/antd-style), a CSS-in-JS library that complements Ant Design.
21
25
-**Unit Testing**: We use [vitest](https://github.com/vitest-dev/vitest) for unit testing.
22
26
@@ -26,18 +30,82 @@ The folder directory structure of LobeChat is as follows:
26
30
27
31
```bash
28
32
src
29
-
├── app #Main logic of the application and code related to state management
33
+
├── app #Code related to the main logic and state management of the application
30
34
├── components # Reusable UI components
31
-
├── config # Application configuration files, including client-side environment variables and server-side environment variables
35
+
├── config # Application configuration files, including clientand server environment variables
32
36
├── const # Used to define constants, such as action types, route names, etc.
33
-
├── features #Function modules related to business features, such as Agent settings, plugin development pop-ups, etc.
34
-
├── hooks # Custom utility hooks reused throughout the application
37
+
├── features #Business-related feature modules, such as Agent settings, plugin development pop-ups, etc.
38
+
├── hooks # Custom utility Hooks reusable across the application
35
39
├── layout # Application layout components, such as navigation bars, sidebars, etc.
36
40
├── locales # Language files for internationalization
37
41
├── services # Encapsulated backend service interfaces, such as HTTP requests
38
42
├── store # Zustand store for state management
39
43
├── types # TypeScript type definition files
40
-
└── utils #Common utility functions
44
+
└── utils #General utility functions
41
45
```
42
46
43
-
For a detailed introduction to the directory structure, please refer to: [Folder Directory Structure](Folder-Structure.en-US.md)
47
+
For a detailed introduction to the directory structure, see: [Folder Directory Structure](Folder-Structure.zh-CN.md)
48
+
49
+
## Local Development Environment Setup
50
+
51
+
This section outlines setting up the development environment and local development. Before starting, please ensure that Node.js, Git, and your chosen package manager (Bun or PNPM) are installed in your local environment.
52
+
53
+
We recommend using WebStorm as your integrated development environment (IDE).
54
+
55
+
1.**Get the code**: Clone the LobeChat code repository locally:
2.**Install dependencies**: Enter the project directory and install the required dependencies:
62
+
63
+
```bash
64
+
cd lobe-chat
65
+
# If you use Bun
66
+
bun install
67
+
# If you use PNPM
68
+
pnpm install
69
+
```
70
+
71
+
3.**Run and debug**: Start the local development server and begin your development journey:
72
+
73
+
```bash
74
+
# Start the development server with Bun
75
+
bun run dev
76
+
# Visit http://localhost:3010 to view the application
77
+
```
78
+
79
+
> \[!IMPORTANT]\
80
+
> If you encounter the error "Could not find 'stylelint-config-recommended'" when installing dependencies with `npm`, please reinstall the dependencies using `pnpm` or `bun`.
81
+
82
+
Now, you should be able to see the welcome page of LobeChat in your browser. For a detailed environment setup guide, please refer to [Development Environment Setup Guide](Setup-Development.zh-CN.md).
83
+
84
+
## Code Style and Contribution Guide
85
+
86
+
In the LobeChat project, we place great emphasis on the quality and consistency of the code. For this reason, we have established a series of code style standards and contribution processes to ensure that every developer can smoothly participate in the project. Here are the code style and contribution guidelines you need to follow as a developer.
87
+
88
+
-**Code Style**: We use `@lobehub/lint` to unify the code style, including ESLint, Prettier, remarklint, and stylelint configurations. Please adhere to our code standards to maintain code consistency and readability.
89
+
-**Contribution Process**: We use gitmoji and semantic release for code submission and release processes. Please use gitmoji to annotate your commit messages and ensure compliance with the semantic release standards so that our automation systems can correctly handle version control and releases.
90
+
91
+
All contributions will undergo code review. Maintainers may suggest modifications or requirements. Please respond actively to review comments and make timely adjustments. We look forward to your participation and contribution.
92
+
93
+
For detailed code style and contribution guidelines, please refer to [Code Style and Contribution Guide](Contributing-Guidelines.zh-CN.md).
94
+
95
+
## Internationalization Implementation Guide
96
+
97
+
LobeChat uses `i18next` and `lobe-i18n` to implement multilingual support, ensuring a global user experience.
98
+
99
+
Internationalization files are located in `src/locales`, containing the default language (Chinese). We generate other language JSON files automatically through `lobe-i18n`.
100
+
101
+
If you want to add a new language, follow specific steps detailed in [New Language Addition Guide](../Internationalization/Add-New-Locale.zh-CN.md). We encourage you to participate in our internationalization efforts to provide better services to global users.
102
+
103
+
For a detailed guide on internationalization implementation, please refer to [Internationalization Implementation Guide](../Internationalization/Internationalization-Implementation.zh-CN.md).
104
+
105
+
## Appendix: Resources and References
106
+
107
+
To support developers in better understanding and using the technology stack of LobeChat, we provide a comprehensive list of resources and references — [LobeChat Resources and References](https://github.com/lobehub/lobe-chat/wiki/Resources.zh-CN) - Visit our maintained list of resources, including tutorials, articles, and other useful links.
108
+
109
+
We encourage developers to utilize these resources to deepen their learning and enhance their skills, join community discussions through [LobeChat GitHub Discussions](https://github.com/lobehub/lobe-chat/discussions) or [Discord](https://discord.com/invite/AYFPHvv2jT), ask questions, or share your experiences.
110
+
111
+
If you have any questions or need further assistance, please do not hesitate to contact us through the above channels.
0 commit comments