π€ AI Agent Quick-Start Before writing custom
fetch()calls or a dedicated data store, review this document. We exclusively use TanStack Query v5 for server state and Zustand for global client state.
This document serves as the high-level system specification for the ModelSEED-UI Next.js 16 app.
ModelSEED-UI is a React 19 application served by the Next.js App Router:
| Layer | Technology | Rules & Boundaries |
|---|---|---|
| Routing Layer | Next.js 16 (App Router) | All biological paths must match legacy URLs via catch-all routes (e.g. /model/[...path]). Use Server Components by default. |
| UX & Presentation | MUI v7 (Material UI) | Shared design system. Rely strictly on lib/theme.ts. For heavy data rendering, use DataGrid. |
| Data Engine | TanStack Query v5 | Sole manager of request lifecycles, caching, and loading/error states for all API interaction. |
| Shared State | Zustand | Only for global auth (useAuth) and layout toggles. Do NOT put API responses here. |
All core network logic MUST reside inside lib/api/ and never directly in a .tsx page. The app interfaces with three primary systems:
- What: The robust user data storage system.
- Where:
https://p3.theseed.org/services/Workspace - Client:
lib/api/workspace.ts - Usage: Only for legacy workflows and specific biological object retrieval parsing.
- What: The modern computational proxy and analysis backend.
- Where: Defined by
MODELSEED_API_URL(currentlyhttp://poplar.cels.anl.gov:8000). - Client:
lib/api/modelseed.ts - Usage: Used for My Models, My Media, Jobs, and workspace proxy events. Authentication requires a PATRIC Token in the
Authorizationheader.
- What: Extremely fast reference data search.
- Where: Defined by
SOLR_BASEinlib/api/config.ts. - Client:
lib/api/biochem.ts - Usage: Exclusively for querying reactions and compounds for reference biochemistry tables.
We enforce a strict Query-First architecture. When building a new data-driven view:
- Invoke TanStack Query: The component calls
useQuery()with a hardcoded, stablequeryKeyarray. - Abstract the Network: The
queryFnexecutes a function mapped fromlib/api/(e.g.,getModelsFromApi()). - Handle State Gracefully: Let TanStack Query manage
isLoading,isError, anddataavailability natively. - Cache & Revalidation: TanStack caches the output aggressively. Ensure mutations invalidate specific keys via
queryClient.invalidateQueries().
ModelSEED-UI is dense and highly scientific. We utilize MUI v7 exclusively.
Core Directives for UX:
- No Ad-Hoc CSS: Exclude raw
.cssor inline global styling. Rely heavily on thesx={{...}}prop formatted in consistent increments of8px. - Constraint Widths: Use
Container maxWidth="lg"or"xl"to keep text readability high. - Palette: Defined inside
lib/theme.ts. Deep purples and cyans to emulate legacy ModelSEED branding. - Complex Tables: If a table manages more than 50 rows or requires column sorting, filtering, or pagination, exclusively use MUI's
DataGridcombined with the unifiedDataControlHeader.
- Client vs Server Components:
- Next.js default is a Server Component (
app/page.tsx). Do this whenever state/effects are unneeded. - Inject
'use client'at the absolute lowest node of the component tree that requires interactivity or user hooks.
- Next.js default is a Server Component (
- Selective Rerendering:
useMemocomplexDataGridcolumns to prevent heavy DOM thrashing.useCallbackon grid event handlers.
- Structure & Code-Splitting:
- Page-specific helper UI stays in the Route directory.
- Global or cross-functional UI lives in
components/ui/.