# Карта проекта «Беличья нора» Актуально на 2026-08-25. Карта описывает добавленный функционал Белок; legacy userscript-файлы остаются отдельными статическими материалами и не входят в расчётный контур. ```mermaid mindmap root((cwshed-clone)) Belki Domain domain.py ЛУ и ЗУ Тренировки Осмотры Калькулятор цели reports.py Web app/main.py Public API calculate inspect bulk resolve identity applications Upload boundary PNG JPEG WebP JSON 20 MiB image 15 MiB issued URL TTL 30 min / 1000 Application validation bounded text rows and amounts HTTPS media and review links VK profile link allowlist Admin API password session history applications refresh WebSocket pool 8 web/calculator.html Reports Goal calculator Applications web/admin.html Review and accept Report entered checkbox Current calendar month by default web/applications.html VK bot vk_bot.py Long Poll reconnect on SSL/socket/timeout Step dialogs durable vk_dialog_states checkpoint Natural one-line parser Mentor and student labels Per-ward self-sufficiency labels Flexible punctuation and ID normalization Written Russian dates Attachment mirroring bounded verified raster bytes Applications dialog Sudoku /sudoku adaptive game UI nickname-only resume key dokusan ranked generator server-side solution key Data PostgreSQL production calculations calculations.entered admin flag applications sudoku_games export outbox identities and profiles SQLite local fallback calculations.entered migration Private MinIO image storage belki-images bucket HAProxy front door 10.43.30.146:9000 bucket-scoped GetObject PutObject GetBucketLocation account public proxy /api/images/id Integrations VK API Optional Google Sheets export (HTTPS only) Deployment Docker Immutable Belki base image Python 3.12 GitLab CI test build deploy main Kubernetes namespace belki belki-web belki-bot belki-postgres cwshed gateway Security boundaries Public input bounded JSON bounded worker pool validated web attachments bounded application payload Admin HttpOnly SameSite session session TTL 12 h / 100 active password comparison Persistence parameterized SQL public identity input is ephemeral Follow-up deployment control TLS and edge rate limiting ``` ## Потоки данных ```mermaid flowchart LR Browser[Публичный браузер] --> Web[BelkiHTTPServer] Browser -->|inspection screenshot only| Web VK[VK Long Poll] --> Bot[BelkiDialog] Web --> Domain[Расчётное ядро] Bot --> Domain Web --> Store[(PostgreSQL or SQLite)] Bot --> Store Web --> ImageStore[Private MinIO] Web --> Sudoku[Sudoku game store] Bot --> ImageStore Browser -->|public image URL| Web Web -->|bounded proxy read| ImageStore Admin[Администратор] -->|session cookie| Web Admin -->|same filters| XLSX[Отчёты и заявки XLSX] Web -->|UTC instants to UTC+3 display| Admin Web --> XLSX Web --> Admin Bot -. when enabled .-> Sheets[Google Apps Script] ``` ## Проверочные точки - Изменение доменной формулы проверяется в `tests/test_belki.py` и `tests/test_api.py`. - Диалоги, команды и естественный ввод проверяются в `tests/test_vk_conversation.py`. - Границы image-host и HTTP-предохранители проверяются в `tests/test_image_host.py`. - Заявки, экспортная очередь и уведомления проверяются в `tests/test_applications.py`; совместимость сортировки истории — в `tests/test_history.py`. - Периоды админки, защищённые XLSX-маршруты и целостность XLSX ZIP проверяются в `tests/test_admin_export.py`. - Перед CI используйте Python 3.12 в Docker: `docker run --rm -v "$PWD:/work" -w /work python:3.12-slim sh -lc 'python -m compileall -q app tests && python -m unittest discover -s tests -q'`. ## Ограничения развёртывания Исходники ограничивают размер и параллелизм запросов, но TLS и сетевой rate limit должны обеспечиваться на внешнем прокси. Перед следующим production rollout необходимо убедиться, что админский путь недоступен по plaintext HTTP и что `belki-web` не публикуется в обход этого прокси. - VK scheduler: `BelkiBot.handle_event` -> `VkConversationStore` (реестр) -> `VkScheduler` (timezone, claim `schedule_id+planned_for`, VK `messages.send`); админка `/admin` -> `/api/admin/vk/*`.