feat: Migrate to ultrathin monolith architecture

Consolidate 3 separate applications (reports-app, data-entry-app, telegram-bot) into a unified
architecture with single backend and frontend:

Backend Changes:
- Unified FastAPI backend at backend/ with modular structure
- Modules: reports, data_entry, telegram in backend/modules/
- Centralized config.py and main.py with all routers registered
- Single worker mode (--workers 1) for Telegram bot compatibility
- Shared Oracle connection pool and JWT authentication
- Unified requirements.txt and environment configuration

Frontend Changes:
- Single Vue.js SPA with module-based routing
- Unified frontend at src/ with modules in src/modules/{reports,data-entry}/
- Shared components and stores in src/shared/
- Error boundaries for module isolation
- Dual API proxy in Vite for module communication

Infrastructure:
- New unified startup scripts: start-prod.sh, start-test.sh, start-backend.sh
- Environment templates: .env.dev.example, .env.test.example, .env.prod.example
- Updated deployment scripts for Windows IIS
- Simplified SSH tunnel management

Documentation:
- Comprehensive CLAUDE.md with architecture overview
- Module-specific docs in docs/{data-entry,telegram}/
- Architecture decision records in docs/ARCHITECTURE-DECISIONS.md
- Deployment guides consolidated in deployment/windows/docs/

This migration reduces complexity, improves maintainability, and enables easier
deployment while maintaining all existing functionality.

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-29 23:48:14 +02:00
parent 2a101f1ef5
commit c5e051ad80
378 changed files with 7566 additions and 73730 deletions

View File

@@ -65,8 +65,8 @@ $ProgressPreference = "SilentlyContinue"
$script:Config = @{
AppName = "ROA2WEB"
ServiceName = "ROA2WEB-Backend"
ServiceDisplayName = "ROA2WEB Backend Service"
ServiceDescription = "FastAPI backend service for ROA2WEB ERP Reports Application"
ServiceDisplayName = "ROA2WEB Unified Backend Service"
ServiceDescription = "Unified FastAPI backend for ROA2WEB ERP - includes Reports, Data Entry, and Telegram modules (Ultrathin Monolith)"
InstallPath = $InstallPath
BackendPath = Join-Path $InstallPath "backend"
FrontendPath = Join-Path $InstallPath "frontend"
@@ -340,9 +340,19 @@ function New-WindowsService {
if ($serviceExists) {
Write-Warning "Service already exists, stopping and removing..."
# Try to stop service (may fail if service is broken)
& nssm stop $Config.ServiceName 2>&1 | Out-Null
Start-Sleep -Seconds 2
# Check service status
$status = & nssm status $Config.ServiceName 2>&1
# Only try to stop if service is running
if ($status -match "SERVICE_RUNNING") {
Write-Step "Stopping running service..."
& nssm stop $Config.ServiceName 2>&1 | Out-Null
Start-Sleep -Seconds 2
} else {
Write-Step "Service is not running (status: $status)"
}
# Force remove service
& nssm remove $Config.ServiceName confirm 2>&1 | Out-Null
Start-Sleep -Seconds 2
@@ -352,12 +362,13 @@ function New-WindowsService {
# Get Python path
$pythonPath = (Get-Command python).Source
$uvicornModule = "uvicorn"
$appModule = "app.main:app"
$appModule = "main:app"
# NSSM service creation
try {
# Install service
& nssm install $Config.ServiceName $pythonPath "-m" $uvicornModule $appModule "--host" "127.0.0.1" "--port" $Config.ServicePort.ToString() "--workers" "4"
# NOTE: Using --workers 1 because Telegram bot requires single instance (polling conflict)
& nssm install $Config.ServiceName $pythonPath "-m" $uvicornModule $appModule "--host" "127.0.0.1" "--port" $Config.ServicePort.ToString() "--workers" "1"
# Set service configuration
& nssm set $Config.ServiceName DisplayName $Config.ServiceDisplayName
@@ -366,9 +377,10 @@ function New-WindowsService {
& nssm set $Config.ServiceName AppDirectory $Config.BackendPath
# Set environment variables (PYTHONPATH for shared modules)
# Point to the installation root so shared/ modules can be imported
$pythonPath = $Config.InstallPath
& nssm set $Config.ServiceName AppEnvironmentExtra "PYTHONPATH=$pythonPath"
# Point to the installation root AND backend/ so both shared/ and app/ modules can be imported
$pythonPathRoot = $Config.InstallPath
$pythonPathBackend = $Config.BackendPath
& nssm set $Config.ServiceName AppEnvironmentExtra "PYTHONPATH=$pythonPathRoot;$pythonPathBackend"
# Set logging
$stdoutLog = Join-Path $Config.LogsPath "backend-stdout.log"
@@ -537,13 +549,25 @@ function Show-Summary {
Write-Host " 1. Copy backend files to: $($Config.BackendPath)"
Write-Host " 2. Copy frontend files to: $($Config.FrontendPath)"
Write-Host " 3. Configure .env file at: $($Config.BackendPath)\.env"
Write-Host " 4. Run: .\Deploy-ROA2WEB.ps1 to deploy updates"
Write-Host ""
Write-Host " IMPORTANT - Module Control Flags in .env:" -ForegroundColor Cyan
Write-Host " MODULE_REPORTS_ENABLED=true # Enable/disable Reports module"
Write-Host " MODULE_DATA_ENTRY_ENABLED=true # Enable/disable Data Entry module"
Write-Host " MODULE_TELEGRAM_ENABLED=true # Enable/disable Telegram bot module"
Write-Host ""
Write-Host " 4. Start service: Start-Service $($Config.ServiceName)"
Write-Host "`nManagement Commands:" -ForegroundColor Yellow
Write-Host " Start Service: .\Start-ROA2WEB.ps1"
Write-Host " Stop Service: .\Stop-ROA2WEB.ps1"
Write-Host " Restart Service: .\Restart-ROA2WEB.ps1"
Write-Host " Start Service: Start-Service $($Config.ServiceName)"
Write-Host " Stop Service: Stop-Service $($Config.ServiceName)"
Write-Host " Restart Service: Restart-Service $($Config.ServiceName)"
Write-Host " View Logs: Get-Content $($Config.LogsPath)\backend-stdout.log -Tail 50"
Write-Host " Check Status: Get-Service $($Config.ServiceName)"
Write-Host "`nArchitecture:" -ForegroundColor Yellow
Write-Host " ULTRATHIN MONOLITH - Single Windows service with multiple modules"
Write-Host " All modules share Oracle pool, auth, and cache"
Write-Host " Telegram bot runs as background task (not separate service)"
Write-Host "`n" + ("=" * 80) -ForegroundColor Cyan
}