Overview
The ADK Utils Example project follows Next.js 16 App Router conventions with a clear separation of concerns. The codebase is organized into logical directories that separate UI components, business logic, AI agents, and API routes.Directory Structure
Key Directories
/app
Next.js 16 App Router with pages, layouts, and API routes
/components
Reusable React UI components for the chat interface
/hooks
Custom React hooks for app functionality
/lib
Shared utilities, constants, and helper functions
/app Directory
Theapp directory contains all Next.js App Router pages and API routes.
/app/agents
This directory contains ADK agent definitions, tools, and configurations.
agent1.ts (lines 1-76)
get_current_time- Returns the current time in a specified citycreate_mermaid_diagram- Creates Mermaid diagrams (flowchart, sequence, etc.)view_source_code- Shows source code to the user
/app/api
API routes that handle backend communication./app/api/genai-agent
File:route.ts (lines 1-28)
/app/api/chat
Alternative chat endpoint (currently not used by the main UI).Root App Files
| File | Purpose | Location |
|---|---|---|
page.tsx | Main chat interface (home page) | app/page.tsx |
layout.tsx | Root layout with fonts and metadata | app/layout.tsx |
globals.css | Global styles and Tailwind setup | app/globals.css |
/components Directory
All UI components for the chat interface are located here.chat-message.tsx
Renders individual chat messages with Markdown, code highlighting, and Mermaid diagrams
chat-input.tsx
Input field with submit, reset, and info buttons
chat-header.tsx
Header with title, suggestions, and reset functionality
chat-empty-state.tsx
Welcome screen shown when no messages exist
chat-typing-indicator.tsx
Animated indicator shown while AI is generating
ui/
shadcn/ui base components (Button, Tooltip, etc.)
ChatMessage Component
TheChatMessage component uses Streamdown with plugins for advanced rendering:
/hooks Directory
Custom React hooks that provide reusable functionality.use-scroll-to-bottom.ts
Auto-scrolls chat container when new messages arrive
use-focus-on-load.ts
Automatically focuses input field on page load
/lib Directory
Shared utilities and constants used throughout the app.constants.ts
Defines app-wide constants including:- Rate limiting:
LIMIT = 20messages per hour - Time window:
ONE_HOUR_IN_MS = 60 * 60 * 1000 - Suggestions: Array of pre-defined prompts with icons
utils.ts
Utility functions for common operations like class name merging./e2e Directory
Playwright end-to-end tests for the application.home.spec.ts
Tests for the home page rendering
chat.spec.ts
Tests for chat functionality and interactions
Configuration Files
package.json
Key Dependencies:@google/adk- Google Agent Development Kit@yagolopez/adk-utils- Enhanced Ollama model supportai- Vercel AI SDKnext(16.1.6) - Next.js frameworkreact(19.2.4) - React librarystreamdown- Markdown rendering with plugins
Next.js App Router Structure
The main chat interface (
app/page.tsx) is a Client Component because it uses React hooks like useState and useChat.Related Pages
Request Flow
Learn how user messages flow through the system
Installation
Set up your development environment