How diegochavez/burger-builder-mobx-state-tree works
1. Project type and purpose
- This is a small React + TypeScript demo app for building a burger visually.
- The README makes the intent explicit: it is a presentation app showcasing MobX-State-Tree (MST) and its benefits, not a full backend-driven product.
2. Top-level structure
- The repository is split into three main areas:
- src/ for application logic and UI
- public/ for static assets and the HTML host page
- root config files for TypeScript, npm, and sandbox setup
3. Application bootstrap
- src/index.tsx is the entry point that mounts the React app.
- src/components/App.tsx is the top-level UI component.
- src/withRoot.tsx likely wraps the app with shared providers/theme setup, acting as a composition boundary between the entry point and the component tree.
4. State management boundary
- src/stores/RootStore.tsx is the central state container for the app.
- This is the main architectural boundary between UI and state: components consume store state and actions rather than managing the burger data locally.
- The use of MobX-State-Tree implies state is modeled as observable, structured application state with actions/mutations handled through the store layer.
5. Domain model layer
- src/stores/models/Burger.tsx and src/stores/models/Ingredient.tsx define the core domain objects.
- The burger builder is modeled around at least two concepts:
- a Burger aggregate/root
- individual Ingredient items
- This model layer is the source of truth for what can be added, removed, or displayed in the burger.
6. UI composition
- src/components/Burger.tsx and src/components/Ingredient.tsx are the primary visual components for the domain.
- Burger likely renders the assembled burger from store state.
- Ingredient likely renders one ingredient item, either as a selectable option or as a part of the assembled burger view.
- App.tsx probably composes these components and wires them to store data/actions.
7. Data flow
- The likely flow is:
- store initializes domain state in RootStore
- UI reads observable state from the store
- user interaction in components triggers store actions
- the store updates burger/ingredient state
- React re-renders the visual burger from the updated state
- This makes the app a classic unidirectional state-driven UI, with MST handling the state transition logic.
8. Static assets
- public/images/burger-assets contains image assets for burger ingredients and related visuals.
- These assets are part of the presentation layer and are likely referenced by the ingredient/burger components to render the assembled burger.
9. Runtime and tooling
- The stack is React, TypeScript, and MobX-State-Tree.
- package.json / package-lock.json define the npm-based build/runtime dependencies.
- tsconfig.json indicates TypeScript compilation and type checking are central to the codebase.
- sandbox.config.json suggests the app is intended to run in a sandbox/demo environment as well as locally.
10. Architecture boundaries to draw
- A good diagram should show:
- Entry/bootstrapping: index.tsx → withRoot
- Composition/UI layer: App → Burger / Ingredient
- State layer: RootStore → domain models Burger and Ingredient
- Assets layer: public/images/burger-assets feeding UI rendering
- The key separation is between presentational components and MST-backed state/domain models.
11. Notable absence
- There is no evidence of a backend, API client, router, or persistence layer in the file tree.
- The app appears self-contained and client-side only, with all interactive state managed in the frontend store.
Main entry points: App.tsx App · index.tsx Entry · RootStore.tsx RootStore · Burger.tsx Burger model
Components 15
Root
Repository-level docs and tooling
Runtime
HTML host and app bootstrap
UI
React components and composition
- Root wrapper · Shared providers or app-level setup
src/withRoot.tsx - App · Main application composition
src/components/App.tsx - Burger · Renders the assembled burger
src/components/Burger.tsx - Ingredient · Renders ingredient visuals
src/components/Ingredient.tsx
State
MST store and domain models
- RootStore · Central application state container
src/stores/RootStore.tsx - Burger model · Burger aggregate and state logic
src/stores/models/Burger.tsx - Ingredient model · Ingredient data and behavior
src/stores/models/Ingredient.tsx
Assets
Static presentation assets
- Burger assets · Ingredient and burger image assets
public/images/burger-assets
Connections 17
- Host page → Entry: loads · Browser host loads the React entry point
- Entry → Root wrapper: boots · Entry point composes the root wrapper
- Root wrapper → App: renders · Root wrapper provides shared setup to App
- App → Burger: composes · Main view includes the burger display
- App → Ingredient: composes · Main view includes ingredient UI
- App → RootStore: binds · App consumes central observable state
- Burger → Burger assets: uses · Burger visuals are driven by static assets
- Ingredient → Burger assets: uses · Ingredient visuals use image assets
- RootStore → Burger model: owns · Root store coordinates burger domain state
- RootStore → Ingredient model: owns · Root store coordinates ingredient domain state
- Burger model → Ingredient model: contains · Burger state is built from ingredient items
- App → Burger model: reads · UI reflects burger model state
- App → Ingredient model: reads · UI reflects ingredient model state
- package → Entry: builds · NPM tooling compiles and runs the app
- tsconfig → Entry: types · TypeScript config governs source compilation
- sandbox → Host page: hosts · Sandbox setup points at the browser shell
- React env → App: types · React environment typings support the UI code