Files
cwshed-clone/project_mind_map.md
T

7.6 KiB

Карта проекта «Беличья нора»

Основная карта — состояние на 2026-11-14; 2026-11-17 добавлена отдельная проектируемая ветка тренажёра ЛУ. Карта описывает добавленный функционал Белок; legacy userscript-файлы остаются отдельными статическими материалами и не входят в расчётный контур.

mindmap
  root((cwshed-clone))
    Project context
      project-info.txt
      LongMemory catwar
    Planned LU trainer — not implemented
      LU_TRAINER_PROJECT.md
      Game-like scene and character
      Minefield companion map
      Shared attempt state and action history
      Client-side rules independent of Belki
      Proposed route and asset serving via Python and gateway
    Belki
      Domain
        domain.py
          ЛУ и ЗУ
          Тренировки
          Осмотры
          Калькулятор цели
        reports.py
      Web
        app/main.py
          Public API
            calculate
            inspect bulk
            resolve identity
            rename existing identity
            applications
            character report lookup
          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
          Native section links and mode radios
          Prepared-result version and invalidation
          Reports
          Goal calculator
          Applications
          Cat-name update tab
          Report lookup by cat ID
        web/admin.html
          Review and accept
          Report entered checkbox
          Current calendar month by default
        web/applications.html
        tests/browser/calculator.cjs
          Isolated loopback API and fixtures
          Desktop and mobile Chromium
      VK bot
        vk_bot.py
          Callback API listener :8081
            secret and group validation
            confirmation response
            message_new and message_event
          callback event deduplication
            vk_callback_events, seven-day retention
          Step dialogs
            durable vk_dialog_states checkpoint
          Natural one-line parser
          Existing cat-name rename flow
          My reports by VK sender ID
          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
        Pulkovo ULLI raw METAR
          weather.py bounded process cache
          /api/weather/ulli decoration settings
          shared weather-effect.js and CSS
          wind leaves rain snow mixed
        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
        Manual rollout 2026-10-10
          amd64 images on reg.nyan404.ru
          callback Secret from ignored local files
          confirmation verified through gateway proxy
    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

Потоки данных

flowchart LR
  Browser[Публичный браузер] --> Web[BelkiHTTPServer]
  Browser -->|inspection screenshot only| Web
  VK[VK Callback API] -->|/api/vk/callback| Gateway[cwshed gateway]
  Gateway -->|exact route| BotHTTP[belki-bot :8081]
  BotHTTP --> Bot[BelkiDialog]
  Web --> Domain[Расчётное ядро]
  Web -->|fixed URL, 5-minute cache| Weather[weather.nyan404.ru ULLI METAR]
  Browser -->|/api/weather/ulli| Web
  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.
  • Поиск публичной истории по ID участника, фильтр VK-истории и HTTP response shape проверяются в tests/test_report_lookup.py и tests/test_vk_bot.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/*.