Files
egg 92834dbe0e feat: Migrate to MySQL and add unified environment configuration
## Database Migration (SQLite → MySQL)
- Add Alembic migration framework
- Add 'tr_' prefix to all tables to avoid conflicts in shared database
- Remove SQLite support, use MySQL exclusively
- Add pymysql driver dependency
- Change ad_token column to Text type for long JWT tokens

## Unified Environment Configuration
- Centralize all hardcoded settings to environment variables
- Backend: Extend Settings class in app/core/config.py
- Frontend: Use Vite environment variables (import.meta.env)
- Docker: Move credentials to environment variables
- Update .env.example files with comprehensive documentation

## Test Organization
- Move root-level test files to tests/ directory:
  - test_chat_room.py → tests/test_chat_room.py
  - test_websocket.py → tests/test_websocket.py
  - test_realtime_implementation.py → tests/test_realtime_implementation.py
- Fix path references in test_realtime_implementation.py

Breaking Changes:
- CORS now requires explicit origins (no more wildcard)
- All database tables renamed with 'tr_' prefix
- SQLite no longer supported

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 14:15:11 +08:00

1.8 KiB

Tasks: Unified Environment Configuration

1. Backend Configuration Enhancement

  • 1.1 擴展 app/core/config.py Settings 類別,新增所有環境變數
  • 1.2 更新 app/main.py 使 CORS 來源從 CORS_ORIGINS 環境變數讀取
  • 1.3 更新 app/modules/realtime/router.py 將硬編碼的 SYSTEM_ADMIN_EMAIL 改為環境變數
  • 1.4 更新 app/modules/auth/services/ad_client.py 將 timeout 改為可配置
  • 1.5 更新 app/modules/realtime/services/message_service.py 將訊息編輯時間限制改為可配置
  • 1.6 更新 app/modules/realtime/websocket_manager.py 將打字超時改為可配置
  • 1.7 更新 app/modules/file_storage/validators.py 將檔案大小限制改為可配置

2. Frontend Configuration Enhancement

  • 2.1 更新 frontend/vite.config.ts 使用環境變數設定端口和後端 URL
  • 2.2 更新 frontend/src/services/api.ts 使用環境變數設定 API 超時
  • 2.3 更新 frontend/src/hooks/useMessages.ts 使用環境變數設定重新取得間隔
  • 2.4 更新 frontend/src/hooks/useWebSocket.ts 使用環境變數設定重連延遲
  • 2.5 更新 frontend/src/hooks/useReports.ts 使用環境變數設定快取過期時間

3. Docker Configuration

  • 3.1 更新 docker-compose.minio.yml 使用環境變數取代硬編碼認證
  • 3.2 創建 .env.docker.example 範例檔案

4. Documentation Updates

  • 4.1 更新根目錄 .env.example 包含所有後端環境變數及中英文說明
  • 4.2 更新 frontend/.env.example 包含所有前端環境變數及說明
  • 4.3 更新現有 .env 檔案包含所有新環境變數

5. Testing & Validation

  • 5.1 驗證所有環境變數有合理的預設值(開發環境可直接運行)
  • 5.2 確保前端編譯成功
  • 5.3 驗證後端配置正確載入