Status: Accepted Date: 2024-11-21 Deciders: Frontend Team Technical Story: Frontend technology stack selection
We need to build a modern web UI for the Ambient Code Platform with:
- Server-side rendering for fast initial loads
- Rich interactive components (session monitoring, project management)
- Real-time updates for session status
- Type-safe API integration
- Responsive design with accessible components
What frontend framework and UI library should we use?
- Modern patterns: Server components, streaming, type safety
- Developer experience: Good tooling, active community
- UI quality: Professional design system, accessibility
- Performance: Fast initial load, efficient updates
- Data fetching: Caching, optimistic updates, real-time sync
- Team expertise: React knowledge on team
- Next.js 14 + Shadcn UI + React Query (chosen)
- Create React App + Material-UI + Redux
- Remix + Chakra UI + React Query
- Svelte/SvelteKit + Custom components
Chosen option: "Next.js 14 + Shadcn UI + React Query", because:
Next.js 14 (App Router):
- Server components: Reduced client bundle size
- Streaming: Progressive page rendering
- File-based routing: Intuitive project structure
- TypeScript: First-class type safety
- Industry momentum: Large ecosystem, active development
Shadcn UI:
- Copy-paste components: Own your component code
- Built on Radix UI: Accessibility built-in
- Tailwind CSS: Utility-first styling
- Customizable: Full control over styling
- No runtime dependency: Just copy components you need
React Query:
- Declarative data fetching: Clean component code
- Automatic caching: Reduces API calls
- Optimistic updates: Better UX
- Real-time sync: Easy integration with WebSockets
- DevTools: Excellent debugging experience
Positive:
-
Performance:
- Server components reduce client JS by ~40%
- React Query caching reduces redundant API calls
- Streaming improves perceived performance
-
Developer Experience:
- TypeScript end-to-end (API to UI)
- Shadcn components copy-pasted and owned
- React Query hooks simplify data management
- Next.js DevTools for debugging
-
User Experience:
- Fast initial page loads (SSR)
- Smooth client-side navigation
- Accessible components (WCAG 2.1 AA)
- Responsive design (mobile-first)
Negative:
-
Learning curve:
- Next.js App Router is new (released 2023)
- Server vs. client component mental model
- React Query concepts (queries, mutations, invalidation)
-
Complexity:
- More moving parts than simple SPA
- Server component restrictions (no hooks, browser APIs)
- Hydration errors if server/client mismatch
Risks:
- Next.js App Router still evolving (breaking changes possible)
- Shadcn UI components need manual updates (not npm package)
- React Query cache invalidation can be tricky
Technology Versions:
- Next.js: 14.x (App Router)
- React: 18.x
- Shadcn UI: Latest (no version, copy-paste)
- TanStack React Query: 5.x
- Tailwind CSS: 3.x
- TypeScript: 5.x
Key Files:
components/frontend/DESIGN_GUIDELINES.md- Comprehensive patternscomponents/frontend/src/components/ui/- Shadcn componentscomponents/frontend/src/services/queries/- React Query hookscomponents/frontend/src/app/- Next.js pages
Performance Metrics:
- Initial page load: <2s (Lighthouse score >90)
- Client bundle size: <200KB (with code splitting)
- Time to Interactive: <3s
- API call reduction: 60% fewer calls (React Query caching)
Developer Feedback:
- Positive: React Query simplifies data management significantly
- Positive: Shadcn components easy to customize
- Challenge: Server component restrictions initially confusing
- Resolution: Clear guidelines in DESIGN_GUIDELINES.md
User Feedback:
- Fast perceived performance (streaming)
- Smooth interactions (optimistic updates)
- Accessible (keyboard navigation, screen readers)
- Related: ADR-0004 (Go Backend with Python Runner)
- Next.js 14 Documentation
- Shadcn UI
- TanStack React Query
- Frontend Guidelines:
components/frontend/DESIGN_GUIDELINES.md