Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion BACKLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ Roadmap и план работ для AI Secretary System. Этот файл и
**Завершено:** 2026-01-28

**Описание:**
Разбить orchestrator.py (~170 endpoints) на модульную структуру `app/routers/`.
Разбить orchestrator.py на модульную структуру `app/routers/`.
> **Примечание:** Полная декомпозиция завершена в Phase 4 (issue #494): orchestrator.py 4100 → 321 строк. Все endpoints в `modules/*/router*.py`, сервисы в `modules/*/startup.py`, задачи в `modules/*/tasks.py`.

**Задачи:**
- [x] Создать `app/` структуру с routers, services, models
Expand Down
7 changes: 4 additions & 3 deletions docs/IMPROVEMENT_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ jobs:
- [ ] Configure branch protection (require CI pass)
- [ ] Add Dependabot for Python and npm

### 0.2 Code Restructuring [P0]
**Why:** orchestrator.py is too large (~60 endpoints), hard to maintain
### 0.2 Code Restructuring [P0] ✅
**Why:** orchestrator.py was too large — hard to maintain.
**Status:** Complete. Phase 0.2 extracted 11 routers. Phase 4 (issue #494) completed full decomposition: orchestrator.py 4100 → 321 lines. All endpoints in `modules/*/router*.py`, all service init in `modules/*/startup.py`, all background tasks via `TaskRegistry`. See [Architecture wiki](https://github.com/ShaerWare/AI_Secretary_System/wiki/Architecture) for details.

```
AI_Secretary_System/
Expand Down Expand Up @@ -136,7 +137,7 @@ AI_Secretary_System/
│ ├── test_tts.py
│ └── test_api.py
├── orchestrator.py # DEPRECATED → app/main.py
├── orchestrator.py # FastAPI entry point (~320 lines, pure wiring)
└── ...
```

Expand Down
23 changes: 15 additions & 8 deletions docs/WORKFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,22 @@ AI Secretary System - виртуальный секретарь с клонир
### Service Container (Dependency Injection)

```
app/dependencies.py → ServiceContainer (Singleton)
app/dependencies.py → ServiceContainer (Singleton, single source of truth)
├─ .voice_service → VoiceCloneService (XTTS Marina)
├─ .anna_voice_service → VoiceCloneService (XTTS Anna)
├─ .piper_service → PiperTTSService (CPU)
├─ .llm_service → LLMService (vLLM или Cloud)
├─ .stt_service → UnifiedSTTService (Vosk + Whisper)
├─ .streaming_tts_manager → StreamingTTSManager
└─ .faq_manager → AsyncFAQManager
├─ .voice_service → VoiceCloneService (XTTS Marina)
├─ .anna_voice_service → VoiceCloneService (XTTS Anna)
├─ .piper_service → PiperTTSService (CPU)
├─ .openvoice_service → OpenVoiceService (GPU CC 6.1+)
├─ .llm_service → CloudLLMService or VLLMLLMService
├─ .stt_service → VoskSTTService
├─ .streaming_tts_manager → StreamingTTSManager
├─ .wiki_rag_service → WikiRAGService
├─ .gsm_service → GSMService
├─ .internet_monitor → InternetMonitor
└─ .current_voice_config → dict (engine + voice)

Populated by domain init functions in modules/*/startup.py
No global service variables — container is the only state holder
```

### Cloud LLM Factory
Expand Down
8 changes: 4 additions & 4 deletions wiki-pages/Architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@

## Текущее состояние

### Монолит (исторический)
### Текущее состояние после Phase 4

| Компонент | Размер | Что содержит |
|-----------|--------|-------------|
| `orchestrator.py` | ~4100 строк | FastAPI entry point, инициализация сервисов, legacy endpoints, background tasks, регистрация 28 роутеров |
| `orchestrator.py` | ~320 строк | Чистый wiring: imports, middleware, регистрация 28 роутеров, вызовы доменных init-функций, static files |
| `db/models.py` | ~200 строк (фасад) | Реэкспорт моделей из `modules/*/models.py` (54 модели) |
| `db/integration.py` | ~100 строк (фасад) | Импорт синглтонов и классов из `modules/*/service.py` под старыми именами |

Expand Down Expand Up @@ -476,7 +476,7 @@ from modules.kanban.service import kanban_service as async_kanban_manager

**Ключевые решения:**
- `numpy` — lazy import внутри `_cache_full_audio()` (избегает ошибок импорта в cloud mode без GPU)
- Глобальная переменная `streaming_tts_manager` и все 17 точек использования остаются в `orchestrator.py` (будут перенесены в Phase 4.5)
- Глобальная переменная `streaming_tts_manager` перенесена в `ServiceContainer` (Phase 4.7b)
- `synthesize_with_current_voice()` перенесена в `modules/compat/router.py` в Phase 4.3 (переписана на `get_container()`)
- 5 неиспользуемых импортов удалены из orchestrator (`hashlib`, `re`, `OrderedDict`, `ThreadPoolExecutor`, `numpy`)

Expand Down Expand Up @@ -589,7 +589,7 @@ from modules.kanban.service import kanban_service as async_kanban_manager
- `router_logs.py` регистрируется безусловно (доступен во всех режимах)
- 35 из 52 эндпоинтов были мёртвыми дубликатами (shadowed модульными роутерами, зарегистрированными ранее)

**Результат:** orchestrator.py: 2471 → 1121 строк (−1350). Содержит: импорты, middleware, регистрацию роутеров, глобальные сервисные переменные, startup/shutdown lifecycle, раздачу статических файлов.
**Результат:** orchestrator.py: 2471 → 1121 строк (−1350). Содержит: импорты, middleware, регистрацию роутеров, startup/shutdown lifecycle, раздачу статических файлов.

### Phase 4.6: Background tasks → TaskRegistry

Expand Down
2 changes: 1 addition & 1 deletion wiki-pages/Response-Pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Quiz: тип проекта → описание → бизнес-цель →

### Публичный виджет (без авторизации)

Эндпоинт: `POST /widget/chat/session/{id}/stream` (`orchestrator.py`)
Эндпоинт: `POST /widget/chat/session/{id}/stream` (`modules/channels/widget/router_public.py`)

```
Сообщение в виджете
Expand Down
Loading