feat: add React frontend with search and mod pages
Add apps/web (Vite + React Router + Tailwind v4 + Zustand) with a search page and a mod page that analyzes saves via @tts/extract. Document the frontend in the README and docs.
This commit is contained in:
+60
-17
@@ -21,20 +21,20 @@ Steam Workshop, fetching full TTS save files, and analyzing their contents.
|
||||
## Non-goals (for now)
|
||||
|
||||
- Backend traversal endpoints (deferred by design).
|
||||
- Frontend app (later; will consume `packages/extract` directly).
|
||||
- Caching / Redis / multi-instance concerns.
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
apps/proxy ──► packages/tts ──► packages/shared
|
||||
│ │
|
||||
│ └──► (fetchMod → TTSMod)
|
||||
▼
|
||||
packages/extract ──► packages/tts (traverseMod) ──► packages/shared (types)
|
||||
(isomorphic, used by future frontend)
|
||||
apps/web ──► apps/proxy ──► packages/tts ──► packages/shared
|
||||
│ │ │
|
||||
│ │ └──► (fetchMod → TTSMod)
|
||||
│ ▼
|
||||
└──► packages/extract ──► packages/shared (types)
|
||||
(isomorphic, used by the frontend)
|
||||
```
|
||||
|
||||
- **`apps/web`** — React frontend (search + mod pages).
|
||||
- **`apps/proxy`** — Hono server. Search + fetch only. No traversal endpoints.
|
||||
- **`packages/tts`** — low-level fetcher: Steam API call, BSON parse, filename
|
||||
derivation. Returns raw parsed `TTSMod`.
|
||||
@@ -54,16 +54,34 @@ tts-workshop/
|
||||
├── docs/
|
||||
│ └── implementation-plan.md # this file
|
||||
├── apps/
|
||||
│ └── proxy/
|
||||
│ ├── proxy/
|
||||
│ │ ├── package.json
|
||||
│ │ ├── tsconfig.json
|
||||
│ │ └── src/
|
||||
│ │ ├── index.ts # Hono app + @hono/node-server
|
||||
│ │ ├── routes/
|
||||
│ │ │ ├── search.ts # GET /search?q=...&page=1
|
||||
│ │ │ ├── items.ts # GET /items/:id, /items/:id/file
|
||||
│ │ │ └── health.ts # GET /health
|
||||
│ │ └── env.ts # zod env validation
|
||||
│ └── web/
|
||||
│ ├── package.json
|
||||
│ ├── tsconfig.json
|
||||
│ ├── vite.config.ts # dev proxy → localhost:3000
|
||||
│ ├── index.html
|
||||
│ └── src/
|
||||
│ ├── index.ts # Hono app + @hono/node-server
|
||||
│ ├── routes/
|
||||
│ │ ├── search.ts # GET /search?q=...&page=1
|
||||
│ │ ├── items.ts # GET /items/:id, /items/:id/file
|
||||
│ │ └── health.ts # GET /health
|
||||
│ └── env.ts # zod env validation
|
||||
│ ├── main.tsx # React root + router
|
||||
│ ├── App.tsx # layout + routes
|
||||
│ ├── api.ts # fetch wrappers for /search, /items
|
||||
│ ├── index.css # tailwind v4 entry
|
||||
│ ├── pages/
|
||||
│ │ ├── SearchPage.tsx
|
||||
│ │ └── ModPage.tsx
|
||||
│ ├── components/
|
||||
│ │ └── SearchResults.tsx
|
||||
│ └── stores/
|
||||
│ ├── searchStore.ts # zustand
|
||||
│ └── modStore.ts # zustand
|
||||
└── packages/
|
||||
├── shared/
|
||||
│ └── src/
|
||||
@@ -159,6 +177,27 @@ Hono server exposing search + fetch.
|
||||
- `GET /health` — liveness.
|
||||
- `env.ts` — zod validation of `STEAM_API_KEY`, `PORT`.
|
||||
|
||||
### `apps/web`
|
||||
|
||||
React frontend (Vite + React Router + Tailwind v4 + Zustand). Consumes the
|
||||
proxy API and `packages/extract` directly for analysis.
|
||||
|
||||
- `main.tsx` — React root, `BrowserRouter`.
|
||||
- `App.tsx` — app shell (header) + routes: `/` (search), `/mod/:id` (mod).
|
||||
- `api.ts` — typed `fetch` wrappers for `/search` and `/items/:id`, plus a
|
||||
`modFileUrl` helper for the raw-file download.
|
||||
- `pages/SearchPage.tsx` — search form, drives `searchStore`.
|
||||
- `pages/ModPage.tsx` — loads the mod via `modStore`, uses `@tts/extract`
|
||||
(`flattenObjects`, `collectRefs`) to render objects and asset refs, and links
|
||||
to the raw save file.
|
||||
- `components/SearchResults.tsx` — result grid + pagination.
|
||||
- `stores/searchStore.ts` / `stores/modStore.ts` — Zustand stores for search
|
||||
and mod state.
|
||||
- `vite.config.ts` — dev proxy for `/search`, `/items`, `/health` →
|
||||
`http://localhost:3000`.
|
||||
- Styling: Tailwind v4 via `@tailwindcss/vite`; `index.css` imports
|
||||
`tailwindcss`.
|
||||
|
||||
## Endpoints
|
||||
|
||||
| Method | Path | Description | Auth |
|
||||
@@ -186,14 +225,16 @@ packages/extract → flatten objects / extract refs / download assets
|
||||
- `bson` — BSON deserialization.
|
||||
- `cheerio` — Workshop browse page scraping (backend only).
|
||||
- `zod` — validation.
|
||||
- `react`, `react-dom`, `react-router-dom`, `zustand` — frontend.
|
||||
- `vite`, `@vitejs/plugin-react`, `tailwindcss`, `@tailwindcss/vite` — frontend tooling.
|
||||
- `tsx`, `typescript`, `eslint`, `prettier` — tooling.
|
||||
|
||||
## Tooling
|
||||
|
||||
- TypeScript strict mode.
|
||||
- `tsx` for dev, `tsc` for build.
|
||||
- `tsx` for dev, `tsc` for build; `vite` for the frontend dev server/build.
|
||||
- `vitest` for unit tests, colocated as `*.test.ts` next to sources.
|
||||
- Root scripts: `pnpm dev`, `pnpm build`, `pnpm test`, `pnpm lint`.
|
||||
- Root scripts: `pnpm dev`, `pnpm dev:web`, `pnpm build`, `pnpm test`, `pnpm lint`.
|
||||
|
||||
## Build order
|
||||
|
||||
@@ -203,7 +244,9 @@ packages/extract → flatten objects / extract refs / download assets
|
||||
3. `packages/tts` — fetch + parse (existing scraper code).
|
||||
4. `packages/extract` — objects, refs, download.
|
||||
5. `apps/proxy` — search + items + health routes, env validation.
|
||||
6. Wire up root scripts, `.env.example`, README.
|
||||
6. `apps/web` — React frontend (search + mod pages), consuming the proxy and
|
||||
`packages/extract`.
|
||||
7. Wire up root scripts, `.env.example`, README.
|
||||
|
||||
## Risks / caveats
|
||||
|
||||
|
||||
Reference in New Issue
Block a user