chore: Remove obsolete microservices directories and update all references

- Delete data-entry-app/ (1.6GB), reports-app/ (447MB), .auto-build-data/
- Saved ~1.4GB disk space (64% reduction: 2.2GB → 845MB)

Updated references across 38 files:
- .claude/rules/ paths: backend/modules/, src/modules/
- .claude/commands/validate.md: all validation paths
- docs/ (13 files): data-entry, telegram, README, CLAUDE.md
- scripts/ (3 files): backup-secrets, restore-secrets, test-docker
- security/ (2 files): git_cleanup, SECURITY_PROCEDURES
- deployment/ & shared/: updated all stale comments

All paths now reflect ultrathin monolith architecture:
- Backend: backend/modules/{reports,data_entry,telegram}/
- Frontend: src/modules/{reports,data-entry}/
- Shared: shared/{auth,database,routes}/

🤖 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-30 12:08:20 +02:00
parent c5e051ad80
commit 9008876b16
33 changed files with 1300 additions and 125 deletions

View File

@@ -173,7 +173,7 @@ shared/
└── cache/
└── redis_client.py ⚠️ MODIFY - Use real tenant_id (not "default")
reports-app/backend/
backend/
├── app/
│ ├── main.py ⚠️ MODIFY - Initialize MultiTenantPoolManager
│ └── routers/
@@ -753,7 +753,7 @@ CREATE INDEX IF NOT EXISTS idx_audit_tenant ON audit_logs(tenant_id);
```
7. **Add background task pentru health monitoring**
- **Fișier:** `reports-app/backend/app/main.py`
- **Fișier:** `backend/app/main.py`
- **Task:** Run every 60 seconds
```python
async def monitor_ssh_tunnels():
@@ -824,7 +824,7 @@ CREATE INDEX IF NOT EXISTS idx_audit_tenant ON audit_logs(tenant_id);
```
2. **Update login endpoint să determine tenant_id**
- **Fișier:** `reports-app/backend/app/main.py` (auth router)
- **Fișier:** `backend/app/main.py` (auth router)
- **Logica:**
- Check `tenant_users` table pentru user_id
- Dacă user are access la multiple tenants, return primul (default)
@@ -921,7 +921,7 @@ CREATE INDEX IF NOT EXISTS idx_audit_tenant ON audit_logs(tenant_id);
- **Flow:** AuthMiddleware decode JWT → TenantMiddleware validate tenant access
5. **Update toate router-urile să folosească tenant_id din request.state**
- **Fișiere:** `reports-app/backend/app/routers/*.py`
- **Fișiere:** `backend/app/routers/*.py`
- **Pattern:**
```python
# Înainte (single-tenant)
@@ -945,7 +945,7 @@ CREATE INDEX IF NOT EXISTS idx_audit_tenant ON audit_logs(tenant_id);
```
6. **Update Telegram bot pentru tenant support**
- **Fișier:** `reports-app/telegram-bot/app/auth/linking.py`
- **Fișier:** `backend/modules/telegram/app/auth/linking.py`
- **Modificări:**
- La linking, salvează și `tenant_id` în SQLite
- JWT token include `tenant_id`
@@ -1590,13 +1590,13 @@ locust -f shared/tests/load/test_multi_tenant_load.py --host=http://localhost:80
expdp username/password@ROA directory=BACKUP dumpfile=pre_migration.dmp
# Backup existing .env files
cp reports-app/backend/.env reports-app/backend/.env.backup
cp backend/.env backend/.env.backup
```
- [ ] **Document current single-tenant config**
```bash
# Save current credentials
cat reports-app/backend/.env > docs/pre_migration_env.txt
cat backend/.env > docs/pre_migration_env.txt
# Save current SSH tunnel config
./ssh-tunnel-prod.sh status > docs/pre_migration_ssh.txt
@@ -1795,7 +1795,7 @@ python3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().
DB_ENCRYPTION_KEY=$(cat .encryption_key)
# 3. Update .env
cat >> reports-app/backend/.env << EOF
cat >> backend/.env << EOF
# Tenant Configuration
TENANT_DB_URL=sqlite:///data/tenant_config.db
DB_ENCRYPTION_KEY=$DB_ENCRYPTION_KEY
@@ -1892,7 +1892,7 @@ services:
roa-backend:
build:
context: .
dockerfile: ./reports-app/backend/Dockerfile
dockerfile: ./backend/Dockerfile
image: roa2web/backend:multi-tenant
container_name: roa-backend
restart: unless-stopped
@@ -1942,7 +1942,7 @@ services:
# Frontend (unchanged)
roa-frontend:
build:
context: ./reports-app/frontend
context: ./src
dockerfile: Dockerfile
image: roa2web/frontend:latest
container_name: roa-frontend
@@ -2443,7 +2443,7 @@ Multi-Tenant (10 tenants):
- **OraclePool:** `shared/database/oracle_pool.py` - Singleton pattern for single-tenant
- **JWT Handler:** `shared/auth/jwt_handler.py` - Token creation/validation (needs tenant_id)
- **Auth Middleware:** `shared/auth/middleware.py` - JWT verification (needs tenant validation)
- **Backend Main:** `reports-app/backend/app/main.py` - Startup logic (needs MultiTenantPoolManager)
- **Backend Main:** `backend/app/main.py` - Startup logic (needs MultiTenantPoolManager)
- **SSH Tunnel Script:** `ssh-tunnel-prod.sh` - Single tunnel script (needs per-tenant manager)
### Inspiration & Patterns

View File

@@ -35,13 +35,13 @@
### Fișiere Modificate (7 fișiere)
- [ ] `reports-app/backend/requirements.txt` - Adaugă redis>=5.0.0
- [ ] `reports-app/backend/.env.example` - Adaugă REDIS_* env vars
- [ ] `reports-app/backend/app/main.py` - Initialize Redis at startup
- [ ] `reports-app/backend/app/services/dashboard_service.py` - Apply caching
- [ ] `reports-app/backend/app/services/invoice_service.py` - Apply caching
- [ ] `reports-app/backend/app/routers/dashboard.py` - Cache invalidation on mutations
- [ ] `reports-app/backend/app/routers/invoices.py` - Cache invalidation on mutations
- [ ] `backend/requirements.txt` - Adaugă redis>=5.0.0
- [ ] `backend/.env.example` - Adaugă REDIS_* env vars
- [ ] `backend/app/main.py` - Initialize Redis at startup
- [ ] `backend/app/services/dashboard_service.py` - Apply caching
- [ ] `backend/app/services/invoice_service.py` - Apply caching
- [ ] `backend/app/routers/dashboard.py` - Cache invalidation on mutations
- [ ] `backend/app/routers/invoices.py` - Cache invalidation on mutations
---
@@ -54,7 +54,7 @@
**Tasks:**
1. [ ] **Adaugă dependency în requirements.txt**
- Fișier: `reports-app/backend/requirements.txt`
- Fișier: `backend/requirements.txt`
- Acțiune: Adaugă linia `redis>=5.0.0` după `httpx>=0.27.0`
- Motivație: redis 5.0+ are async support nativ
@@ -79,7 +79,7 @@
- Template (vezi secțiunea Code Templates mai jos)
4. [ ] **Adaugă env variables în .env.example**
- Fișier: `reports-app/backend/.env.example`
- Fișier: `backend/.env.example`
- Acțiune: Adaugă la sfârșitul fișierului:
```bash
# Redis Configuration
@@ -90,7 +90,7 @@
```
5. [ ] **Initialize Redis la startup în main.py**
- Fișier: `reports-app/backend/app/main.py`
- Fișier: `backend/app/main.py`
- Acțiune: În funcția `startup_event()`:
```python
from shared.cache import redis_cache
@@ -254,7 +254,7 @@
**Tasks:**
1. [ ] **Apply @cached în DashboardService.get_complete_summary()**
- Fișier: `reports-app/backend/app/services/dashboard_service.py`
- Fișier: `backend/app/services/dashboard_service.py`
- Acțiune: Adaugă decorator la metoda `get_complete_summary`:
```python
from shared.cache import cached
@@ -268,26 +268,26 @@
- Motivație: Dashboard e accesat des, datele se schimbă rar
2. [ ] **Apply @cached în DashboardService.get_trends()**
- Fișier: `reports-app/backend/app/services/dashboard_service.py`
- Fișier: `backend/app/services/dashboard_service.py`
- Acțiune: Similar, TTL=180 (3 min pentru trends)
- Cache key va include period: `cache:default:dashboard_trends:company-X:period-30d:abc123`
3. [ ] **Apply @cached în DashboardService.get_detailed_data()**
- Fișier: `reports-app/backend/app/services/dashboard_service.py`
- Fișier: `backend/app/services/dashboard_service.py`
- Acțiune: TTL=60 (1 min pentru tabel detalii - se refreshează des)
- Cache key include page, page_size, search
4. [ ] **Apply @cached în InvoiceService.get_invoices()**
- Fișier: `reports-app/backend/app/services/invoice_service.py`
- Fișier: `backend/app/services/invoice_service.py`
- Acțiune: TTL=60 (1 min)
- Cache key include filter params (partner_type, date_from, date_to, etc.)
5. [ ] **Apply @cached în InvoiceService.get_invoice_summary()**
- Fișier: `reports-app/backend/app/services/invoice_service.py`
- Fișier: `backend/app/services/invoice_service.py`
- Acțiune: TTL=180 (3 min pentru summary)
6. [ ] **Cache invalidation în dashboard mutations (viitor)**
- Fișier: `reports-app/backend/app/routers/dashboard.py`
- Fișier: `backend/app/routers/dashboard.py`
- Acțiune: Pregătește cod pentru invalidation (de activat când există POST/PUT/DELETE):
```python
# TODO: Activate când implementăm mutations
@@ -301,7 +301,7 @@
```
7. [ ] **Cache invalidation în invoice mutations**
- Fișier: `reports-app/backend/app/routers/invoices.py`
- Fișier: `backend/app/routers/invoices.py`
- Acțiune: Când se implementează POST/PUT/DELETE pentru invoices, invalidează:
- `invoices_list`
- `invoices_summary`
@@ -601,7 +601,7 @@ ab -n 100 -c 10 http://localhost:8001/api/dashboard/summary?company=123
## 🔧 Configurare Env Variables
**File:** `reports-app/backend/.env`
**File:** `backend/.env`
```bash
# ============================================================================
@@ -657,7 +657,7 @@ docker-compose exec roa-backend env | grep REDIS
- [ ] Dependency added: `redis>=5.0.0` în requirements.txt
- [ ] Package created: `shared/cache/__init__.py`
- [ ] Redis client: `shared/cache/redis_client.py`
- [ ] Env vars added: `reports-app/backend/.env.example`
- [ ] Env vars added: `backend/.env.example`
- [ ] Main.py updated: Redis initialize at startup
- [ ] Test: `python -c "import asyncio; from shared.cache import redis_cache; asyncio.run(redis_cache.initialize())"`
@@ -703,8 +703,8 @@ docker-compose exec roa-backend env | grep REDIS
- **Docker Compose Redis Config:** `docker-compose.yml:147-163`
- **Oracle Pool Pattern:** `shared/database/oracle_pool.py` (reference for singleton pattern)
- **Backend Services:** `reports-app/backend/app/services/` (where to apply caching)
- **Backend Routers:** `reports-app/backend/app/routers/` (where to invalidate cache)
- **Backend Services:** `backend/app/services/` (where to apply caching)
- **Backend Routers:** `backend/app/routers/` (where to invalidate cache)
### Documentație Externă

View File

@@ -2,7 +2,7 @@
Shared Routes for ROA2WEB Applications
This module provides factory functions for creating common API routers
that can be mounted in both reports-app and data-entry-app.
that can be mounted in both the unified monolith backend.
Usage:
from shared.routes import create_companies_router, create_calendar_router

View File

@@ -2,7 +2,7 @@
Shared Calendar Router Factory for ROA2WEB Applications
Creates a FastAPI router for /api/calendar endpoints that can be used
by both reports-app and data-entry-app.
by both the unified monolith backend.
Usage:
from shared.routes.calendar import create_calendar_router

View File

@@ -2,7 +2,7 @@
Shared Companies Router Factory for ROA2WEB Applications
Creates a FastAPI router for /api/companies endpoints that can be used
by both reports-app and data-entry-app.
by both the unified monolith backend.
Usage:
from shared.routes.companies import create_companies_router