mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-04-17 15:20:58 +00:00
docs: update all docs to reflect current trading module state
Trading module now VN stocks only with dynamic symbol resolution. Update test counts (105), remove crypto/gold/forex references from project-level docs, update architecture file tree descriptions.
This commit is contained in:
@@ -10,7 +10,7 @@ Modules are added or removed via a single `MODULES` env var. Each module registe
|
|||||||
- **Three visibility levels out of the box.** Public commands show in Telegram's `/` menu and `/help`; protected show only in `/help`; private are hidden slash-command easter eggs. One namespace, loud conflict detection.
|
- **Three visibility levels out of the box.** Public commands show in Telegram's `/` menu and `/help`; protected show only in `/help`; private are hidden slash-command easter eggs. One namespace, loud conflict detection.
|
||||||
- **Storage is swappable.** Modules talk to a small `KVStore` interface — Cloudflare KV today, a different backend tomorrow, with a one-file change.
|
- **Storage is swappable.** Modules talk to a small `KVStore` interface — Cloudflare KV today, a different backend tomorrow, with a one-file change.
|
||||||
- **Zero admin surface.** No in-Worker `/admin/*` routes, no admin secret. `setWebhook` + `setMyCommands` run at deploy time from a local node script.
|
- **Zero admin surface.** No in-Worker `/admin/*` routes, no admin secret. `setWebhook` + `setMyCommands` run at deploy time from a local node script.
|
||||||
- **Tested.** 110 vitest unit tests cover registry, storage, dispatcher, help renderer, validators, HTML escaping, and the trading module.
|
- **Tested.** 105 vitest unit tests cover registry, storage, dispatcher, help renderer, validators, HTML escaping, and the trading module.
|
||||||
|
|
||||||
## How a request flows
|
## How a request flows
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ src/
|
|||||||
│ ├── dispatcher.js # wires every command via bot.command()
|
│ ├── dispatcher.js # wires every command via bot.command()
|
||||||
│ ├── validate-command.js
|
│ ├── validate-command.js
|
||||||
│ ├── util/ # /info, /help (fully implemented)
|
│ ├── util/ # /info, /help (fully implemented)
|
||||||
│ ├── trading/ # fake paper trading — crypto, stocks, forex, gold
|
│ ├── trading/ # paper trading — VN stocks (dynamic symbol resolution)
|
||||||
│ ├── wordle/ # stub — proves plugin system
|
│ ├── wordle/ # stub — proves plugin system
|
||||||
│ ├── loldle/ # stub
|
│ ├── loldle/ # stub
|
||||||
│ └── misc/ # stub
|
│ └── misc/ # stub
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ src/
|
|||||||
│ ├── dispatcher.js ── bot.command() for every visibility
|
│ ├── dispatcher.js ── bot.command() for every visibility
|
||||||
│ ├── validate-command.js ── shared validators
|
│ ├── validate-command.js ── shared validators
|
||||||
│ ├── util/ ── fully implemented: /info + /help
|
│ ├── util/ ── fully implemented: /info + /help
|
||||||
│ ├── trading/ ── paper trading: crypto, VN stocks, forex, gold
|
│ ├── trading/ ── paper trading: VN stocks (dynamic symbol resolution)
|
||||||
│ ├── wordle/ loldle/ ── stub modules proving the plugin system
|
│ ├── wordle/ loldle/ ── stub modules proving the plugin system
|
||||||
│ └── misc/ ── stub that exercises the DB (ping/mstats)
|
│ └── misc/ ── stub that exercises the DB (ping/mstats)
|
||||||
└── util/
|
└── util/
|
||||||
@@ -278,7 +278,7 @@ A previous design sketched a `POST /admin/setup` route inside the Worker, gated
|
|||||||
|
|
||||||
## 12. Testing philosophy
|
## 12. Testing philosophy
|
||||||
|
|
||||||
Pure-logic unit tests only. No `workerd` pool, no Telegram fixtures, no integration-level tooling. 110 tests run in ~500ms.
|
Pure-logic unit tests only. No `workerd` pool, no Telegram fixtures, no integration-level tooling. 105 tests run in ~500ms.
|
||||||
|
|
||||||
Test seams:
|
Test seams:
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ Run `npm run format` before committing.
|
|||||||
- **Files:** lowercase, hyphens for multi-word (`stats-handler.js`, `fake-kv-namespace.js`)
|
- **Files:** lowercase, hyphens for multi-word (`stats-handler.js`, `fake-kv-namespace.js`)
|
||||||
- **Directories:** lowercase, single word preferred (`trading/`, `util/`)
|
- **Directories:** lowercase, single word preferred (`trading/`, `util/`)
|
||||||
- **Functions/variables:** camelCase
|
- **Functions/variables:** camelCase
|
||||||
- **Constants:** UPPER_SNAKE_CASE for frozen config objects (`SYMBOLS`, `CURRENCIES`)
|
- **Constants:** UPPER_SNAKE_CASE for frozen config objects (e.g. `CURRENCIES`)
|
||||||
- **Command names:** lowercase + digits + underscore, 1-32 chars, no leading slash
|
- **Command names:** lowercase + digits + underscore, 1-32 chars, no leading slash
|
||||||
|
|
||||||
## Module Conventions
|
## Module Conventions
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ Telegram bot on Cloudflare Workers with a plug-n-play module system. grammY hand
|
|||||||
| Module | Status | Commands | Description |
|
| Module | Status | Commands | Description |
|
||||||
|--------|--------|----------|-------------|
|
|--------|--------|----------|-------------|
|
||||||
| `util` | Complete | `/info`, `/help` | Bot info and command help renderer |
|
| `util` | Complete | `/info`, `/help` | Bot info and command help renderer |
|
||||||
| `trading` | Complete | `/trade_topup`, `/trade_buy`, `/trade_sell`, `/trade_convert`, `/trade_stats` | Paper trading with crypto, VN stocks, forex, gold |
|
| `trading` | Complete | `/trade_topup`, `/trade_buy`, `/trade_sell`, `/trade_convert`, `/trade_stats` | Paper trading — VN stocks with dynamic symbol resolution. Crypto/gold/forex coming soon. |
|
||||||
| `misc` | Stub | `/ping`, `/mstats`, `/fortytwo` | Health check + DB demo |
|
| `misc` | Stub | `/ping`, `/mstats`, `/fortytwo` | Health check + DB demo |
|
||||||
| `wordle` | Stub | `/wordle`, `/wstats`, `/konami` | Placeholder for word game |
|
| `wordle` | Stub | `/wordle`, `/wstats`, `/konami` | Placeholder for word game |
|
||||||
| `loldle` | Stub | `/loldle`, `/ggwp` | Placeholder for LoL game |
|
| `loldle` | Stub | `/loldle`, `/ggwp` | Placeholder for LoL game |
|
||||||
@@ -57,11 +57,11 @@ Each module maintains its own `README.md` with commands, data model, and impleme
|
|||||||
|
|
||||||
## Test Coverage
|
## Test Coverage
|
||||||
|
|
||||||
110 tests across 11 test files:
|
105 tests across 11 test files:
|
||||||
|
|
||||||
| Area | Tests | What's Covered |
|
| Area | Tests | What's Covered |
|
||||||
|------|-------|---------------|
|
|------|-------|---------------|
|
||||||
| DB layer | 19 | KV store, prefixing, JSON helpers, pagination |
|
| DB layer | 19 | KV store, prefixing, JSON helpers, pagination |
|
||||||
| Module framework | 33 | Registry, dispatcher, validators, help renderer |
|
| Module framework | 33 | Registry, dispatcher, validators, help renderer |
|
||||||
| Utilities | 4 | HTML escaping |
|
| Utilities | 4 | HTML escaping |
|
||||||
| Trading module | 54 | Symbols, formatters, portfolio CRUD, all 5 command handlers |
|
| Trading module | 49 | Dynamic symbol resolution, formatters, flat portfolio CRUD, command handlers |
|
||||||
|
|||||||
Reference in New Issue
Block a user