# Drama Ling - 專案架構 這是Drama Ling語言學習應用的主要專案資料夾,包含前端和後端代碼。 ## 專案結構 ``` src/ ├── backend/ # .NET Core Web API 後端 │ ├── DramaLing.API/ # Web API 專案 │ ├── DramaLing.Application/ # 應用服務層 │ ├── DramaLing.Core/ # 領域模型層 │ ├── DramaLing.Infrastructure/ # 基礎設施層 │ ├── DramaLing.Tests/ # 測試專案 │ └── DramaLing.sln # 解決方案檔 ├── mobile/ # Flutter 移動應用 │ ├── lib/ │ │ ├── core/ # 核心功能 (常數、工具、服務) │ │ ├── features/ # 功能模組 (認證、學習、對話等) │ │ └── shared/ # 共用組件 (Widget、模型、Provider) │ └── pubspec.yaml # Flutter 專案配置 └── docker-compose.yml # Docker 開發環境配置 ``` ## 技術棧 ### 後端 (.NET Core) - **.NET 8**: 最新的跨平台框架 - **ASP.NET Core Web API**: RESTful API 服務 - **Entity Framework Core**: ORM 資料庫存取 - **PostgreSQL**: 主要資料庫 - **Redis**: 快取和會話管理 - **JWT**: 身份驗證 - **Swagger/OpenAPI**: API 文檔 - **Serilog**: 結構化日誌 ### 前端 (Flutter) - **Flutter 3.16+**: 跨平台移動應用框架 - **Dart 3.0+**: 程式語言 - **Riverpod**: 狀態管理 - **Go Router**: 導航路由 - **Dio + Retrofit**: HTTP 客戶端 - **Hive**: 本地資料存儲 - **Material 3**: UI 設計系統 ## 開發環境設置 ### 必要工具 - [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0) - [Flutter 3.16+](https://flutter.dev/docs/get-started/install) - [Docker Desktop](https://www.docker.com/products/docker-desktop) - [PostgreSQL](https://www.postgresql.org/download/) (或使用Docker) ### 快速開始 #### 1. 啟動開發環境 ```bash # 啟動資料庫和Redis cd src docker-compose up -d postgres redis # 或者啟動完整環境包含API docker-compose up -d ``` #### 2. 後端開發 ```bash cd src/backend # 還原套件 dotnet restore # 建立資料庫 dotnet ef database update --project DramaLing.Infrastructure --startup-project DramaLing.API # 啟動API服務 dotnet run --project DramaLing.API # API將在 http://localhost:5000 啟動 # Swagger UI: http://localhost:5000 ``` #### 3. 前端開發 ```bash cd src/mobile # 安裝套件 flutter pub get # 程式碼生成 (Riverpod, Retrofit 等) dart run build_runner build # 啟動Flutter應用 (需要模擬器或實體裝置) flutter run ``` ## API 文檔 - **開發環境**: http://localhost:5000 - **Swagger UI**: http://localhost:5000 (開發模式下) - **API 規格文檔**: `../../docs/04_technical/api/` ## 資料庫 ### 連線資訊 (開發環境) - **主機**: localhost - **埠號**: 5432 - **資料庫**: dramaling_dev - **使用者**: postgres - **密碼**: password ### 遷移指令 ```bash # 建立遷移 dotnet ef migrations add --project DramaLing.Infrastructure --startup-project DramaLing.API # 更新資料庫 dotnet ef database update --project DramaLing.Infrastructure --startup-project DramaLing.API # 移除最後一個遷移 dotnet ef migrations remove --project DramaLing.Infrastructure --startup-project DramaLing.API ``` ## 測試 ### 後端測試 ```bash cd src/backend dotnet test ``` ### 前端測試 ```bash cd src/mobile flutter test ``` ## 部署 ### 生產環境建構 ```bash # 後端 cd src/backend dotnet publish DramaLing.API -c Release -o publish # 前端 cd src/mobile flutter build apk --release # Android flutter build ios --release # iOS ``` ## 開發指南 ### 架構原則 - **Clean Architecture**: 分層架構,依賴倒置 - **CQRS**: 命令查詢職責分離 (使用 MediatR) - **Feature-based**: 按功能模組組織程式碼 - **API-first**: API 優先設計 ### 編碼規範 - **後端**: 遵循 C# 編碼慣例 - **前端**: 遵循 Dart/Flutter 編碼慣例 - **命名**: 英文命名,中文註釋 - **測試**: 單元測試覆蓋率 > 80% ## 相關文檔 - [API 規格文檔](../../docs/04_technical/api/) - [資料庫設計](../../docs/04_technical/database-schema.md) - [技術選型決策](../../docs/04_technical/tech-stack-decision.md) - [開發工作流程](../../docs/03_development/development-workflow.md) ## 問題回報 如有問題請參考: - [ISSUES.md](../../ISSUES.md) - [問題管理系統](../../README-問題管理.md) ## 授權 版權所有 © 2025 Drama Ling Team