# suspect147/five-years-later architecture

> Architecture diagram of the GitHub repository suspect147/five-years-later, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/suspect147/five-years-later
- Repository: https://github.com/suspect147/five-years-later

## Overview

«Пять лет спустя» — мини-приложение с финансовой симуляцией на пять лет. Игрок проходит сценарий, выбирает действия и получает разбор результата; в MAX игра также синхронизирует результаты и прогресс, а бот присылает приглашение открыть приложение. Основные продуктовые области — сценарии и события, детерминированный финансовый движок, интерфейс, серверные профили и таблица лидеров. Связи движка с контентом и UI с движком показаны пунктиром: доступные выдержки не показывают их вызовы напрямую. README отсутствует.

Main entry points: [`engine.js`](https://github.com/suspect147/five-years-later/blob/main/engine.js) (Симуляция и расчёты), [`ui.js`](https://github.com/suspect147/five-years-later/blob/main/ui.js) (Игровой интерфейс), [`max.js`](https://github.com/suspect147/five-years-later/blob/main/max.js) (Связь с сервером), [`supabase/functions/fyl-api/index.ts`](https://github.com/suspect147/five-years-later/blob/main/supabase/functions/fyl-api/index.ts) (Игровой API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Игра"]
  node_ui["Игровой интерфейс<br/>[ui.js]"]
  node_engine["Симуляция и расчёты<br/>[engine.js]"]
  node_scenarios["Сценарии и знания<br/>[content.js]"]
  node_events["События и выборы<br/>[events.js]"]
end

subgraph group_integration["MAX-интеграция"]
  node_maxbridge["Связь с сервером<br/>[max.js]"]
  node_localcache[("Локальный кэш<br/>[max.js]")]
end

subgraph group_backend["Сервер"]
  node_api["Игровой API<br/>[index.ts]"]
  node_database[("Данные игроков<br/>[index.ts]")]
  node_bot["Бот-приглашение<br/>[index.ts]"]
end

node_player(("Игрок"))
node_maxplatform["Платформа MAX"]

node_player -->|"играет"| node_ui
node_ui -.->|"запускает симуляцию"| node_engine
node_engine -.->|"использует сценарии"| node_scenarios
node_engine -->|"собирает события"| node_events
node_ui -->|"читает профиль"| node_maxbridge
node_maxbridge -->|"отправляет запросы"| node_api
node_maxbridge -->|"читает и сохраняет"| node_localcache
node_api -->|"пересчитывает партию"| node_engine
node_api -->|"читает и записывает"| node_database
node_maxplatform -->|"отправляет вебхук"| node_bot
node_bot -->|"отправляет приглашение"| node_maxplatform

click node_ui "https://github.com/suspect147/five-years-later/blob/main/ui.js"
click node_engine "https://github.com/suspect147/five-years-later/blob/main/engine.js"
click node_scenarios "https://github.com/suspect147/five-years-later/blob/main/content.js"
click node_events "https://github.com/suspect147/five-years-later/blob/main/events.js"
click node_maxbridge "https://github.com/suspect147/five-years-later/blob/main/max.js"
click node_localcache "https://github.com/suspect147/five-years-later/blob/main/max.js"
click node_api "https://github.com/suspect147/five-years-later/blob/main/supabase/functions/fyl-api/index.ts"
click node_database "https://github.com/suspect147/five-years-later/blob/main/supabase/functions/fyl-api/index.ts"
click node_bot "https://github.com/suspect147/five-years-later/blob/main/supabase/functions/fyl-bot/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ui,node_engine,node_scenarios,node_events toneBlue
class node_maxbridge,node_localcache toneAmber
class node_api,node_database,node_bot toneMint
class node_player,node_maxplatform toneIndigo
```

## Components

### Игра

- [Игровой интерфейс](https://github.com/suspect147/five-years-later/blob/main/ui.js): `ui.js`
- [Симуляция и расчёты](https://github.com/suspect147/five-years-later/blob/main/engine.js): `engine.js`
- [Сценарии и знания](https://github.com/suspect147/five-years-later/blob/main/content.js): `content.js`
- [События и выборы](https://github.com/suspect147/five-years-later/blob/main/events.js): `events.js`

### MAX-интеграция

- [Связь с сервером](https://github.com/suspect147/five-years-later/blob/main/max.js): `max.js`
- [Локальный кэш](https://github.com/suspect147/five-years-later/blob/main/max.js): `max.js`

### Сервер

- [Игровой API](https://github.com/suspect147/five-years-later/blob/main/supabase/functions/fyl-api/index.ts): `supabase/functions/fyl-api/index.ts`
- [Данные игроков](https://github.com/suspect147/five-years-later/blob/main/supabase/functions/fyl-api/index.ts): `supabase/functions/fyl-api/index.ts`
- [Бот-приглашение](https://github.com/suspect147/five-years-later/blob/main/supabase/functions/fyl-bot/index.ts): `supabase/functions/fyl-bot/index.ts`

### Other components

- **Игрок**
- **Платформа MAX**

## Connections

- Игрок → Игровой интерфейс: играет (evidence: `ui.js`)
- Игровой интерфейс → Симуляция и расчёты: запускает симуляцию
- Симуляция и расчёты → Сценарии и знания: использует сценарии
- Симуляция и расчёты → События и выборы: собирает события
- Игровой интерфейс → Связь с сервером: читает профиль (evidence: `ui.js`)
- Связь с сервером → Игровой API: отправляет запросы (evidence: `max.js`)
- Связь с сервером → Локальный кэш: читает и сохраняет (evidence: `max.js`)
- Игровой API → Симуляция и расчёты: пересчитывает партию (evidence: `supabase/functions/fyl-api/index.ts`)
- Игровой API → Данные игроков: читает и записывает (evidence: `supabase/functions/fyl-api/index.ts`)
- Платформа MAX → Бот-приглашение: отправляет вебхук (evidence: `supabase/functions/fyl-bot/index.ts`)
- Бот-приглашение → Платформа MAX: отправляет приглашение (evidence: `supabase/functions/fyl-bot/index.ts`)
