# DigiDala Chat Mandala core

This directory contains the open implementation core for the Living Chat Mandala MVP.

## Privacy contract

The parser accepts Telegram message text only as an in-memory input and returns aggregate statistics. It does not return or persist the original text. The internal processing API rejects payloads containing raw message text. Application logs must never include message contents. Participant counts use a per-game salted hash of the Telegram user ID; the raw user ID is not stored in the Chat Mandala participant table.

The implementation is intentionally local to DigiDala: no LLM, external semantic analysis or third-party message-processing service is used.

## Main modules

- `parser.mjs` — Unicode text/punctuation/emoji extraction and aggregation.
- `profile.mjs` — profiling and profile locking.
- `progression.mjs` — deterministic channel assignment, area-weighted structure progress, chat-derived palette weighting, region color assignment and energy calculation.
- `templates.mjs` — controlled template/metadata loading.
- `renderer.mjs` — SVG state rendering using precomputed enclosed colorable regions; the original line art stays as a permanent outline.

The six Chat Mandala templates contain static region geometry and per-unit region metadata prepared from their enclosed line-art areas. Region segmentation is not performed at runtime. The canonical SVG remains transparent; Telegram PNG delivery adds a white background.

The repository is public and this module is intentionally reviewable as part of DigiDala's privacy explanation.

## Color mapping

After profiling locks, the selected text classes contribute to a weighted palette according to their frequencies. Atomic regions receive deterministic colors sampled from that palette using the game and region identifiers as the seed. For oversized regions, the renderer can additionally apply a deterministic concentric multi-color band treatment whose bands are derived from the same palette and the region geometry. This preserves the static source geometry while preventing a single large region from becoming a visually dominant monochrome mass at an early reveal stage.

## Sequence profile

The parser also counts adjacent 2-gram and 3-gram character sequences inside letter runs. To keep the privacy surface aggregate-only, n-grams are converted to fixed-width hash buckets before they leave memory; literal n-gram strings are never persisted. The selected character classes remain locked at profiling, while the cumulative sequence profile can evolve as the group keeps talking. Its current contribution is blended into the deterministic palette weighting and unit color arrangement, so recurring character combinations can gradually change the visual character without storing the source text.
