# Architecture TODO

This file tracks the current architecture cleanup work for the Nanobot web app.

## Card Platform

- [x] Move all template-backed cards to the dynamic `card.js` runtime.
- [x] Remove inline-script fallback execution from the frontend shell.
- [x] Keep the card runtime contract documented and stable.
- [x] Validate every template card automatically in CI/local checks.
- [x] Add lightweight fixture coverage for mount/update/destroy behavior.

## Template Source Of Truth

- [x] Treat `~/.nanobot/cards/templates` as the live source of truth.
- [x] Sync repo examples from the live template tree with a script instead of manual copying.
- [x] Make template drift a failing quality check.

## Backend Structure

- [x] Split card persistence/materialization out of `app.py`.
- [x] Split session helpers out of `app.py`.
- [x] Split Nanobot transport/client code out of `app.py`.
- [x] Keep HTTP routes thin and push domain logic into service modules.

## Frontend Structure

- [x] Split `useWebRTC.ts` into transport, sessions, cards/feed, and workbench modules.
- [x] Reduce `App.tsx` to layout/navigation concerns only.
- [x] Keep `CardFeed.tsx` focused on rendering, not domain mutation orchestration.

## Updates And Reactivity

- [x] Replace polling-heavy paths with evented updates where possible.
- [x] Keep card updates localized so a live sensor refresh does not churn the whole feed.

## Remaining Cleanup

- [x] Move backend startup state into FastAPI lifespan/app state.
- [x] Stop importing private underscore helpers across app boundaries.
- [x] Split the backend route surface into router modules.
- [x] Split the card runtime renderer into loader/host/renderer modules.
- [x] Replace async tool-job polling with an evented stream.
