A monorepo example demonstrating type-safe integration between TanStack frontend and Agentuity AI agents, orchestrated with Turborepo.
# Install dependencies
bun install
# Set up your Agentuity credentials
cp apps/agentuity/.env.example apps/agentuity/.env
# Edit apps/agentuity/.env and add your AGENTUITY_SDK_KEY
# Start development (both frontend and backend)
bun devOpen http://localhost:3000 to use the translation app.
tanstack-turborepo/
├── apps/
│ ├── web/ # TanStack frontend (port 3000)
│ │ └── src/components/TranslateDemo.tsx
│ └── agentuity/ # Agentuity backend (port 3500)
│ └── src/agent/translate/agent.ts
├── packages/
│ └── shared/ # Shared schemas & types
│ └── src/translate.ts
├── turbo.json # Task orchestration
└── package.json # Workspace root
Define schemas once, use everywhere:
// packages/shared/src/translate.ts
export const TranslateInputSchema = s.object({
text: s.string(),
toLanguage: s.enum(LANGUAGES).optional(),
model: s.enum(MODELS).optional(),
});// apps/agentuity/src/agent/translate/agent.ts
import { TranslateInputSchema, TranslateOutputSchema } from '@tanstack-turborepo/shared';
const agent = createAgent('translate', {
schema: { input: TranslateInputSchema, output: TranslateOutputSchema },
handler: async (ctx, { text, toLanguage, model }) => { ... }
});// apps/web/src/components/TranslateDemo.tsx
import '@agentuity/routes'; // Generated types
import { LANGUAGES, type Language } from '@tanstack-turborepo/shared';
const { data, invoke } = useAPI('POST /api/translate');
// TypeScript knows the exact input/output types!bun dev # Builds routes first, then runs both apps in parallel
bun build # Builds agentuity first (for route types), then web| Command | Description |
|---|---|
bun dev |
Start both frontend and backend |
bun build |
Build all packages |
bun typecheck |
Type-check all packages |
- Frontend: http://localhost:3000
- Agentuity Backend: http://localhost:3500
- Agent Workbench: http://localhost:3500/workbench
- Schemas defined in
packages/shared - Agent uses schemas →
agentuity buildgeneratesroutes.ts - Frontend imports
@agentuity/routes(TS path alias) useAPI('POST /api/translate')is fully typed
The frontend and backend are independently deployable:
# Deploy just the agent
cd apps/agentuity && bun run deploy
# Build frontend for production
cd apps/web && bun run buildCreate apps/agentuity/.env with:
# Required: Agentuity SDK key
AGENTUITY_SDK_KEY=your_key_hereGet your SDK key from agentuity.com.