> For the complete documentation index, see [llms.txt](https://bubblegum-reality.gitbook.io/bubblegum-reality-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bubblegum-reality.gitbook.io/bubblegum-reality-docs/getting-started/project-structure.md).

# Project Structure

```
src/
├── routes/                  # file-based routes (TanStack Router)
│   ├── __root.tsx           # app shell: providers, head metadata, fonts, Toaster
│   ├── index.tsx            # landing page (hero film, status strip, editorial panels)
│   ├── terminal.tsx         # execution terminal
│   ├── markets.tsx          # canonical stock-token registry
│   ├── portfolio.tsx        # on-chain holdings, valuation + concentration
│   ├── alerts.tsx           # alerts (awaiting auth UI)
│   ├── settings.tsx         # settings (awaiting auth UI)
│   └── about.tsx            # methodology, sources, disclosures
├── components/
│   ├── app-shell.tsx        # nav + header + network banner
│   ├── wallet-button.tsx    # connect / disconnect dialog
│   ├── network-banner.tsx   # wrong-chain remediation
│   ├── data-state.tsx       # loading / error / empty / stale primitives
│   ├── landing/             # boot-sequence, hero-video, status-strip
│   ├── terminal/            # eligibility-gate, score-panel, swap-panel, reality-check-panel
│   └── ui/                  # shadcn primitives
├── lib/
│   ├── chain.ts             # chain 4663 config, explorer links, canonical tokens
│   ├── wagmi.ts             # wagmi config (injected + WalletConnect, SSR-safe)
│   ├── money.ts             # decimal-safe math, execution cost in bps
│   ├── reality-score.ts     # deterministic 0–100 scoring
│   ├── market-session.ts    # US market session state
│   ├── market-types.ts      # client-safe DTOs
│   ├── assets.ts            # CDN URLs for landing media
│   ├── eligibility.ts       # client-side gate state
│   ├── ai-schema.ts         # bounded Reality Check schema + error mapping
│   ├── swap-exec.ts         # exact-amount approval helpers
│   ├── reality-check.ts     # client-safe prompt + snapshot cache key
│   ├── portfolio.ts         # valuation, weights, HHI, concentration bands
│   ├── market.functions.ts  # server fns: assets, prices, chain status, eligibility
│   ├── swap.functions.ts    # server fns: indicative price, firm quote, config check
│   ├── portfolio.functions.ts # server fn: batched balance reads + valuation
│   ├── ai.functions.ts      # server fn: Reality Check
│   ├── account.functions.ts # server fns: profile, wallets, watchlists, alerts, history
│   ├── robinhood.server.ts  # asset/price fetch + normalization
│   ├── zerox.server.ts      # 0x proxy, validation, rate limit, error sanitizing
│   ├── rpc.server.ts        # chain status reads
│   ├── portfolio.server.ts  # Multicall3 balance reads
│   ├── reality-check.server.ts # AI call + ai_insights cache
│   ├── ai-gateway.server.ts # AI gateway provider
│   ├── eligibility.server.ts# restricted-region evaluation
│   └── __tests__/           # Vitest suite
├── hooks/
│   ├── use-local-storage.ts # SSR-safe persistence
│   ├── use-network.ts       # chain switch / add
│   ├── use-eligibility.ts   # acknowledgement state
│   └── use-mobile.tsx
└── styles.css               # Tailwind v4 theme + design tokens
```

## Layering rules

```
components / routes
        │  import only
        ▼
*.functions.ts        ← createServerFn wrappers (thin, Zod-validated)
        │
        ▼
*.server.ts           ← secrets, fetch, normalization (never imported by UI)
```

### Thin-wrapper invariant

A file declaring `createServerFn` may contain **only** imports, erased types, and exported server-function declarations. Every runtime helper, constant, and config lives in an imported module or inside the handler. Violating this survives typecheck but produces a `ReferenceError` at runtime after function splitting.

### Files you must not edit

* `src/routeTree.gen.ts` — generated by the router plugin.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://bubblegum-reality.gitbook.io/bubblegum-reality-docs/getting-started/project-structure.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
