How thanhdatttt/cryptox works
Purpose and maturity
Cryptox is an educational crypto-strategy laboratory focused on extensible strategy authoring, market/news inputs, bounded backtesting, evaluation, and ranking. It is a TypeScript monorepo targeting a synchronous modular monolith. Current source is largely a scaffold: module APIs and composition points exist, but most business behavior is unimplemented and no end-to-end product flow is verified.
Runtime entry points and composition
The backend is the primary server composition boundary: apps/backend/src/main.ts starts it, while apps/backend/src/app.module.ts and apps/backend/src/compose.ts assemble application dependencies. The frontend is a separate Vite client entry at apps/frontend/src/main.tsx, with HTML bootstrap in apps/frontend/index.html; it remains a placeholder. Module-local api/bootstrap.ts files are intended to construct public in-process module APIs.
Module-first boundaries
Business capabilities are isolated under modules/, conventionally split into domain, application, infrastructure, and public api layers. Consumers should use public APIs rather than internal layers, exemplified by modules/strategy/api/index.ts, modules/market-data/api/index.ts, and modules/backtesting/api/index.ts. Shared transport contracts are outside business modules in packages/contracts/rest/index.ts and packages/contracts/websocket/index.ts, preventing transport types from becoming module internals.
Strategy and input pipeline
The intended workflow begins with market data, news, and sentiment inputs. Market-data exposes snapshot-oriented access through modules/market-data/api/snapshot-reader.ts and its API bootstrap. News and sentiment are separate modules with application ports (modules/news/application/ports.ts, modules/sentiment/application/ports.ts), supporting provider isolation and failure containment. Strategy definitions and extension points belong to modules/strategy/domain/contracts.ts and modules/strategy/application/ports.ts, which should consume these capabilities through their published APIs.
Backtest execution boundary
Backtesting is explicitly bounded and local for MVP. Its application defines replaceable dependencies in modules/backtesting/application/ports.ts; the approved concrete executor is modules/backtesting/infrastructure/local/bounded-local-backtest-executor.ts. The public adapter resides in modules/backtesting/api/index.ts. This boundary permits a future worker/queue implementation without changing strategy-facing or API-facing contracts; distributed queues are not part of the approved runtime.
Results, evaluation, and leaderboard
Backtest outputs flow into evaluation and then ranking. Evaluation owns its domain contract and public boundary in modules/evaluation/domain/contracts.ts and modules/evaluation/api/index.ts. Leaderboard owns ranking-facing contracts and ports in modules/leaderboard/domain/contracts.ts and modules/leaderboard/application/ports.ts. Search is a separate query capability rather than a cross-module persistence concern, exposed through modules/search/api/index.ts.
Transport, infrastructure, and constraints
REST is the command/query transport; WebSocket is reserved for realtime market-data delivery, with message shapes in packages/contracts/websocket/market-data.ts. Local infrastructure includes PostgreSQL-oriented migrations at infra/db/migrations/001_enable_pgcrypto.js and Docker composition in infra/docker-compose.yml. No authentication, multitenancy, LLM integration, Redis/BullMQ, microservices, Kafka, CQRS, or event sourcing is approved for MVP. Architecture intent and dependency direction are governed by docs/architecture.md and validated in part by scripts/check-architecture-rules.mjs.
Main entry points: api/index.ts Strategy API · compose.ts Backend composition · api/index.ts Backtesting API · main.ts Backend server
Components 17
Runtime
- Vite frontend · Separate placeholder client.
apps/frontend/src/main.tsx - Backend server · Primary synchronous application host.
apps/backend/src/main.ts - Backend composition
apps/backend/src/compose.ts
Input modules
- Market data API · Publishes snapshot-oriented market access.
modules/market-data/api/snapshot-reader.ts - News module
modules/news/application/ports.ts - Sentiment module
modules/sentiment/application/ports.ts
Strategy pipeline
- Strategy API · Strategy definitions and extensions consume published inputs.
modules/strategy/api/index.ts - Strategy contracts
modules/strategy/domain/contracts.ts - Backtesting API · Stable boundary for backtest requests and results.
modules/backtesting/api/index.ts - Bounded local executor · Approved MVP execution implementation.
modules/backtesting/infrastructure/local/bounded-local-backtest-executor.ts
Results and discovery
- Evaluation API
modules/evaluation/api/index.ts - Leaderboard ports
modules/leaderboard/application/ports.ts - Search API · Separate discovery capability.
modules/search/api/index.ts
Transport and local platform
- REST contracts
packages/contracts/rest/index.ts - Market-data WS contracts
packages/contracts/websocket/market-data.ts - PostgreSQL migrations
infra/db/migrations/001_enable_pgcrypto.js - Architecture rules · Enforces intended dependency direction.
scripts/check-architecture-rules.mjs
Connections 21
- Vite frontend → Backend server: REST commands and queries
- Backend server → Backend composition: starts
- Backend composition → Strategy API: wires
- Backend composition → Backtesting API: wires
- Backend composition → Evaluation API: wires
- Backend composition → Leaderboard ports: wires
- Backend composition → Search API: wires
- Backend server → REST contracts: uses
- Market data API → Market-data WS contracts: realtime delivery shapes
- Strategy API → Strategy contracts: publishes
- Strategy API → Market data API: reads snapshots
- Strategy API → News module: consumes published API
- Strategy API → Sentiment module: consumes published API
- Strategy API → Backtesting API: submits strategy
- Backtesting API → Bounded local executor: delegates execution
- Bounded local executor → PostgreSQL migrations: uses local persistence
- Backtesting API → Evaluation API: emits results
- Evaluation API → Leaderboard ports: provides evaluated results
- Leaderboard ports → Search API: exposes ranked results
- Architecture rules → Strategy API: validates boundaries
- Architecture rules → Backtesting API: validates boundaries