This document serves as a comprehensive guide for AI agents working with the ABP React TanStack application. It provides context, architecture details, and operational guidance for maintaining and extending this full-stack project.
Project Name: abp-react-tanstack
Purpose: A modern full-stack web application built with React, TanStack Router, and integrated with ABP (ASP.NET Boilerplate Platform) backend.
Key Features:
- π OIDC Authentication: Secure authentication via OpenID Connect
- π Project Management Dashboard: Task tracking, metrics, and analytics
- π οΈ API Client Generation: Auto-generated TypeScript clients from OpenAPI specs
- π¨ Modern UI: Shadcn/ui components with Tailwind CSS
- π SSR Support: Server-side rendering with TanStack Start
- π³ Docker Ready: Containerized deployment
- React 19.2.0: Latest React with concurrent features
- TanStack Router: File-based routing with type-safe navigation
- TanStack Start: Full-stack framework with server functions and SSR
- Vite: Fast development build tool
- TanStack Query: Powerful data fetching and caching
- TanStack Store: Reactive state management (optional)
- Tailwind CSS: Utility-first CSS framework
- Shadcn/ui: High-quality React components
- Radix UI: Accessible component primitives
- Lucide React: Modern icon library
- OpenID Connect: Industry-standard authentication
- PKCE: Enhanced security for public clients
- Session Management: Server-side session handling
- ABP Framework: ASP.NET Boilerplate Platform backend
- Hey API: Automated API client generation from OpenAPI specs
- Zod: Runtime type validation for API responses
- TypeScript: Full type safety throughout
- Biome: Fast linting and formatting
- Vitest: Unit testing framework
- Docker: Containerization for deployment
src/
βββ features/ # Feature-based modules
β βββ auth/ # Authentication feature
β β βββ components/ # Auth-specific components
β β βββ hooks/ # Auth-specific hooks
β β βββ stores/ # Auth state management
β β βββ constants.ts # Auth-specific constants
β βββ users/ # User management feature
β β βββ components/ # User-related components
β β βββ hooks/ # User-specific hooks
β β βββ stores/ # User state management
β β βββ constants.ts # User-specific constants
β βββ roles/ # Role management feature
β β βββ components/ # Role-related components
β β βββ hooks/ # Role-specific hooks
β β βββ stores/ # Role state management
β β βββ constants.ts # Role-specific constants
β βββ tenants/ # Tenant management feature
β β βββ components/ # Tenant-related components
β β βββ hooks/ # Tenant-specific hooks
β β βββ stores/ # Tenant state management
β β βββ constants.ts # Tenant-specific constants
β βββ dashboard/ # Dashboard feature
β βββ components/ # Dashboard components
β βββ hooks/ # Dashboard hooks
β βββ data/ # Dashboard data
β βββ types/ # Dashboard types
βββ shared/ # Shared code across features
β βββ components/ # Reusable UI components
β βββ hooks/ # Shared hooks
β βββ stores/ # Shared stores
β βββ utils/ # Utility functions
β βββ types/ # Shared types
βββ infrastructure/ # Infrastructure concerns
β βββ api/ # API client configuration
β βββ auth/ # Authentication infrastructure
β βββ config/ # Configuration files
βββ routes/ # Route definitions (TanStack Router file-based routing)
β βββ __root.tsx # Root route (always rendered)
β βββ index.tsx # Home page route
β βββ dashboard.tsx # Dashboard route
β βββ users.tsx # Users route
β βββ roles.tsx # Roles route
β βββ tenants.tsx # Tenants route
β βββ auth.*.ts # Authentication routes (login, logout, callback, me)
β βββ demo/ # Demo routes
βββ router.tsx # Router configuration (TanStack Router setup)
βββ routeTree.gen.ts # Auto-generated route tree (gitignored)
βββ constants.ts # Application constants (API endpoints, base URLs)
βββ styles.css # Global styles
βββ logo.svg # Application logo
- Purpose: Configures automated API client generation
- Input: OpenAPI spec from ABP backend (
https://abp.antosubash.com/swagger/v1/swagger.json) - Output: TypeScript client in
src/infrastructure/api/ - Plugins:
@hey-api/client-fetch: HTTP clientzod: Runtime validation schemas@tanstack/react-query: Query hooks
- Purpose: Vite configuration for development and build
- Plugins:
tanstackStart(): Full-stack framework integrationrouter.entry:router.tsx(router configuration file)router.routesDirectory:routes(file-based routing directory)
viteReact(): React plugintailwindcss(): CSS frameworkviteTsConfigPaths(): Path alias resolution
- Purpose: TanStack Router configuration
- Location:
src/router.tsx - Exports:
getRouter()function that returns a router instance - Configuration:
- Route tree imported from auto-generated
routeTree.gen.ts - Scroll restoration enabled
- Preload stale time configuration
- Route tree imported from auto-generated
- Scripts:
pnpm generate-api: Regenerate API client from OpenAPI specpnpm dev: Start development serverpnpm build: Production buildpnpm test: Run tests with Vitestpnpm lint: Code linting with Biomepnpm format: Code formatting with Biomecheck-file-size: Verify file size limits (500 lines max)
- Path Aliases:
@/*: Points to./src/*@/shared/*: Points to./src/shared/*@/features/*: Points to./src/features/*@/infrastructure/*: Points to./src/infrastructure/*
// Environment variables needed:
VITE_OIDC_ISSUER=https://your-oidc-provider.com
VITE_OIDC_CLIENT_ID=your-client-id
VITE_OIDC_CLIENT_SECRET=your-client-secret
VITE_BASE_URL=http://localhost:3000
VITE_OIDC_REDIRECT_URI=http://localhost:3000/auth/callback
VITE_SESSION_SECRET=your-super-secret-key- Login Initiation: User clicks login β redirect to OIDC provider
- Callback Handling:
/auth/callbackprocesses authorization code - Token Storage: Access/ID tokens stored server-side in session
- Route Protection:
ProtectedRoutecomponent wraps authenticated routes - Token Refresh: Automatic refresh when tokens expire
useAuth(): Authentication hooks for login/logoutProtectedRoute: Route guard componentAuthProvider: Context provider for auth state- Session Management: Server-side session storage
- Data Source:
src/features/dashboard/data/(615 sample tasks) - Features:
- Task status tracking (Done/In Process)
- Metrics calculation (completion rates, reviewer stats)
- Interactive charts (pie/bar charts using Recharts)
- Data table with sorting/filtering
- Recent activity timeline
- Team member avatars and stats
- Metrics Cards: Total tasks, completed, in-progress, completion rate
- Charts: Status distribution (pie), type distribution (bar)
- Activity Feed: Recent task updates with user avatars
- Data Table: Comprehensive task overview with filtering
# Install dependencies
pnpm install
# Start development server
pnpm dev
# Generate API client (after backend changes)
pnpm generate-api
# Run tests
pnpm test
# Lint and format code
pnpm lint
pnpm format- Trigger: Run
pnpm generate-api - Process:
- Fetches OpenAPI spec from ABP backend
- Generates TypeScript types and functions
- Creates TanStack Query hooks
- Adds Zod validation schemas
- Output: Updated files in
src/infrastructure/api/
- Create feature directory in
src/features/[feature-name]/ - Add components, hooks, stores, and constants as needed
- Create route file in
src/routes/[feature].tsx(orsrc/routes/[feature]/index.tsxfor nested routes) - Use
createFileRouteto define the route:import { createFileRoute } from "@tanstack/react-router"; import { FeatureComponent } from "@/features/[feature-name]/components/FeatureComponent"; export const Route = createFileRoute("/[feature-path]")({ component: FeatureComponent, });
- The route tree will be auto-generated on next dev server start or build
- Use Shadcn/ui components from
src/shared/components/ui/ - Follow existing patterns for consistency
- Implement responsive design with Tailwind
- Use TypeScript for type safety
- Keep files under 500 lines (enforced by check-file-size script)
# Multi-stage build
FROM node:24-alpine AS builder
# Build stage with dependencies
FROM node:24-alpine AS production
# Production stage with optimized runtime# Build Docker image
pnpm docker:build
# Run locally
pnpm docker:run
# Docker Compose (full stack)
pnpm docker:compose:up- Security: Use strong session secrets in production
- HTTPS: Required for OIDC in production
- Environment: Configure production OIDC provider URLs
- Health Checks: Built-in health check endpoint at
/api/health
/demo/api-client: Generated API client demonstration/demo/start/api-request: API request examples/demo/start/server-funcs: Server functions showcase/demo/start/ssr/*: SSR mode demonstrations
- Project Tasks: 615 sample tasks in JSON format
- Punk Songs: Demo data for music-related features
- Mock API Responses: Simulated backend responses
TanStack Start uses file-based routing following TanStack Router conventions:
- Routes Directory:
src/routes/ - Router Config:
src/router.tsx - Route Tree:
src/routeTree.gen.ts(auto-generated, gitignored)
| URL Path | File Path | Type |
|---|---|---|
/ |
routes/index.tsx |
Index Route |
/about |
routes/about.tsx |
Static Route |
/posts |
routes/posts.tsx |
Layout Route |
/posts/:id |
routes/posts/$id.tsx |
Dynamic Route |
/api/* |
routes/api/$.tsx |
Wildcard Route |
// src/routes/feature.tsx
import { createFileRoute } from "@tanstack/react-router";
import { FeatureComponent } from "@/features/feature/components/FeatureComponent";
export const Route = createFileRoute("/feature")({
component: FeatureComponent,
// Optional: loader, beforeLoad, etc.
});The __root.tsx file is always rendered and contains:
- Document shell (
<html>,<body>) - Global providers (QueryClient, AuthProvider)
- Layout logic
- HeadContent and Scripts components
The route tree is automatically generated when:
- Running
pnpm dev - Running
pnpm build - The TanStack Router plugin detects route file changes
Reference: TanStack Start Routing Guide
- Create feature directory structure under
src/features/ - Implement components with TypeScript
- Create route file in
src/routes/[feature].tsx - Use
createFileRouteto define the route - Add API integration if needed
- Update navigation components
- Add tests for new functionality
- Run
pnpm generate-apiafter backend changes - Use generated hooks:
useQuery,useMutation - Apply Zod schemas for validation
- Handle loading/error states
- Use existing Shadcn/ui components
- Follow design system patterns
- Implement responsive design
- Add proper TypeScript types
- Modify OIDC configuration in
src/infrastructure/auth/ - Update route protection logic
- Handle token refresh scenarios
- Update error handling
- Implement proper loading states
- Use TanStack Query caching effectively
- Optimize bundle size
- Implement code splitting
- Write unit tests with Vitest
- Test authentication flows
- Test API integration
- Test component interactions
-
API Client Generation Fails
- Check backend OpenAPI spec URL availability
- Verify network connectivity
- Check Hey API configuration
-
Authentication Issues
- Verify OIDC provider configuration
- Check environment variables
- Validate redirect URIs
- Check session secret strength
-
Build Issues
- Clear node_modules and reinstall
- Check TypeScript errors
- Verify Vite configuration
- Check dependency versions
-
Runtime Errors
- Check browser console for errors
- Verify environment variables loaded
- Check API endpoints accessibility
- Validate session storage
# Enable debug logging
DEBUG=oidc:* pnpm dev
# Check build output
pnpm build --debug
# Run tests in watch mode
pnpm test --watch- TanStack Router: https://tanstack.com/router
- TanStack Query: https://tanstack.com/query
- TanStack Start: https://tanstack.com/start
- ABP Framework: https://abp.io/
- Shadcn/ui: https://ui.shadcn.com/
- Hey API: https://heyapi.dev/
- OIDC Setup: See
OIDC_SETUP.md
- Code Style: Follow Biome configuration
- TypeScript: Use strict typing throughout
- Testing: Add tests for new features
- Commits: Use conventional commit messages
- PR Reviews: Required for all changes
Last Updated: November 2025 Version: 0.0.6 Maintainer: AI Development Team