# xf5201/pc28 architecture

> Architecture diagram of the GitHub repository xf5201/pc28, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xf5201/pc28
- Repository: https://github.com/xf5201/pc28

## Overview

This is a Telegram-operated, multi-user PC28 automated betting system. Users configure accounts, target chats and strategies through bot panels; the runtime collects draw results, triggers bets for running strategies, and settles records into profit and operational reporting. The principal flow is split between the crawler, strategy executor, Telegram account/session services and persistence. The tree indicates additional configuration, dashboard, log and notification capabilities; sampled excerpts do not establish all of their internal wiring, so those links are kept conservative.

Main entry points: [`src/services/strategy-executor.service.js`](https://github.com/xf5201/pc28/blob/main/src/services/strategy-executor.service.js) (Strategy executor), [`src/services/crawler.service.js`](https://github.com/xf5201/pc28/blob/main/src/services/crawler.service.js) (Result crawler), [`src/bot/handlers`](https://github.com/xf5201/pc28/tree/main/src/bot/handlers) (Bot handlers), [`src/index.js`](https://github.com/xf5201/pc28/blob/main/src/index.js) (Runtime startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bot["Telegram Bot"]
  node_entry["Runtime startup<br/>[index.js]"]
  node_handlers["Bot handlers"]
  node_panels["Panels and scenes"]
  node_logintext["Login text flow"]
  node_notify["Notifications"]
end

subgraph group_account["Accounts"]
  node_accountsvc["Account service<br/>[account.service.js]"]
  node_sessions["Session manager<br/>[session.manager.js]"]
end

subgraph group_betting["Betting Runtime"]
  node_crawler["Result crawler<br/>[crawler.service.js]"]
  node_period["Period service<br/>[period.service.js]"]
  node_executor["Strategy executor"]
  node_sender["Bet sender"]
  node_settlement["Settlement service"]
  node_accounting["Accounting service"]
end

subgraph group_data["Persistence"]
  node_sqlite[("SQLite database<br/>[connection.js]")]
  node_accountdao["Account and config DAOs<br/>[account.dao.js]"]
  node_betdao["Bet and result DAOs<br/>[bet-record.dao.js]"]
  node_profitdao["Profit log DAO<br/>[profit-log.dao.js]"]
  node_contextdao["Panel context DAO"]
end

subgraph group_engines["Betting Logic"]
  node_strategy["Strategy engine<br/>[strategy.engine.js]"]
  node_odds["Odds engine<br/>[odds.engine.js]"]
end

node_user(("Bot user"))
node_telegram{{"Telegram API"}}
node_drawapi{{"PC20 results API"}}

node_user -->|"sends commands"| node_handlers
node_entry -->|"registers routes"| node_handlers
node_entry -->|"starts crawler"| node_crawler
node_entry -->|"restores sessions"| node_sessions
node_entry -->|"launches bot"| node_telegram
node_handlers -->|"renders panels"| node_panels
node_handlers -->|"manages accounts"| node_accountsvc
node_handlers -->|"controls strategies"| node_executor
node_handlers -->|"requests reports"| node_accounting
node_logintext -->|"submits credentials"| node_accountsvc
node_logintext -->|"reads wizard state"| node_contextdao
node_accountsvc -->|"authenticates"| node_telegram
node_accountsvc -->|"initializes session"| node_sessions
node_sessions -->|"recovers accounts"| node_accountdao
node_crawler -->|"fetches results"| node_drawapi
node_crawler -->|"checks pending bets"| node_betdao
node_crawler -->|"settles periods"| node_settlement
node_crawler -->|"triggers next bets"| node_executor
node_crawler -->|"uses period service"| node_period
node_executor -->|"calculates direction"| node_strategy
node_executor -->|"calculates odds"| node_odds
node_executor -->|"schedules bet send"| node_sender
node_executor -->|"reads strategy config"| node_accountdao
node_executor -->|"records bets"| node_betdao
node_settlement -->|"records profit"| node_profitdao
node_accounting -->|"queries profit"| node_profitdao
node_notify -->|"updates panels"| node_panels
node_accountdao -->|"reads and writes"| node_sqlite
node_betdao -->|"reads and writes"| node_sqlite
node_profitdao -->|"reads and writes"| node_sqlite
node_contextdao -->|"reads and writes"| node_sqlite

click node_entry "https://github.com/xf5201/pc28/blob/main/src/index.js"
click node_handlers "https://github.com/xf5201/pc28/tree/main/src/bot/handlers"
click node_panels "https://github.com/xf5201/pc28/tree/main/src/bot/panels"
click node_logintext "https://github.com/xf5201/pc28/blob/main/src/bot/handlers/login-text.handler.js"
click node_accountsvc "https://github.com/xf5201/pc28/blob/main/src/services/account.service.js"
click node_sessions "https://github.com/xf5201/pc28/blob/main/src/services/session.manager.js"
click node_crawler "https://github.com/xf5201/pc28/blob/main/src/services/crawler.service.js"
click node_period "https://github.com/xf5201/pc28/blob/main/src/services/period.service.js"
click node_executor "https://github.com/xf5201/pc28/blob/main/src/services/strategy-executor.service.js"
click node_sender "https://github.com/xf5201/pc28/blob/main/src/services/bet-sender.service.js"
click node_settlement "https://github.com/xf5201/pc28/blob/main/src/services/settlement.service.js"
click node_accounting "https://github.com/xf5201/pc28/blob/main/src/services/accounting.service.js"
click node_notify "https://github.com/xf5201/pc28/blob/main/src/services/notification.service.js"
click node_strategy "https://github.com/xf5201/pc28/blob/main/src/core/strategy.engine.js"
click node_odds "https://github.com/xf5201/pc28/blob/main/src/core/odds.engine.js"
click node_sqlite "https://github.com/xf5201/pc28/blob/main/src/db/connection.js"
click node_accountdao "https://github.com/xf5201/pc28/blob/main/src/db/account.dao.js"
click node_betdao "https://github.com/xf5201/pc28/blob/main/src/db/bet-record.dao.js"
click node_profitdao "https://github.com/xf5201/pc28/blob/main/src/db/profit-log.dao.js"
click node_contextdao "https://github.com/xf5201/pc28/blob/main/src/db/panel-context.dao.js"

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_entry,node_handlers,node_panels,node_logintext,node_notify,node_user toneBlue
class node_accountsvc,node_sessions toneAmber
class node_crawler,node_period,node_executor,node_sender,node_settlement,node_accounting,node_telegram,node_drawapi toneMint
class node_sqlite,node_accountdao,node_betdao,node_profitdao,node_contextdao toneRose
class node_strategy,node_odds toneIndigo
```

## Components

### Telegram Bot

- [Runtime startup](https://github.com/xf5201/pc28/blob/main/src/index.js): `src/index.js`
- [Bot handlers](https://github.com/xf5201/pc28/tree/main/src/bot/handlers): `src/bot/handlers`
- [Panels and scenes](https://github.com/xf5201/pc28/tree/main/src/bot/panels): `src/bot/panels`
- [Login text flow](https://github.com/xf5201/pc28/blob/main/src/bot/handlers/login-text.handler.js): `src/bot/handlers/login-text.handler.js`
- [Notifications](https://github.com/xf5201/pc28/blob/main/src/services/notification.service.js): `src/services/notification.service.js`

### Accounts

- [Account service](https://github.com/xf5201/pc28/blob/main/src/services/account.service.js): `src/services/account.service.js`
- [Session manager](https://github.com/xf5201/pc28/blob/main/src/services/session.manager.js): `src/services/session.manager.js`

### Betting Runtime

- [Result crawler](https://github.com/xf5201/pc28/blob/main/src/services/crawler.service.js): `src/services/crawler.service.js`
- [Period service](https://github.com/xf5201/pc28/blob/main/src/services/period.service.js): `src/services/period.service.js`
- [Strategy executor](https://github.com/xf5201/pc28/blob/main/src/services/strategy-executor.service.js): `src/services/strategy-executor.service.js`
- [Bet sender](https://github.com/xf5201/pc28/blob/main/src/services/bet-sender.service.js): `src/services/bet-sender.service.js`
- [Settlement service](https://github.com/xf5201/pc28/blob/main/src/services/settlement.service.js): `src/services/settlement.service.js`
- [Accounting service](https://github.com/xf5201/pc28/blob/main/src/services/accounting.service.js): `src/services/accounting.service.js`

### Persistence

- [SQLite database](https://github.com/xf5201/pc28/blob/main/src/db/connection.js): `src/db/connection.js`
- [Account and config DAOs](https://github.com/xf5201/pc28/blob/main/src/db/account.dao.js): `src/db/account.dao.js`
- [Bet and result DAOs](https://github.com/xf5201/pc28/blob/main/src/db/bet-record.dao.js): `src/db/bet-record.dao.js`
- [Profit log DAO](https://github.com/xf5201/pc28/blob/main/src/db/profit-log.dao.js): `src/db/profit-log.dao.js`
- [Panel context DAO](https://github.com/xf5201/pc28/blob/main/src/db/panel-context.dao.js): `src/db/panel-context.dao.js`

### Betting Logic

- [Strategy engine](https://github.com/xf5201/pc28/blob/main/src/core/strategy.engine.js): `src/core/strategy.engine.js`
- [Odds engine](https://github.com/xf5201/pc28/blob/main/src/core/odds.engine.js): `src/core/odds.engine.js`

### Other components

- **Bot user**
- **Telegram API**
- **PC20 results API**

## Connections

- Bot user → Bot handlers: sends commands
- Runtime startup → Bot handlers: registers routes
- Runtime startup → Result crawler: starts crawler
- Runtime startup → Session manager: restores sessions
- Runtime startup → Telegram API: launches bot
- Bot handlers → Panels and scenes: renders panels
- Bot handlers → Account service: manages accounts
- Bot handlers → Strategy executor: controls strategies
- Bot handlers → Accounting service: requests reports
- Login text flow → Account service: submits credentials
- Login text flow → Panel context DAO: reads wizard state
- Account service → Telegram API: authenticates
- Account service → Session manager: initializes session
- Session manager → Account and config DAOs: recovers accounts
- Result crawler → PC20 results API: fetches results
- Result crawler → Bet and result DAOs: checks pending bets
- Result crawler → Settlement service: settles periods
- Result crawler → Strategy executor: triggers next bets
- Result crawler → Period service: uses period service
- Strategy executor → Strategy engine: calculates direction
- Strategy executor → Odds engine: calculates odds
- Strategy executor → Bet sender: schedules bet send
- Strategy executor → Account and config DAOs: reads strategy config
- Strategy executor → Bet and result DAOs: records bets
- Settlement service → Profit log DAO: records profit
- Accounting service → Profit log DAO: queries profit
- Notifications → Panels and scenes: updates panels
- Account and config DAOs → SQLite database: reads and writes
- Bet and result DAOs → SQLite database: reads and writes
- Profit log DAO → SQLite database: reads and writes
- Panel context DAO → SQLite database: reads and writes
