Naalya Handbook

The stack

A guided tour of the libraries the school website runs on, what each one does, why it's here, and how they fit together.

This page is for a developer new to the school website. It covers the libraries that matter in package.json: which job each one owns, why it is here, and how the pieces fit into one app.

The site is a React Router app that renders on the server, gets its content from Sanity and its application data from a typed API client, and uses shadcn and Radix for UI. Each section below covers one part of that sentence.

The repository holds two independent packages: the website frontend at the root (website-frontend) and the Sanity Studio in sanity/ (naalya-website). pnpm-workspace.yaml declares no packages: field, so a root pnpm install does not install the Studio. Run cd sanity && pnpm install as a separate step. Setup covers the Studio side.


Framework and rendering

At the core sits React 19, rendered server-side through React Router 7 in framework mode. That phrase is the most important one on the page. "Framework mode" means React Router isn't just matching URLs: it owns loaders, actions, and server-side rendering (SSR), the same job Remix used to do. Every page you'll write starts life on the server, with data already fetched, before the browser ever sees it.

One consequence shapes every import you write: everything comes from react-router directly, never react-router-dom. The Node adapter and production server (@react-router/node, @react-router/serve) round out the runtime, and @react-router/dev supplies the Vite plugin and typegen.

SSR is on by default, and the switch is a single line:

react-router.config.ts
import type { Config } from "@react-router/dev/config";

export default {
  ssr: true, // flip to false for SPA mode
} satisfies Config;

isbot is installed but never imported. The React Router template includes it for bot detection inside a custom entry.server, and this project has no custom entry files, so it uses React Router's built-in ones. You can ignore isbot.

The build is Vite 7, and the plugin order in vite.config.ts is not arbitrary: tailwindcss() must run before reactRouter(), with devtools() registered first. Two dependencies also have to be force-bundled for SSR because they ship CSS imports the server build can't externalize:

vite.config.ts
export default defineConfig({
  plugins: [devtools(), tailwindcss(), reactRouter(), tsconfigPaths()],
  ssr: {
    // these ship CSS/ESM that breaks if left external
    noExternal: ["streamdown", "react-syntax-highlighter"],
  },
});

If you ever add a dependency that imports CSS at module load and the SSR build crashes, ssr.noExternal is the first place to look. The full routing model is in Routing and pages.


Styling and UI

Styling runs on Tailwind CSS v4 with zero JavaScript config. There is no tailwind.config.js anywhere in the repo, and that surprises people, so it's worth saying twice. Every theme token, plugin, and custom variant lives inside app/app.css. The CSS file is the config:

app/app.css
@import "tailwindcss";
@import "tw-animate-css";
@plugin "@tailwindcss/typography";
@custom-variant dark (&:is(.dark *));

@theme {
  --font-poppins: "Poppins", sans-serif;
  /* + color tokens in oklch, custom keyframes */
}

Class composition always flows through the cn() helper: clsx for conditionals, tailwind-merge to resolve conflicts so the last utility wins. Variants for components come from class-variance-authority. If you're hunting for where a color or font is defined, open app.css, not a JS file that doesn't exist. The full token system and dark-mode mechanism are in Styling and theming.

The component layer is shadcn/ui (new-york style, neutral base) sitting on top of a near-complete Radix UI primitive set. The split is the whole point: Radix supplies the headless behaviour, focus traps, keyboard nav, ARIA, and shadcn copies styled, editable component files into app/components/ui/ that you own outright. Adding one is a single command that reads components.json and wires cn for you:

terminal
pnpm dlx shadcn@latest add <component>

Twenty-six @radix-ui/react-* packages are installed, and every one is imported. When you add a shadcn component, its Radix dependency is almost always present already. Install a new Radix package only when the CLI says that one is missing.

Three icon sets coexist, and the distinction matters: @tabler/icons-react is the primary set for app content and the target of the CMS icon-mapper, lucide-react is what shadcn's generated components use internally, and iconsax-react is a niche extra. Beyond that, a fleet of focused libraries each own one visual job: embla-carousel for carousels, sonner for toasts, vaul for drawers, cmdk for the command menu, recharts for charts, canvas-confetti and react-snowfall for flourishes. Reach for the existing one before adding a new dependency; Components covers the conventions.

Use the zustand theme store, not next-themes. sonner.tsx imports useTheme from next-themes, but the app never mounts its ThemeProvider, so useTheme always returns the "system" fallback. Theming is a custom zustand store (theme.provider.tsx) that toggles .dark on <html>.

For animation, standardize on motion, imported as motion/react (used in 22 files). Both motion and framer-motion are installed at the same major version: they're separate packages, so it's easy to grab the wrong one. framer-motion appears in exactly one file and should be treated as legacy.


Data and state

The site has two kinds of state and one rule: server state lives in TanStack Query, client state lives in zustand, and URL state lives in nuqs. Keep them in their lanes and the data flow stays predictable.

Server state is the interesting one because of SSR. A single shared QueryClient would leak one user's cache to the next request, so the client is created fresh per request on the server and reused as a singleton in the browser, always obtained through a factory, never new-ed in a component:

app/lib/query-client.ts
let browserQueryClient: QueryClient | undefined;

export function getQueryClient() {
  if (typeof window === "undefined") {
    return makeQueryClient(); // fresh per request on the server
  }
  browserQueryClient ??= makeQueryClient(); // singleton in the browser
  return browserQueryClient;
}

Never instantiate QueryClient inline

Calling new QueryClient() inside a component breaks the SSR contract and can leak cache across users. Always go through getQueryClient(). This is the single most important rule in the data layer.

Client state, theme, settings, feature toggles, is zustand with the persist middleware, and persisted keys are namespaced naalya-* (naalya-theme, naalya-settings-storage) so they're easy to spot in localStorage. The provider stack assembles in a fixed order (NuqsProvider > QueryProvider > PostHogProvider > ThemeProvider); that order is deliberate, not incidental.


Forms and validation

Forms are react-hook-form for state, Zod for the schema, and @hookform/resolvers as the bridge between them. RHF keeps re-renders cheap by tracking fields outside React state; Zod defines the shape once and validates against it. Specialized inputs fill the gaps, input-otp for verification codes, react-phone-number-input for international numbers, and everything funnels through shadcn's form.tsx.

The project runs Zod v4, which has API differences from v3. Many tutorials online still show v3 syntax, which causes confusing type errors here. Check the current Zod docs before you copy an example. Forms shows the project's own patterns.


Content: Sanity CMS

Page content, the words, images, and structured sections an editor manages, comes from Sanity (project hdefozzv, dataset development). The flow is consistent everywhere: queries are authored with groq's defineQuery, prefetched in React Router loaders, then hydrated on the client by TanStack Query. That's the same SSR handoff you saw above, applied to CMS data.

The supporting cast is small and each part has a clear job: @sanity/client reads (in the browser) and writes (on the server only), @sanity/image-url builds CDN transform URLs, @portabletext/react renders rich-text bodies, and @sanity/visual-editing powers the in-context Presentation overlay.

app/queries/.../example.query.ts
import { defineQuery } from "groq";

export const SITE_SETTINGS_QUERY = defineQuery(
  `*[_type == "siteSettings"][0]{ siteName, /* ... */ }`,
);

Reads happen in the browser and writes on the server. app/lib/sanity-client.ts is the read-only client that the browser uses, and it carries no token. Writes go through the site's own POST /api/form-submission route, which uses app/lib/sanity-write-client.server.ts and the server-only SANITY_WRITE_TOKEN. The .server suffix makes the build fail if browser code imports that file.

GROQ authoring, the content model, pagination, and the singleton pattern are all documented across the Sanity CMS section.


The application API client

Content is one thing; application data, students, admissions, the things behind auth, is another. That comes from a NestJS-style backend, the "Naalya Schools API", and the frontend talks to it through a fully type-safe axios client generated from the live OpenAPI spec into app/services/api/.

The key property: the generated client returns a Result<T> shaped { data, error } and never throws. You branch on error instead of wrapping every call in try/catch:

app/services/api/usage-example.ts
import { api } from "@/services/api/api.client";

const { data, error } = await api.get("/students/{id}", {
  params: { path: { id } },
});
// or the semantic, operationId-named form:
const result = await api.op.getStudentById({ id });

Regeneration is driven by chowbea-axios, point api.config.toml at the swagger endpoint and run pnpm api:generate (or pnpm api:watch to poll, or pnpm dev:all to run the watcher alongside Vite). The _generated/ files are overwritten every run; the wrapper files around them are generated once and then owned by the team, so they're safe to hand-edit.

chowbea-axios runs every api:* script but is not in dependencies, the lockfile, or node_modules, because it is installed globally. On a fresh clone, pnpm api:generate fails with "command not found" until you install the CLI globally or run it through pnpm dlx.

The API client covers the interceptors, the Result shape, and regeneration in full.


AI features

The website's chat (app/components/naalya-chat/widget.tsx) talks to the API's public assistant directly, without an AI SDK. app/lib/naalya-chat/client.ts posts to /api/v1/public-ai/chat and reads /api/v1/public-ai/config, sending the site's publishable API key (VITE_NAALYA_API_KEY), which only works from the site's allowed origins; see API tokens. streamdown renders the streamed markdown and use-stick-to-bottom keeps the latest message in view.


Tooling and quality

The frontend uses Biome and only Biome, no ESLint, no Prettier, with biome.jsonc as the single source of truth and the ultracite preset on top. (The Sanity Studio is the exception: it still runs ESLint + Prettier.) Type-checking pairs react-router typegen with tsc. The two commands you run before pushing:

terminal
pnpm dlx ultracite fix   # lint + format (what lint-staged is meant to run)
pnpm typecheck           # react-router typegen && tsc

The pre-commit hook is a no-op

Husky and lint-staged are configured, but the actual .husky/pre-commit hook only echos and exits: nothing is formatted or linted on commit. Running ultracite fix and typecheck yourself before pushing isn't optional housekeeping; it's the only thing standing between you and unformatted code in main.

Analytics goes through PostHog via typed event helpers in app/lib/analytics.ts (never raw posthog.capture at the call site), and logging goes through a shared pino logger. One trap worth knowing: react-ga4 is installed but unused, live Google Analytics runs from an inline gtag script in root.tsx with a hardcoded measurement ID, so the VITE_PUBLIC_GA4_MEASUREMENT_ID env var is effectively ignored.


Configuration and key versions

VITE_* values are inlined at build time. Change one and you rebuild. Copy .env.example rather than reconstructing names from memory. The Dockerfile ARG list includes extra names the example file does not. Getting Started walks through the file. package.json sets packageManager to pnpm@11.12.0.

Most dependencies float on a caret, but a handful are pinned on purpose. If a line in package.json has no ^, it was pinned deliberately, bump it intentionally, in its own commit:

Pinned dependencyWhy it's locked
rechartsCharting API stability
@biomejs/biome, ultraciteLint output must be reproducible

Production pins node:22-alpine. Local machines often run a newer Node (24.x), and that works, but CI and containers should match the Dockerfile. The build raises the V8 heap to 4 GB, so a container with less than 4 GB of memory can run out of memory during pnpm build.


Where to go next

On this page