mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-31 16:11:18 +08:00
- Revised the README files for shared data and main data layers to improve clarity and structure. - Consolidated documentation on shared data types and API types, removing the now-deleted `api-design-guidelines.md`. - Streamlined directory structure descriptions and updated links to relevant documentation. - Enhanced quick reference sections for better usability and understanding of the data architecture.
1.6 KiB
1.6 KiB
Main Data Layer
This directory contains the main process data management implementation.
Documentation
- Overview: docs/en/references/data/README.md
- DataApi in Main: data-api-in-main.md
- Database Patterns: database-patterns.md
Directory Structure
src/main/data/
├── api/ # Data API framework
│ ├── core/ # ApiServer, MiddlewareEngine, adapters
│ └── handlers/ # API endpoint implementations
├── services/ # Business logic layer
├── repositories/ # Data access layer (selective usage)
├── db/ # Database layer
│ ├── schemas/ # Drizzle table definitions
│ ├── seeding/ # Database initialization
│ └── DbService.ts # Database connection management
├── migration/ # Data migration system
├── CacheService.ts # Cache management
├── DataApiService.ts # API coordination
└── PreferenceService.ts # User preferences
Quick Reference
Adding New API Endpoints
- Define schema in
@shared/data/api/schemas/ - Implement handler in
api/handlers/ - Create business service in
services/ - Create repository in
repositories/(if complex domain)
Database Commands
# Generate migrations
yarn db:migrations:generate