# My Web - Frontend Vue 3 SPA for [adam-french.co.uk](https://adam-french.co.uk). Built with Vite, Tailwind CSS v4, Pinia, and Vue Router. ## Setup ```sh npm install ``` ## Development ```sh npm run dev ``` The Vite dev server proxies API requests: - `/api` -> `http://localhost:8080` (Go backend) - `/gitea` -> `http://localhost:3000` (Gitea) - `/radio` -> `http://localhost:8000` (Icecast2) - `/py` -> `http://localhost:8000` (FastAPI; the `/py` prefix is stripped, as nginx does in production) ## Structure ``` src/ main.js entry point — awaits the wasm init, then mounts App.vue empty shell; all chrome lives in the layouts router/index.js route table + the single admin route guard graphql.js the entire GraphQL client (one axios POST) layouts/ DefaultLayout (dark, navbar+footer) and CVLayout (light, print) stores/ Pinia stores components/ reusable UI — text/, input/, util/, borders/, elle/ views/ page components, one directory per area assets/styles.css design tokens + base styles (see Styling) js/ small shared helpers wasm/ GENERATED by `npm run build:wasm`; gitignored, do not edit crates/stp_wasm the Rust source for the above ``` ## Routing Two layout shells, defined in `src/router/index.js`: | Path | Layout | Notes | | --- | --- | --- | | `/` | DefaultLayout | Landing page (statically imported — it's the first paint) | | `/stp` | DefaultLayout | The personal home page: the widget grid | | `/admin`, `/admin/login` | DefaultLayout | `/admin` is guarded by `meta.requiresAdmin` | | `/automata`, `/hotels`, `/shrines/*` | DefaultLayout | | | `/cv`, `/cv/jobs` | CVLayout | Light print theme; `/cv/jobs` is admin-only | | `/stp2` | (none) | Bare full-bleed mock, deliberately outside both layouts | | `:pathMatch(.*)*` | DefaultLayout | 404 | Everything except the landing page is a dynamic `import()`, so Vite gives each view its own chunk. Route `name`s are contracts used by `RouterLink`/`router.push` — renaming one breaks every link to it. **The admin guard** (`router.beforeEach`) has one subtlety: the admin flag comes from the `me` field of the home-data query, which arrives asynchronously. Navigating straight to `/admin` on a cold load would otherwise read an empty user and bounce a real admin to the login page, so the guard first awaits `homeData.loaded` via a self-stopping watcher. ## Data flow There is no GraphQL cache or codegen. `src/graphql.js` is a single function: ```js const data = await gql(`query { ... }`, variables); ``` It POSTs to `/api/graphql` and throws on an error response with no data. Auth rides along in **HTTP-only cookies** set by the Go backend, so nothing here touches tokens — the request just has to be same-origin (nginx in production, the Vite proxy in dev). **`stores/homeData.js` is the hub.** It issues *one* query for everything the `/stp` page needs (posts, favourites, activities, Spotify, rowing, bookmarks, Gitea feed, Steam status, current user) instead of letting a dozen widgets each fire their own request. That fetch is kicked off as a side effect of the first `useHomeDataStore()` call, so no component has to start it. The other stores are thin views over it: | Store | Role | | --- | --- | | `homeData` | the one query; owns `loaded` / `error` | | `auth` | current user; mirrors `homeData.me`, plus login/logout mutations | | `posts`, `favorites`, `activity`, `songs`, `steam` | mirror one slice of `homeData` via an `immediate` watch, and keep a placeholder value until real data arrives | | `places` | independent CRUD; sign-in only, so it is fetched lazily | | `messages` | the chat WebSocket — not GraphQL at all | | `models` | dormant; not imported anywhere | The mirroring watches are `immediate` on purpose: a store created *after* `homeData` has already loaded would never see the existing value otherwise. ## Component conventions - Layout and one-off tweaks go in Tailwind utilities; reach for a scoped `