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>
This commit is contained in:
egg
2025-12-07 14:15:11 +08:00
parent 1d5d4d447d
commit 92834dbe0e
39 changed files with 1558 additions and 136 deletions

View File

@@ -1,11 +1,56 @@
# Frontend Environment Variables
# =============================================================================
# Task Reporter - Frontend Environment Configuration
# =============================================================================
# Copy this file to .env and customize as needed.
# All variables are optional and have sensible defaults for development.
# =============================================================================
# -----------------------------------------------------------------------------
# API Configuration
# -----------------------------------------------------------------------------
# API Base URL (optional)
# - For local development: leave empty or don't set (will use /api)
# - For local development: leave empty or don't set (will use /api with proxy)
# - For production with separate backend: set to full URL
# Example: https://api.yourdomain.com/api
VITE_API_BASE_URL=
# Note: When set, this URL is also used for WebSocket connections
# http:// will be converted to ws://
# https:// will be converted to wss://
# API request timeout in milliseconds (default: 30000 = 30 seconds)
VITE_API_TIMEOUT_MS=30000
# -----------------------------------------------------------------------------
# Development Server Configuration
# -----------------------------------------------------------------------------
# Frontend development server port (default: 3000)
VITE_PORT=3000
# Backend API URL for development proxy (default: http://localhost:8000)
# This is used by Vite's proxy configuration during development
VITE_BACKEND_URL=http://localhost:8000
# -----------------------------------------------------------------------------
# WebSocket Configuration
# -----------------------------------------------------------------------------
# Maximum WebSocket reconnection delay in milliseconds (default: 30000 = 30 seconds)
# The reconnection uses exponential backoff, capped at this value
VITE_MAX_RECONNECT_DELAY_MS=30000
# -----------------------------------------------------------------------------
# Query/Cache Configuration
# -----------------------------------------------------------------------------
# Messages refetch interval in milliseconds (default: 30000 = 30 seconds)
# Used for polling online users status
VITE_MESSAGES_REFETCH_INTERVAL_MS=30000
# Reports stale time in milliseconds (default: 30000 = 30 seconds)
# Time before cached report data is considered stale
VITE_REPORTS_STALE_TIME_MS=30000
# =============================================================================
# Notes
# =============================================================================
# - All VITE_ prefixed variables are exposed to the browser
# - Never put sensitive data (API keys, secrets) in frontend environment variables
# - When VITE_API_BASE_URL is set:
# - http:// URLs will be converted to ws:// for WebSocket connections
# - https:// URLs will be converted to wss:// for WebSocket connections
# =============================================================================