diff --git a/README.md b/README.md
index 0cae43e28e214..611c91d3fd256 100644
--- a/README.md
+++ b/README.md
@@ -59,9 +59,11 @@ One-click **FREE** deployment of your private OpenAI ChatGPT/Claude/Gemini/Groq/
- [`5` Text to Image Generation](#5-text-to-image-generation)
- [`6` Plugin System (Function Calling)](#6-plugin-system-function-calling)
- [`7` Agent Market (GPTs)](#7-agent-market-gpts)
- - [`8` Progressive Web App (PWA)](#8-progressive-web-app-pwa)
- - [`9` Mobile Device Adaptation](#9-mobile-device-adaptation)
- - [`10` Custom Themes](#10-custom-themes)
+ - [`8` Support Local / Remote Database](#8-support-local--remote-database)
+ - [`9` Support Clerk / NextAuth user auth systems](#9-support-clerk--nextauth-user-auth-systems)
+ - [`10` Progressive Web App (PWA)](#10-progressive-web-app-pwa)
+ - [`11` Mobile Device Adaptation](#11-mobile-device-adaptation)
+ - [`12` Custom Themes](#12-custom-themes)
- [`*` What's more](#-whats-more)
- [⚡️ Performance](#️-performance)
- [🛳 Self Hosting](#-self-hosting)
@@ -280,9 +282,44 @@ Our marketplace is not just a showcase platform but also a collaborative space.
+[![][image-feat-database]][docs-feat-database]
+
+### `8` [Support Local / Remote Database][docs-feat-database]
+
+LobeChat supports the use of both server-side and local databases. Depending on your needs, you can choose the appropriate deployment solution:
+
+- **Local database**: suitable for users who want more control over their data and privacy protection. LobeChat uses CRDT (Conflict-Free Replicated Data Type) technology to achieve multi-device synchronization. This is an experimental feature aimed at providing a seamless data synchronization experience.
+- **Server-side database**: suitable for users who want a more convenient user experience. LobeChat supports PostgreSQL as a server-side database. For detailed documentation on how to configure the server-side database, please visit [Configure Server-side Database](https://lobehub.com/docs/self-hosting/advanced/server-database).
+
+Regardless of which database you choose, LobeChat can provide you with an excellent user experience.
+
+
+
+[![][back-to-top]](#readme-top)
+
+
+
+[![][image-feat-auth]][docs-feat-auth]
+
+### `9` [Support Multi-User Management][docs-feat-auth]
+
+LobeChat supports multi-user management and provides two main user authentication and management solutions to meet different needs:
+
+- **next-auth**: LobeChat integrates `next-auth`, a flexible and powerful identity verification library that supports multiple authentication methods, including OAuth, email login, credential login, etc. With `next-auth`, you can easily implement user registration, login, session management, social login, and other functions to ensure the security and privacy of user data.
+
+- **Clerk**: For users who need more advanced user management features, LobeChat also supports `Clerk`, a modern user management platform. `Clerk` provides richer functions, such as multi-factor authentication (MFA), user profile management, login activity monitoring, etc. With `Clerk`, you can get higher security and flexibility, and easily cope with complex user management needs.
+
+Regardless of which user management solution you choose, LobeChat can provide you with an excellent user experience and powerful functional support.
+
+
+
+[![][back-to-top]](#readme-top)
+
+
+
[![][image-feat-pwa]][docs-feat-pwa]
-### `8` [Progressive Web App (PWA)][docs-feat-pwa]
+### `10` [Progressive Web App (PWA)][docs-feat-pwa]
We deeply understand the importance of providing a seamless experience for users in today's multi-device environment.
Therefore, we have adopted Progressive Web Application ([PWA](https://support.google.com/chrome/answer/9658361)) technology,
@@ -309,7 +346,7 @@ providing smooth animations, responsive layouts, and adapting to different devic
[![][image-feat-mobile]][docs-feat-mobile]
-### `9` [Mobile Device Adaptation][docs-feat-mobile]
+### `11` [Mobile Device Adaptation][docs-feat-mobile]
We have carried out a series of optimization designs for mobile devices to enhance the user's mobile experience. Currently, we are iterating on the mobile user experience to achieve smoother and more intuitive interactions. If you have any suggestions or ideas, we welcome you to provide feedback through GitHub Issues or Pull Requests.
@@ -321,7 +358,7 @@ We have carried out a series of optimization designs for mobile devices to enhan
[![][image-feat-theme]][docs-feat-theme]
-### `10` [Custom Themes][docs-feat-theme]
+### `12` [Custom Themes][docs-feat-theme]
As a design-engineering-oriented application, LobeChat places great emphasis on users' personalized experiences,
hence introducing flexible and diverse theme modes, including a light mode for daytime and a dark mode for nighttime.
@@ -629,7 +666,7 @@ Every bit counts and your one-time donation sparkles in our galaxy of support! Y
Copyright © 2024 [LobeHub][profile-link].
-This project is [MIT](./LICENSE) licensed.
+This project is [Apache 2.0](./LICENSE) licensed.
@@ -665,6 +702,8 @@ This project is [MIT](./LICENSE) licensed.
[docs-docker]: https://lobehub.com/docs/self-hosting/platform/docker
[docs-env-var]: https://lobehub.com/docs/self-hosting/environment-variables
[docs-feat-agent]: https://lobehub.com/docs/usage/features/agent-market
+[docs-feat-auth]: https://lobehub.com/docs/usage/features/auth
+[docs-feat-database]: https://lobehub.com/docs/usage/features/database
[docs-feat-local]: https://lobehub.com/docs/usage/features/local-llm
[docs-feat-mobile]: https://lobehub.com/docs/usage/features/mobile
[docs-feat-plugin]: https://lobehub.com/docs/usage/features/plugin-system
@@ -706,6 +745,8 @@ This project is [MIT](./LICENSE) licensed.
[github-trending-url]: https://trendshift.io/repositories/2256
[image-banner]: https://github.com/lobehub/lobe-chat/assets/28616219/9f155dff-4737-429f-9cad-a70a1a860c5f
[image-feat-agent]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/268670869-f1ffbf66-42b6-42cf-a937-9ce1f8328514.png
+[image-feat-auth]: https://github.com/lobehub/lobe-chat/assets/17870709/8ce70e15-40df-451e-b700-66090fe5b8c2
+[image-feat-database]: https://github.com/lobehub/lobe-chat/assets/17870709/acf39ea2-74b3-46ae-8eb8-54a51f7f1d36
[image-feat-local]: https://github.com/lobehub/lobe-chat/assets/28616219/ca9a21bc-ea6c-4c90-bf4a-fa53b4fb2b5c
[image-feat-mobile]: https://gw.alipayobjects.com/zos/kitchen/R441AuFS4W/mobile.webp
[image-feat-plugin]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/268670883-33c43a5c-a512-467e-855c-fa299548cce5.png
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 54d2963d64653..31b50f5ce2949 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -58,9 +58,11 @@
- [`5` Text to Image 文生图](#5-text-to-image-文生图)
- [`6` 插件系统 (Function Calling)](#6-插件系统-function-calling)
- [`7` 助手市场 (GPTs)](#7-助手市场-gpts)
- - [`8` 渐进式 Web 应用 (PWA)](#8-渐进式-web-应用-pwa)
- - [`9` 移动设备适配](#9-移动设备适配)
- - [`10` 自定义主题](#10-自定义主题)
+ - [`8` 支持本地 / 远程数据库](#8-支持本地--远程数据库)
+ - [`9` 支持多用户管理](#9-支持多用户管理)
+ - [`10` 渐进式 Web 应用 (PWA)](#10-渐进式-web-应用-pwa)
+ - [`11` 移动设备适配](#11-移动设备适配)
+ - [`12` 自定义主题](#12-自定义主题)
- [更多特性](#更多特性)
- [⚡️ 性能测试](#️-性能测试)
- [🛳 开箱即用](#-开箱即用)
@@ -268,9 +270,44 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
+[![][image-feat-database]][docs-feat-database]
+
+### `8` [支持本地 / 远程数据库][docs-feat-database]
+
+LobeChat 支持同时使用服务端数据库和本地数据库。根据您的需求,您可以选择合适的部署方案:
+
+- 本地数据库:适合希望对数据有更多掌控感和隐私保护的用户。LobeChat 采用了 CRDT (Conflict-Free Replicated Data Type) 技术,实现了多端同步功能。这是一项实验性功能,旨在提供无缝的数据同步体验。
+- 服务端数据库:适合希望更便捷使用体验的用户。LobeChat 支持 PostgreSQL 作为服务端数据库。关于如何配置服务端数据库的详细文档,请前往 [配置服务端数据库](https://lobehub.com/zh/docs/self-hosting/advanced/server-database)。
+
+无论您选择哪种数据库,LobeChat 都能为您提供卓越的用户体验。
+
+
+
+[![][back-to-top]](#readme-top)
+
+
+
+[![][image-feat-auth]][docs-feat-auth]
+
+### `9` [支持多用户管理][docs-feat-auth]
+
+LobeChat 支持多用户管理,提供了两种主要的用户认证和管理方案,以满足不同需求:
+
+- **next-auth**:LobeChat 集成了 `next-auth`,一个灵活且强大的身份验证库,支持多种身份验证方式,包括 OAuth、邮件登录、凭证登录等。通过 `next-auth`,您可以轻松实现用户的注册、登录、会话管理以及社交登录等功能,确保用户数据的安全性和隐私性。
+
+- **Clerk**:对于需要更高级用户管理功能的用户,LobeChat 还支持 `Clerk`,一个现代化的用户管理平台。`Clerk` 提供了更丰富的功能,如多因素认证 (MFA)、白名单、用户管理、登录活动监控等。通过 `Clerk`,您可以获得更高的安全性和灵活性,轻松应对生产级的用户管理需求。
+
+您可以根据自己的需求,选择合适的用户管理方案。
+
+
+
+[![][back-to-top]](#readme-top)
+
+
+
[![][image-feat-pwa]][docs-feat-pwa]
-### `8` [渐进式 Web 应用 (PWA)][docs-feat-pwa]
+### `10` [渐进式 Web 应用 (PWA)][docs-feat-pwa]
我们深知在当今多设备环境下为用户提供无缝体验的重要性。为此,我们采用了渐进式 Web 应用 [PWA](https://support.google.com/chrome/answer/9658361) 技术,
这是一种能够将网页应用提升至接近原生应用体验的现代 Web 技术。通过 PWA,LobeChat 能够在桌面和移动设备上提供高度优化的用户体验,同时保持轻量级和高性能的特点。
@@ -293,7 +330,7 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
[![][image-feat-mobile]][docs-feat-mobile]
-### `9` [移动设备适配][docs-feat-mobile]
+### `11` [移动设备适配][docs-feat-mobile]
针对移动设备进行了一系列的优化设计,以提升用户的移动体验。目前,我们正在对移动端的用户体验进行版本迭代,以实现更加流畅和直观的交互。如果您有任何建议或想法,我们非常欢迎您通过 GitHub Issues 或者 Pull Requests 提供反馈。
@@ -305,7 +342,7 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
[![][image-feat-theme]][docs-feat-theme]
-### `10` [自定义主题][docs-feat-theme]
+### `12` [自定义主题][docs-feat-theme]
作为设计工程师出身,LobeChat 在界面设计上充分考虑用户的个性化体验,因此引入了灵活多变的主题模式,其中包括日间的亮色模式和夜间的深色模式。
除了主题模式的切换,还提供了一系列的颜色定制选项,允许用户根据自己的喜好来调整应用的主题色彩。无论是想要沉稳的深蓝,还是希望活泼的桃粉,或者是专业的灰白,用户都能够在 LobeChat 中找到匹配自己风格的颜色选择。
@@ -650,7 +687,7 @@ $ pnpm run dev
Copyright © 2023 [LobeHub][profile-link].
-This project is [MIT](./LICENSE) licensed.
+This project is [Apache 2.0](./LICENSE) licensed.
@@ -685,6 +722,8 @@ This project is [MIT](./LICENSE) licensed.
[docs-docker]: https://lobehub.com/docs/self-hosting/platform/docker
[docs-env-var]: https://lobehub.com/docs/self-hosting/environment-variables
[docs-feat-agent]: https://lobehub.com/docs/usage/features/agent-market
+[docs-feat-auth]: https://lobehub.com/docs/usage/features/auth
+[docs-feat-database]: https://lobehub.com/docs/usage/features/database
[docs-feat-local]: https://lobehub.com/docs/usage/features/local-llm
[docs-feat-mobile]: https://lobehub.com/docs/usage/features/mobile
[docs-feat-plugin]: https://lobehub.com/docs/usage/features/plugin-system
@@ -727,6 +766,8 @@ This project is [MIT](./LICENSE) licensed.
[github-trending-url]: https://trendshift.io/repositories/2256
[image-banner]: https://github.com/lobehub/lobe-chat/assets/28616219/9f155dff-4737-429f-9cad-a70a1a860c5f
[image-feat-agent]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/268670869-f1ffbf66-42b6-42cf-a937-9ce1f8328514.png
+[image-feat-auth]: https://github.com/lobehub/lobe-chat/assets/17870709/8ce70e15-40df-451e-b700-66090fe5b8c2
+[image-feat-database]: https://github.com/lobehub/lobe-chat/assets/17870709/acf39ea2-74b3-46ae-8eb8-54a51f7f1d36
[image-feat-local]: https://github.com/lobehub/lobe-chat/assets/28616219/ca9a21bc-ea6c-4c90-bf4a-fa53b4fb2b5c
[image-feat-mobile]: https://gw.alipayobjects.com/zos/kitchen/R441AuFS4W/mobile.webp
[image-feat-plugin]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/268670883-33c43a5c-a512-467e-855c-fa299548cce5.png
diff --git a/docs/self-hosting/advanced/server-database.mdx b/docs/self-hosting/advanced/server-database.mdx
new file mode 100644
index 0000000000000..640d8e32ece00
--- /dev/null
+++ b/docs/self-hosting/advanced/server-database.mdx
@@ -0,0 +1,392 @@
+# Deploying Server-Side Database
+
+LobeChat defaults to using a client-side database (IndexedDB) but also supports using a server-side database. LobeChat uses Postgres as the backend storage database. PostgreSQL is a powerful open-source relational database management system with high scalability and standard SQL support. It provides rich data types, concurrency control, data integrity, security, and programmability, making it suitable for complex applications and large-scale data management.
+
+This article will detail how to deploy the server-side database version of LobeChat on Vercel, including: 1) database configuration; 2) identity authentication service configuration; 3) steps for setting up the S3 storage service.
+
+
+ Due to workload constraints, currently only deployment on Vercel using the server-side database
+ version is supported, with Docker version support planned for future iterations.
+
+
+## 1. Configure the Database
+
+
+
+### Prepare a Server-Side Database Instance and Obtain the Connection URL
+
+Before deployment, make sure you have prepared a Postgres database instance. You can choose either of the following methods:
+
+- `A.` Use Serverless Postgres instances like Vercel/Neon;
+- `B.` Use self-deployed Postgres instances like Docker.
+
+The configuration for both methods is slightly different, which will be distinguished in the next step.
+
+### Add Environment Variables in Vercel
+
+In Vercel's deployment environment variables, add the `DATABASE_URL` and other environment variables. Fill in the prepared Postgres database connection URL. The typical format for the database connection URL is `postgres://username:password@host:port/database`.
+
+
+
+
+
+Variables required for Serverless Postgres are as follows:
+
+```shell
+# Serverless Postgres DB Url
+DATABASE_URL=
+
+# Specify the service mode as server, otherwise it won't enter the server-side database
+NEXT_PUBLIC_SERVICE_MODE=server
+```
+
+An example of how to fill in Vercel is shown below:
+
+{' '}
+
+
+
+
+
+
+ Variables required for Node Postgres are as follows:
+
+```shell
+# Node Postgres DB Url
+DATABASE_URL=
+
+# Specify the Postgres database driver as node
+DATABASE_DRIVER=node
+
+# Specify the service mode as server, otherwise it won't enter the server-side database
+NEXT_PUBLIC_SERVICE_MODE=server
+```
+
+An example of how to fill in Vercel is shown below:
+
+{' '}
+
+
+
+
+
+
+
+### Add the `KEY_VAULTS_SECRET` Environment Variable
+
+After adding the `DATABASE_URL` environment variable, you need to add a `KEY_VAULTS_SECRET` environment variable. This variable is used to encrypt sensitive information like user-stored API keys. You can generate a random 32-character string as the key using `openssl rand -base64 32`.
+
+```shell
+KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
+```
+
+Add this to the Vercel environment variables as well.
+
+
+
+## 2. Configure the Identity Authentication Service
+
+A server-side database needs to be paired with an identity authentication service to function properly. Therefore, the corresponding identity authentication service needs to be configured.
+
+
+ Due to workload constraints, currently only Clerk is supported as an identity authentication
+ service solution. Integration with Next-Auth for server-side database is under development.{' '}
+
+
+
+
+### Prepare the Clerk Identity Authentication Service
+
+Go to [Clerk](https://clerk.com?utm_source=lobehub&utm_medium=docs) to register and create an application to obtain the corresponding Public Key and Secret Key.
+
+
+ If you are unfamiliar with Clerk, you can refer to [Authentication
+ Service-Clerk](/en/docs/self-hosting/advanced/authentication#clerk) for details on using Clerk.
+
+
+### Add Public and Private Key Environment Variables in Vercel
+
+In Vercel's deployment environment variables, add the `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` and `CLERK_SECRET_KEY` environment variables. You can click on "API Keys" in the menu, then copy the corresponding values and paste them into Vercel's environment variables.
+
+
+
+The environment variables required for this step are as follows:
+
+```shell
+NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxx
+CLERK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxx
+```
+
+Add these variables to Vercel:
+
+
+
+### Create and Configure a Webhook in Clerk
+
+Since we let Clerk handle user authentication and management entirely, we need Clerk to notify our application and store data in the database when there are changes in the user lifecycle (create, update, delete). We achieve this using the Webhook provided by Clerk.
+
+We need to add an endpoint in Clerk's Webhooks to inform Clerk to send notifications to this endpoint when a user's status changes.
+
+
+ {' '}
+
+
+Fill in your Vercel project's URL in the endpoint, such as `https://your-project.vercel.app/api/webhooks/clerk`. Then, in the Subscribe to events section, check the three user events (`user.created`, `user.deleted`, `user.updated`), and click create.
+
+
+
+### Add the Webhook Secret to Vercel Environment Variables
+
+After creation, you can find the secret of this Webhook in the bottom right corner:
+
+
+
+The corresponding environment variable name for this secret is `CLERK_WEBHOOK_SECRET`:
+
+```shell
+CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
+```
+
+Add this to Vercel's environment variables:
+
+
+
+
+
+
+
+You have now successfully configured the Clerk identity authentication service. Next, we will configure the S3 storage service.
+
+## 3. Configure S3 Storage Service
+
+LobeChat has long supported multimodal AI conversations, involving the function of uploading images to AI. In the client-side database solution, image files are stored as binary data in the browser's indexedDB database. However, this solution is not feasible in the server-side database. We need to configure the S3 storage service to store a large number of image files, and S3 can also serve as a storage solution for file uploads.
+
+
+ {' '}
+ In this article, S3 refers to a compatible S3 storage solution, which supports object storage systems
+ that comply with the Amazon S3 API. Common examples include Cloudflare R2 etc., all of which support
+ S3-compatible APIs.{' '}
+
+
+
+
+### Configure and Obtain S3 Bucket
+
+You need to go to your S3 service provider (such as AWS S3, Cloudflare R2, etc.) and create a new storage bucket. Below is an example of the creation process using Cloudflare R2.
+
+The interface of Cloudflare R2 is shown below:
+
+
+
+When creating the bucket, specify its name and then click create.
+
+
+
+### Obtain Environment Variables for the Bucket
+
+In the settings of the R2 storage bucket, you can view the bucket configuration information:
+
+
+
+The corresponding environment variables are:
+
+```shell
+# Bucket name
+S3_BUCKET=lobechat
+# Bucket request endpoint
+S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
+# Public domain for accessing the bucket
+NEXT_PUBLIC_S3_DOMAIN=https://s3-dev.your-domain.com
+```
+
+### Obtain S3 Key Environment Variables
+
+You need to obtain the access key for S3 so that the LobeChat server has permission to access the S3 storage service. In R2, you can configure the access key in the account details:
+
+
+
+Click the button in the upper right corner to create an API token, then enter the API Token creation page.
+
+
+
+Since our server-side database needs to read and write to the S3 storage service, the permissions need to be set to read and write, and only select the bucket we created, then click create.
+
+
+
+After creation, you can see the corresponding S3 API token.
+
+
+
+The corresponding environment variables are:
+
+```shell
+S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
+S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
+```
+
+### Add the Corresponding Environment Variables in Vercel
+
+The steps to obtain the required environment variables may vary for different S3 service providers, but the obtained environment variables should be consistent in the end:
+
+```shell
+# S3 Key
+S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
+S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
+
+# Bucket name
+S3_BUCKET=lobechat
+# Bucket request endpoint
+S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
+# Public domain for accessing the bucket
+NEXT_PUBLIC_S3_DOMAIN=https://s3-dev.your-domain.com
+
+# Bucket region, such as us-west-1, generally not required to add, but some service providers may need to configure
+# S3_REGION=us-west-1
+```
+
+Then enter the above environment variables into Vercel's environment variables:
+
+
+
+### Configure Cross-Origin Resource Sharing (CORS)
+
+Since S3 storage services are often on a separate domain, cross-origin access needs to be configured.
+
+In R2, you can find the CORS configuration in the settings of the storage bucket:
+
+
+
+Add a CORS rule to allow requests from your domain (in this case, `https://your-project.vercel.app`):
+
+
+
+Example configuration:
+
+```json
+[
+ {
+ "AllowedOrigins": ["https://your-project.vercel.app"],
+ "AllowedMethods": ["GET", "PUT", "HEAD", "POST", "DELETE"],
+ "AllowedHeaders": ["*"]
+ }
+]
+```
+
+After configuration, click save.
+
+
+
+## 4. Deployment and Verification
+
+After completing the above steps, the configuration of the server database should be done. Next, we can deploy LobeChat to Vercel and then visit your Vercel link to verify if the server database is working correctly.
+
+
+ ### Redeploy the latest commit
+
+After configuring the environment variables, you need to redeploy the latest commit and wait for the deployment to complete.
+
+
+
+### Check if the features are working properly
+
+If you click on the login button in the top left corner and the login popup appears normally, then you have configured it successfully. Enjoy using it\~
+
+
+
+
+
+
+
+
+
+
+
+## Appendix
+
+### Overview of Server Database Environment Variables
+
+For easy copying, here is a summary of the environment variables required to configure the server data:
+
+```shell
+# Specify the service mode as server
+NEXT_PUBLIC_SERVICE_MODE=server
+
+# Postgres database URL
+DATABASE_URL=
+KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
+
+# Clerk related configurations
+NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxx
+CLERK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxx
+CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
+
+# S3 related configurations
+# S3 keys
+S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
+S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
+
+# Bucket name
+S3_BUCKET=lobechat
+# Bucket request endpoint
+S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
+# Public access domain for the bucket
+NEXT_PUBLIC_S3_DOMAIN=https://s3-dev.your-domain.com
+# Bucket region, such as us-west-1, generally not needed to add, but some service providers may require configuration
+# S3_REGION=us-west-1
+```
diff --git a/docs/self-hosting/advanced/server-database.zh-CN.mdx b/docs/self-hosting/advanced/server-database.zh-CN.mdx
new file mode 100644
index 0000000000000..ad1612b046d8c
--- /dev/null
+++ b/docs/self-hosting/advanced/server-database.zh-CN.mdx
@@ -0,0 +1,376 @@
+# 使用服务端数据库部署
+
+LobeChat 默认使用客户端数据库(IndexedDB),同时也支持使用服务端数据库。LobeChat 采用了 Postgres 作为后端存储数据库。PostgreSQL是一种强大的开源关系型数据库管理系统,具备高度扩展性和标准SQL支持。它提供了丰富的数据类型、并发处理、数据完整性、安全性及可编程性,适用于复杂应用和大规模数据管理。
+
+本文将详细介绍如何在 Vercel 中部署服务端数据库版 LobeChat,包括: 1)数据库配置;2)身份验证服务配置;3) S3 存储服务的设置步骤。
+
+
+ 限于工作量原因,目前仅支持在 Vercel 中部署使用服务端数据库版本,Docker 版本将会在后续迭代中支持。
+
+
+## 一、 配置数据库
+
+
+
+### 准备服务端数据库实例,获取连接 URL
+
+在部署之前,请确保你已经准备好 Postgres 数据库实例,你可以选择以下任一方式:
+
+- `A.` 使用 Vercel / Neon 等 Serverless Postgres 实例;
+- `B.` 使用 Docker 等自部署 Postgres 实例。
+
+两者的配置方式略有不同,在下一步会有所区分。
+
+### 在 Vercel 中添加环境变量
+
+在 Vercel 的部署环境变量中,添加 `DATABASE_URL` 等环境变量,将上一步准备好的 Postgres 数据库连接 URL 填入其中。数据库连接 URL 的通常格式为 `postgres://username:password@host:port/database`。
+
+
+
+
+
+ Serverless Postgres 需要填写的变量如下:
+
+ ```shell
+ # Serverless Postgres DB Url
+ DATABASE_URL=
+
+ # 指定 service mode 为 server,否则不会进入服务端数据库
+ NEXT_PUBLIC_SERVICE_MODE=server
+ ```
+
+ 在 Vercel 中填写的示例如下:
+
+
+
+
+
+
+ Node Postgres 需要填写的变量如下:
+
+ ```shell
+ # Node Postgres DB Url
+ DATABASE_URL=
+
+ # 指定 Postgres database driver 为 node
+ DATABASE_DRIVER=node
+
+ # 指定 service mode 为 server,否则不会进入服务端数据库
+ NEXT_PUBLIC_SERVICE_MODE=server
+ ```
+
+ 在 Vercel 中填写的示例如下:
+
+
+
+
+
+
+
+### 添加 `KEY_VAULTS_SECRET` 环境变量
+
+在完成数据库 DATABASE_URL 环境变量添加后,需要添加一个 `KEY_VAULTS_SECRET` 环境变量。该变量用于加密用户存储的 apikey 等敏感信息。你可以使用 `openssl rand -base64 32` 生成一个随机的 32 位字符串作为密钥。
+
+```shell
+KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
+```
+
+同样需要将其添加到 Vercel 环境变量中。
+
+
+
+## 二、 配置身份验证服务
+
+服务端数据库需要搭配用户身份验证服务才可以正常使用。因此需要配置对应的身份验证服务。
+
+
+ 同样由于工作量原因,目前仅支持 Clerk 作为身份验证服务方案, Next-Auth 的服务端数据库集成有待开发
+
+
+
+
+### 准备 Clerk 身份验证服务
+
+前往 [Clerk](https://clerk.com?utm_source=lobehub&utm_medium=docs) 注册并创建应用,获取相应的 Public Key 和 Secret Key。
+
+
+ 如果对 Clerk 不太了解,可以查阅
+ [身份验证服务-Clerk](/zh/docs/self-hosting/advanced/authentication#clerk) 了解 Clerk 的使用详情。
+
+
+### 在 Vercel 中添加公、私钥环境变量
+
+在 Vercel 的部署环境变量中,添加 `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` 和 `CLERK_SECRET_KEY` 环境变量。你可以在菜单中点击「API Keys」,然后复制对应的值填入 Vercel 的环境变量中。
+
+
+
+此步骤所需的环境变量如下:
+
+```shell
+NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxx
+CLERK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxx
+```
+
+添加上述变量到 Vercel 中:
+
+
+
+### 在 Clerk 中创建并配置 Webhook
+
+由于我们让 Clerk 完全接管用户鉴权与管理,因此我们需要在 Clerk 用户生命周期变更时(创建、更新、删除)中通知我们的应用并存储落库。我们通过 Clerk 提供的 Webhook 来实现这一诉求。
+
+我们需要在 Clerk 的 Webhooks 中添加一个端点(Endpoint),告诉 Clerk 当用户发生变更时,向这个端点发送通知。
+
+
+
+在 endppint 中填写你的 Vercel 项目的 URL,如 `https://your-project.vercel.app/api/webhooks/clerk`。然后在订阅事件(Subscribe to events)中,勾选 user 的三个事件(`user.created` 、`user.deleted`、`user.updated`),然后点击创建。
+
+
+
+### 将 Webhook 秘钥添加到 Vercel 环境变量
+
+创建完毕后,可以在右下角找到该 Webhook 的秘钥:
+
+
+
+这个秘钥所对应的环境变量名为 `CLERK_WEBHOOK_SECRET`:
+
+```shell
+CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
+```
+
+将其添加到 Vercel 的环境变量中:
+
+
+
+
+
+这样,你已经成功配置了 Clerk 身份验证服务。接下来我们将配置 S3 存储服务。
+
+## 三、 配置 S3 存储服务
+
+LobeChat 在很早以前就支持了多模态 的 AI 会话,其中涉及到图片上传给 AI 的功能。在客户端数据库方案中,图片文件直接以二进制数据存储在浏览器 indexedDB 数据库,但在服务端数据库中这个方案并不可行。我们需要配置 S3 存储服务来存储大量的图片文件,同时 S3 也可以作为文件上传的存储方案。
+
+
+ 在本文,S3所指代的是指兼容 S3 存储方案,即支持 Amazon S3 API 的对象存储系统,常见例如 Cloudflare
+ R2 、阿里云 OSS 等均支持 S3 兼容 API。
+
+
+
+
+ ### 配置并获取 S3 存储桶
+
+ 你需要前往你的 S3 服务提供商(如 AWS S3、Cloudflare R2 等)并创建一个新的存储桶(Bucket)。接下来以 Cloudflare R2 为例,介绍创建流程。
+
+ 下图是 Cloudflare R2 的界面:
+
+
+
+ 创建存储桶时将指定其名称,然后点击创建。
+
+
+ ### 获取存储桶相关环境变量
+
+ 在 R2 存储桶的设置中,可以看到桶配置的信息:
+
+
+
+其对应的环境变量为:
+
+```shell
+# 存储桶的名称
+S3_BUCKET=lobechat
+# 存储桶的请求端点
+S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
+# 存储桶对外的访问域名
+NEXT_PUBLIC_S3_DOMAIN=https://s3-dev.your-domain.com
+```
+
+ ### 获取 S3 密钥环境变量
+
+ 你需要获取 S3 的访问密钥,以便 LobeChat 的服务端有权限访问 S3 存储服务。在 R2 中,你可以在账户详情中配置访问密钥:
+
+
+
+ 点击右上角按钮创建 API token,进入创建 API Token 页面
+
+
+
+ 鉴于我们的服务端数据库需要读写 S3 存储服务,因此权限需要选择读与写,并只选择我们所创建的存储桶,然后点击创建。
+
+
+
+ 创建完成后,就可以看到对应的 S3 API token
+
+
+
+ 其对应的环境变量为:
+
+```shell
+S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
+S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
+```
+
+### 在 Vercel 中添加对应的环境变量
+
+ 不同 S3 服务商获取所需环境变量的步骤可能有所不同,但最终获得到的环境变量应该都是一致的:
+
+```shell
+# S3 秘钥
+S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
+S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
+
+# 存储桶的名称
+S3_BUCKET=lobechat
+# 存储桶的请求端点
+S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
+# 存储桶对外的访问域名
+NEXT_PUBLIC_S3_DOMAIN=https://s3-dev.your-domain.com
+
+# 桶的区域,如 us-west-1,一般来说不需要添加,但某些服务商则需要配置
+# S3_REGION=us-west-1
+```
+
+然后将上述环境变量填入 Vercel 的环境变量中:
+
+
+
+ ### 配置跨域
+
+ 由于 S3 存储服务往往是一个独立的网址,因此需要配置跨域访问。
+
+ 在 R2 中,你可以在存储桶的设置中找到跨域配置:
+
+
+
+ 添加跨域规则,允许你的域名(在上文是 `https://your-project.vercel.app`)来源的请求:
+
+
+
+示例配置如下:
+
+```json
+[
+ {
+ "AllowedOrigins": ["https://your-project.vercel.app"],
+ "AllowedMethods": ["GET", "PUT", "HEAD", "POST", "DELETE"],
+ "AllowedHeaders": ["*"]
+ }
+]
+```
+
+配置后点击保存即可。
+
+
+
+## 四、部署并验证
+
+通过上述步骤之后,我们应该就完成了服务端数据库的配置。接下来我们可以将 LobeChat 部署到 Vercel 上,然后访问你的 Vercel 链接,验证服务端数据库是否正常工作。
+
+
+ ### 重新部署最新的 commit
+
+配置好环境变量后,你需要重新部署最新的 commit,并等待部署完成。
+
+
+
+### 检查功能是否正常
+
+如果你点击左上角登录,可以正常显示登录弹窗,那么说明你已经配置成功了,尽情享用吧~
+
+
+
+
+
+
+
+## 附录
+
+### 服务端数据库环境变量一览
+
+为方便一键复制,在此汇总配置服务端数据所需要的环境变量:
+
+```shell
+# 指定服务模式为 server
+NEXT_PUBLIC_SERVICE_MODE=server
+
+# Postgres 数据库 URL
+DATABASE_URL=
+KEY_VAULTS_SECRET=jgwsK28dspyVQoIf8/M3IIHl1h6LYYceSYNXeLpy6uk=
+
+# Clerk 相关配置
+NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxx
+CLERK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxx
+CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
+
+# S3 相关配置
+# S3 秘钥
+S3_ACCESS_KEY_ID=9998d6757e276cf9f1edbd325b7083a6
+S3_SECRET_ACCESS_KEY=55af75d8eb6b99f189f6a35f855336ea62cd9c4751a5cf4337c53c1d3f497ac2
+
+# 存储桶的名称
+S3_BUCKET=lobechat
+# 存储桶的请求端点
+S3_ENDPOINT=https://0b33a03b5c993fd2f453379dc36558e5.r2.cloudflarestorage.com
+# 存储桶对外的访问域名
+NEXT_PUBLIC_S3_DOMAIN=https://s3-dev.your-domain.com
+# 桶的区域,如 us-west-1,一般来说不需要添加,但某些服务商则需要配置
+# S3_REGION=us-west-1
+```
diff --git a/docs/self-hosting/advanced/upstream-sync.zh-CN.mdx b/docs/self-hosting/advanced/upstream-sync.zh-CN.mdx
index 18623aecbde53..80258cb6fa98b 100644
--- a/docs/self-hosting/advanced/upstream-sync.zh-CN.mdx
+++ b/docs/self-hosting/advanced/upstream-sync.zh-CN.mdx
@@ -101,38 +101,38 @@ OPENAI_MODEL_LIST=-gpt-4,-gpt-4-32k,-gpt-3.5-turbo-16k,gpt-3.5-turbo-1106=gpt-3.
```bash
#!/bin/bash
# auto-update-lobe-chat.sh
-
+
# 设置代理(可选)
-export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
-
+# export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
+
# 拉取最新的镜像并将输出存储在变量中
output=$(docker pull lobehub/lobe-chat:latest 2>&1)
-
+
# 检查拉取命令是否成功执行
if [ $? -ne 0 ]; then
exit 1
fi
-
+
# 检查输出中是否包含特定的字符串
echo "$output" | grep -q "Image is up to date for lobehub/lobe-chat:latest"
-
+
# 如果镜像已经是最新的,则不执行任何操作
if [ $? -eq 0 ]; then
exit 0
fi
-
-echo "Detected Lobe-Chat update"
-
+
+echo "Detected lobe-chat update"
+
# 删除旧的容器
-echo "Removed: $(docker rm -f Lobe-Chat)"
-
-# 运行新的容器
-echo "Started: $(docker run -d --network=host --env-file /path/to/lobe.env --name=Lobe-Chat --restart=always lobehub/lobe-chat)"
-
+echo "Removed: $(docker rm -f lobe-chat)"
+
+# 运行新的容器(请将env配置文件地址改为你的实际地址)
+echo "Started: $(docker run -d --network=host --env-file path/to/lobe.env --name=lobe-chat --restart=always lobehub/lobe-chat)"
+
# 打印更新的时间和版本
echo "Update time: $(date)"
echo "Version: $(docker inspect lobehub/lobe-chat:latest | grep 'org.opencontainers.image.version' | awk -F'"' '{print $4}')"
-
+
# 清理不再使用的镜像
docker images | grep 'lobehub/lobe-chat' | grep -v 'latest' | awk '{print $3}' | xargs -r docker rmi > /dev/null 2>&1
echo "Removed old images."
@@ -150,4 +150,4 @@ echo "Removed old images."
*/5 * * * * /path/to/auto-update-lobe-chat.sh >> /path/to/auto-update-lobe-chat.log 2>&1
```
-
+
\ No newline at end of file
diff --git a/docs/usage/features/auth.mdx b/docs/usage/features/auth.mdx
new file mode 100644
index 0000000000000..985bddf0017b6
--- /dev/null
+++ b/docs/usage/features/auth.mdx
@@ -0,0 +1,44 @@
+# Support Multi-User Management
+
+
+
+
+In modern applications, user management and identity verification are essential functions. To meet the diverse needs of different users, LobeChat provides two main user authentication and management solutions: `next-auth` and `Clerk`. Whether you are looking for simple user registration and login or need advanced multi-factor authentication and user management, LobeChat can flexibly accommodate your requirements.
+
+## next-auth: Flexible and Powerful Identity Verification Library
+
+LobeChat integrates `next-auth`, a flexible and powerful identity verification library that supports various authentication methods, including OAuth, email login, and credential login. With `next-auth`, you can easily achieve the following functions:
+
+- **User Registration and Login**: Support various authentication methods to meet different user needs.
+- **Session Management**: Efficiently manage user sessions to ensure security.
+- **Social Login**: Support quick login via various social platforms.
+- **Data Security**: Ensure the security and privacy of user data.
+
+
+
+Due to workload constraints, integration of next-auth with a server-side database has not been implemented yet. If you need to use a server-side database, please use Clerk.
+
+
+For information on using Next-Auth, you can refer to [Authentication Services - Next Auth](/en-US/docs/self-hosting/advanced/authentication#next-auth).
+
+## Clerk: Modern User Management Platform
+
+For users requiring advanced user management features, LobeChat also supports [Clerk](https://clerk.com), a modern user management platform. Clerk offers richer functionality to help you achieve higher security and flexibility:
+
+- **Multi-Factor Authentication (MFA)**: Provides higher security protection.
+- **User Profile Management**: Conveniently manage user information and configurations.
+- **Login Activity Monitoring**: Real-time monitoring of user login activities to ensure account security.
+- **Scalability**: Supports complex user management requirements.
+
+
+For information on using Clerk, you can refer to [Authentication Services - Clerk](/en-US/docs/self-hosting/advanced/authentication#clerk).
+
+
+
+If you need to use Clerk in conjunction with a server-side database, you can refer to the "Configuring Authentication Services" section in [Deploying with a Server-Side Database](/en-US/docs/self-hosting/advanced/server-database).
+
+
diff --git a/docs/usage/features/auth.zh-CN.mdx b/docs/usage/features/auth.zh-CN.mdx
new file mode 100644
index 0000000000000..f1a9823fb18cd
--- /dev/null
+++ b/docs/usage/features/auth.zh-CN.mdx
@@ -0,0 +1,59 @@
+---
+title: 多用户管理支持
+description: LobeChat 提供了多种用户认证和管理方案,以满足不同用户的需求。
+tags:
+ - LobeChat
+ - 用户管理
+ - next-auth
+ - Clerk
+ - 身份验证
+ - 多因素认证
+---
+
+# 身份验证系统 / 多用户管理支持
+
+
+
+在现代应用中,用户管理和身份验证是至关重要的功能。为满足不同用户的多样化需求,LobeChat 提供了两种主要的用户认证和管理方案:`next-auth` 和 `Clerk`。无论您是追求简便的用户注册登录,还是需要更高级的多因素认证和用户管理,LobeChat 都可以灵活实现。
+
+## next-auth:灵活且强大的身份验证库
+
+LobeChat 集成了 `next-auth`,一个灵活且强大的身份验证库,支持多种身份验证方式,包括 OAuth、邮件登录、凭证登录等。通过 `next-auth`,您可以轻松实现以下功能:
+
+- **用户注册和登录**:支持多种认证方式,满足不同用户的需求。
+- **会话管理**:高效管理用户会话,确保安全性。
+- **社交登录**:支持多种社交平台的快捷登录。
+- **数据安全**:保障用户数据的安全性和隐私性。
+
+
+ 由于工作量原因,目前还没有实现 next-auth 与服务端数据库的集成,如果需要使用服务端数据库,请使用
+ Clerk 。
+
+
+
+ 关于 Next-Auth 的使用,可以查阅 [身份验证服务 - Next
+ Auth](/zh/docs/self-hosting/advanced/authentication#next-auth)。
+
+
+## Clerk:现代化用户管理平台
+
+对于需要更高级用户管理功能的用户,LobeChat 还支持 [Clerk](https://clerk.com) ,一个现代化的用户管理平台。Clerk 提供了更丰富的功能,帮助您实现更高的安全性和灵活性:
+
+- **多因素认证 (MFA)**:提供更高的安全保障。
+- **用户配置文件管理**:便捷管理用户信息和配置。
+- **登录活动监控**:实时监控用户登录活动,确保账户安全。
+- **扩展性**:支持复杂的用户管理需求。
+
+
+
+ 关于 Clerk 的使用,可以查阅 [身份验证服务 - Clerk](/zh/docs/self-hosting/advanced/authentication#clerk)。
+
+
+
+ 如果需要在服务端数据库中搭配使用 Clerk 的使用,可以查阅 [使用服务端数据库部署](/zh/docs/self-hosting/advanced/server-database) 中的「配置身份验证服务」部分。
+
+
diff --git a/docs/usage/features/database.mdx b/docs/usage/features/database.mdx
new file mode 100644
index 0000000000000..fbba3bf0c3cf4
--- /dev/null
+++ b/docs/usage/features/database.mdx
@@ -0,0 +1,56 @@
+---
+title: LobeChat 支持本地 / 云端数据库存储
+description: LobeChat 支持本地 / 云端数据存储,既能实现 Local First,同时支持数据云同步。
+tags:
+ - LobeChat
+ - IndexedDB
+ - Postgres
+ - Local First
+ - 数据云同步
+ - 数据库
+---
+# Local / Cloud Data Storage
+
+
+
+
+In modern application development, the choice of data storage solution is crucial. To meet the needs of different users, LobeChat offers flexible configurations that support both local and server-side databases. Whether you prioritize data privacy and control or seek a convenient user experience, LobeChat can provide excellent solutions for you.
+
+## Local Database: Data Control and Privacy Protection
+
+For users who prefer more control over their data and value privacy protection, LobeChat offers support for local databases. By using IndexedDB as the storage solution and combining it with dexie as an Object-Relational Mapping (ORM) tool, LobeChat achieves efficient data management.
+
+Additionally, we have introduced Conflict-Free Replicated Data Type (CRDT) technology to ensure a seamless multi-device synchronization experience. This experimental feature aims to provide users with greater autonomy and data security.
+
+
+LobeChat defaults to the local database solution to reduce the onboarding cost for new users.
+
+Furthermore, we have attempted to introduce CRDT technology to achieve cross-device synchronization based on the local database. This experimental feature aims to provide users with greater autonomy and data security.
+
+## Server-Side Database: Convenient and Efficient User Experience
+
+For users who seek a convenient user experience, LobeChat supports PostgreSQL as the server-side database. By managing data with Dirzzle ORM and combining it with Clerk for authentication, LobeChat can offer users an efficient and reliable server-side data management solution.
+
+### Server-Side Database Technology Stack
+
+- **DB**: PostgreSQL (Neon is the default)
+- **ORM**: Dirzzle ORM
+- **Auth**: Clerk
+- **Server Router**: tRPC
+
+## Deployment Solution Selection Guide
+
+### 1. Local Database
+
+The local database solution is suitable for users who wish to have strict control over their data. With LobeChat's support for local databases, you can securely store and manage data without relying on external servers. This solution is particularly suitable for users with high requirements for data privacy.
+
+### 2. Server-Side Database
+
+The server-side database solution is ideal for users who want to simplify data management processes and enjoy a convenient user experience. Through server-side databases and user authentication, LobeChat can ensure the security and efficiency of data. If you want to learn how to configure a server-side database, please refer to our [detailed documentation](/docs/self-hosting/advanced/server-database).
+
+Whether you choose a local database or a server-side database, LobeChat can provide you with an excellent user experience.
+
diff --git a/docs/usage/features/database.zh-CN.mdx b/docs/usage/features/database.zh-CN.mdx
new file mode 100644
index 0000000000000..59f4f96a5def9
--- /dev/null
+++ b/docs/usage/features/database.zh-CN.mdx
@@ -0,0 +1,54 @@
+---
+title: LobeChat 支持本地 / 云端数据库存储
+description: LobeChat 支持本地 / 云端数据存储,既能实现 Local First,同时支持数据云同步。
+tags:
+ - LobeChat
+ - IndexedDB
+ - Postgres
+ - Local First
+ - 数据云同步
+ - 数据库
+---
+
+# 本地 / 云端数据存储
+
+
+
+在现代应用开发中,数据存储方案的选择至关重要。为了满足不同用户的需求,LobeChat 提供了同时支持本地数据库和服务端数据库的灵活配置。无论您是注重数据隐私与掌控,还是追求便捷的使用体验,LobeChat 都能为您提供卓越的解决方案。
+
+## 本地数据库:数据掌控与隐私保护
+
+对于希望对数据有更多掌控感和隐私保护的用户,LobeChat 提供了本地数据库支持。采用 IndexedDB 作为存储解决方案,并结合 dexie 作为 ORM(对象关系映射),LobeChat 实现了高效的数据管理。
+
+同时,我们引入了 CRDT(Conflict-Free Replicated Data Type)技术,确保多端同步功能的无缝体验。这一实验性功能旨在为用户提供更高的自主性和数据安全性。
+
+LobeChat 默认采取本地数据库方案,以降低新用户的上手成本。
+
+此外,我们尝试引入了 CRDT(Conflict-Free Replicated Data Type)技术,在本地数据库基础上实现了跨端同步。这一实验性功能旨在为用户提供更高的自主性和数据安全性。
+
+## 服务端数据库:便捷与高效的使用体验
+
+对于追求便捷使用体验的用户,LobeChat 支持 PostgreSQL 作为服务端数据库。通过 Dirzzle ORM 管理数据,结合 Clerk 进行身份验证,LobeChat 能够为用户提供高效、可靠的服务端数据管理方案。
+
+### 服务端数据库技术栈
+
+- **DB**: PostgreSQL(默认使用 Neon)
+- **ORM**: Dirzzle ORM
+- **Auth**: Clerk
+- **Server Router**: tRPC
+
+## 部署方案选择指南
+
+### 1. 本地数据库
+
+本地数据库方案适用于那些希望对数据进行严格控制的用户。通过 LobeChat 的本地数据库支持,您可以在不依赖外部服务器的情况下,安全地存储和管理数据。这一方案特别适合对数据隐私有高要求的用户。
+
+### 2. 服务端数据库
+
+服务端数据库方案则适合那些希望简化数据管理流程,享受便捷使用体验的用户。通过服务端数据库与用户身份验证,LobeChat 能够确保数据的安全性与高效性。如果您希望了解如何配置服务端数据库,请参考我们的[详细文档](/zh/docs/self-hosting/advanced/server-database)。
+
+无论选择本地数据库还是服务端数据库,LobeChat 都能为你提供卓越的用户体验。