Stack

ConcernChoice
FrameworkReact 19 + React Compiler
BundlerVite 6
Package managerBun (workspace monorepo)
RoutingTanStack Router (file-based)
Data fetchingTanStack Query v5
StylingTailwind CSS v4
Headless UIBase UI (@base-ui/react)
IconsPhosphor Icons (@phosphor-icons/react)
i18ni18next + react-i18next
Type checkingTypeScript 5.7 (strict)

Project layout

packages/observer-web/
  src/
    main.tsx          # app bootstrap (Router + Query + i18n)
    main.css          # Tailwind entry
    routes/           # TanStack Router file-based routes (_app/, _auth/)
    components/       # UI components, grouped by domain
      ui/             # atoms: button, badge, icons, toast…
      layout/         # app shell: page-header, sidebar-link…
      forms/          # form-field, filter-bar, comboboxes
      table/          # data-table, pagination, row-actions
      dialogs/        # confirm-dialog, form-dialog
      drawer/         # drawer-shell
      people/ pets/ support/ households/ migration/
      documents/ tags/ users/ permissions/ profile/
      reports/ charts/ auth/ date-picker/ search-palette/
    hooks/            # React Query hooks, grouped by domain
      reference/      # countries, states, places, offices, categories
      people/ pets/ support/ households/ migration/
      documents/ tags/ notes/ users/ projects/ reports/
    stores/           # Zustand: auth, toast
    types/            # TypeScript types matching API responses
    lib/              # api client, i18n, export, params helpers
    constants/        # enum → i18n key maps
    locales/          # ky.json (default), en.json, uk.json, ru.json…

Running

# Install dependencies
cd packages/observer-web && bun install

# Backend + frontend dev servers concurrently
just dev

# Frontend only (http://localhost:5173)
cd packages/observer-web && bun run dev

# Production build (frontend + embedded Go binary)
just build-prod

# Format frontend code
cd packages/observer-web && bun run fmt

Import conventions

@/ alias resolves to src/. Configured in both tsconfig.json and vite.config.ts.

Import order (blank line between groups):

  1. react, react-dom
  2. External libs (@tanstack/*, @base-ui/*, @phosphor-icons/*, i18next)
  3. App aliases (@/lib/*, @/stores/*, @/types/*)
  4. Colocated siblings (./constants, ./types)
  5. Styles (.module.css) — always last

Adding a new route

  1. Create a file under src/routes/. TanStack Router’s Vite plugin auto-generates the route tree.
  2. Protected routes go under _app/ (requires authentication).
  3. Public auth routes go under _auth/ (redirects away if already authenticated).

Example:

// src/routes/_app/settings.tsx → /settings (protected)
import { createFileRoute } from "@tanstack/react-router";

export const Route = createFileRoute("/_app/settings")({
  component: SettingsPage,
});

function SettingsPage() {
  return <div>Settings</div>;
}

Adding translations

  1. Add keys to both src/locales/ky.json and src/locales/en.json.
  2. Use in components via useTranslation():
import { useTranslation } from "react-i18next";

function MyComponent() {
  const { t } = useTranslation();
  return <p>{t("namespace.key")}</p>;
}

Interpolation uses {{variable}} syntax in JSON:

{ "greeting": "Salam, {{name}}" }
t("greeting", { name: "Ali" }); // → "Salam, Ali"

Environment variables

VariableDefaultDescription
VITE_API_URLhttp://localhost:9000Backend API base URL

Vite only exposes variables prefixed with VITE_.