How mad1izjod/business-simulator works
Business Simulator is a browser-based, single-player company simulation: the player creates a company, issues validated decisions, advances time, and explores the resulting business and financial outcomes. The React UI is backed by a pure TypeScript engine; a controller owns the live state, clock, and saves. Daily and month-end simulation stages update interconnected domains, with financial statements derived from ledger postings. README documentation establishes several domain capabilities whose detailed source wiring was not sampled, so those branches are shown without speculative internal call chains.
Main entry points: step.ts Daily and monthly loop · controller.ts Game controller · ledger.ts Accounting ledger · create.ts Company initialization
Components 23
Player interface
- Company setup
src/ui/onboarding/CreateCompany.tsx - App shell
src/ui/App.tsx - Simulation pages
src/ui/pages
Simulation runtime
- Game controller
src/ui/game/controller.ts - Daily and monthly loop
src/engine/step.ts - Validated commands
src/engine/commands.ts - Company initialization
src/engine/create.ts
Business operations
- Demand and sales
src/engine/systems/market.ts - Products and R&D
src/engine/systems/products.ts - Supply and production
src/engine/systems - Employees and hiring
src/engine/systems - Growth and corporate actions
src/engine/systems - Industry and market data
src/engine/data/industries.ts
Finance and world
- Accounting ledger
src/engine/systems/ledger.ts - Debt and capital
src/engine/systems - Markets and events
src/engine/systems
Analysis and persistence
- Reports and insights
src/engine/systems/insights.ts - Metric explanations
src/engine/explain.ts - Forecasts and scenarios
src/engine/projection.ts - Forecast worker
src/ui/game/projection.worker.ts - Browser saves
src/persistence/storage.ts - Save serialization
src/persistence/serialize.ts
Other components
- Player
Connections 35
- Player → Company setup: sets up
README.md - Company setup → Company initialization: creates company
src/ui/onboarding/CreateCompany.tsx - App shell → Company setup: shows before game
src/ui/App.tsx - App shell → Game controller: subscribes to
src/ui/App.tsx - App shell → Simulation pages: selects page
src/ui/App.tsx - Player → Simulation pages: reviews and decides
README.md - Simulation pages → Game controller: dispatches actions
src/ui/pages/Research.tsx - Game controller → Validated commands: dispatches
src/ui/game/controller.ts - Game controller → Daily and monthly loop: advances time
src/ui/game/controller.ts - Game controller → Company initialization: starts game
src/ui/game/controller.ts - Company initialization → Industry and market data: uses configuration
src/engine/create.ts - Company initialization → Accounting ledger: initializes accounts
src/engine/create.ts - Daily and monthly loop → Demand and sales: runs simulation
- Daily and monthly loop → Products and R&D: runs simulation
- Daily and monthly loop → Supply and production: runs simulation
- Daily and monthly loop → Employees and hiring: runs simulation
- Daily and monthly loop → Debt and capital: runs simulation
- Daily and monthly loop → Markets and events: runs simulation
- Demand and sales → Products and R&D: reads product data
src/engine/systems/market.ts - Demand and sales → Accounting ledger: posts activity
src/engine/systems/market.ts - Products and R&D → Accounting ledger: posts expenses
src/engine/systems/products.ts - Products and R&D → Industry and market data: reads industry data
src/engine/systems/products.ts - Supply and production → Accounting ledger: records transactions
src/engine/systems/market.ts - Employees and hiring → Accounting ledger: records transactions
src/engine/systems/market.ts - Debt and capital → Accounting ledger: records transactions
src/engine/systems/market.ts - Growth and corporate actions → Accounting ledger: records transactions
src/engine/systems/market.ts - Daily and monthly loop → Reports and insights: closes reporting
- Game controller → Forecasts and scenarios: requests forecasts
src/ui/game/controller.ts - Forecasts and scenarios → Daily and monthly loop: simulates copy
src/engine/projection.ts - Game controller → Forecast worker: creates worker
src/ui/game/controller.ts - Forecast worker → Forecasts and scenarios: runs forecast
src/ui/game/projection.worker.ts - App shell → Metric explanations: opens explanations
src/ui/App.tsx - Game controller → Browser saves: saves game
src/ui/game/controller.ts - Browser saves → Save serialization: serializes saves
src/persistence/storage.ts - Save serialization → Company initialization: recreates save
src/persistence/serialize.ts