A modern frontend demo application showcasing the Comp AI Tasks API. Built with Next.js 15, TypeScript, and Tailwind CSS.
- π Modern UI: Built with shadcn/ui components and Tailwind CSS
- π± Responsive Design: Works seamlessly on desktop and mobile devices
- π Real-time Updates: Refresh tasks with a single click
- π― Status Filtering: Filter tasks by status (To Do, In Progress, Done, Blocked)
- β‘ Fast Loading: Optimized with Next.js and TypeScript
- π¨ Clean Interface: Intuitive task cards with status badges and timestamps
- π οΈ Error Handling: Comprehensive error states and retry functionality
This demo integrates with the Comp AI Tasks API endpoints:
- GET /v1/tasks - Retrieve all tasks for the authenticated organization
- GET /v1/tasks/{id} - Get a specific task by ID (future enhancement)
interface Task {
id: string; // Unique identifier (e.g., "tsk_abc123def456")
title: string; // Task title
description?: string; // Optional task description
status: 'todo' | 'in_progress' | 'done' | 'blocked';
createdAt: string; // ISO 8601 timestamp
updatedAt: string; // ISO 8601 timestamp
}- Node.js 18+ and pnpm (or npm/yarn)
- A Comp AI API key from trycomp.ai
-
Clone and install dependencies:
cd compai-api-demo pnpm install -
Set up environment variables:
Create a
.env.localfile in the root directory:# Comp AI API Configuration NEXT_PUBLIC_COMPAI_API_URL=https://api.trycomp.ai/v1 COMPAI_API_KEY=your_api_key_here NEXT_PUBLIC_COMPAI_ORGANIZATION_ID=your_organization_id_hereImportant: Replace
your_api_key_herewith your actual Comp AI API key. -
Run the development server:
pnpm dev
-
Open your browser: Navigate to http://localhost:3000
| Variable | Description | Required |
|---|---|---|
COMPAI_API_KEY |
Your Comp AI API key for authentication | β Yes |
NEXT_PUBLIC_COMPAI_API_URL |
Base URL for the Comp AI API | No (defaults to https://api.trycomp.ai/v1) |
NEXT_PUBLIC_COMPAI_ORGANIZATION_ID |
Organization ID for session auth | No (optional for API key auth) |
compai-api-demo/
βββ app/
β βββ layout.tsx # Root layout with metadata
β βββ page.tsx # Main page component
β βββ globals.css # Global styles
βββ components/
β βββ ui/ # shadcn/ui components
β β βββ button.tsx
β β βββ card.tsx
β β βββ badge.tsx
β β βββ alert.tsx
β βββ task-card.tsx # Individual task card component
β βββ tasks-list.tsx # Main tasks list with filtering
βββ lib/
β βββ api.ts # Comp AI API client
β βββ types.ts # TypeScript type definitions
β βββ utils.ts # Utility functions
βββ README.md
The CompAIClient class provides:
- Authentication: Automatic API key and organization ID headers
- Error Handling: Comprehensive error parsing and user-friendly messages
- Type Safety: Full TypeScript support with proper interfaces
- Flexibility: Support for custom API URLs and headers
import { compAIClient } from '@/lib/api';
// Get all tasks
const response = await compAIClient.getTasks();
if (response.data) {
console.log('Tasks:', response.data);
} else if (response.error) {
console.error('Error:', response.error);
}
// Get specific task
const taskResponse = await compAIClient.getTask('tsk_abc123');Displays individual tasks with:
- Task title and description
- Status badge with color coding
- Creation and update timestamps
- Task ID for reference
Main component featuring:
- Loading states with spinner
- Error handling with retry button
- Status filtering (All, To Do, In Progress, Done, Blocked)
- Responsive grid layout
- Empty states for filtered views
- Built with Tailwind CSS for easy customization
- Uses CSS custom properties for theming
- shadcn/ui components can be easily modified
The modular structure makes it easy to add:
- Task creation/editing forms
- Task detail views
- Additional API endpoints
- Real-time updates with WebSockets
pnpm build
# Deploy to VercelThe app builds to static files and can be deployed to any hosting platform that supports Node.js applications.
-
"Network error occurred"
- Check your internet connection
- Verify the API URL is correct
- Ensure CORS is properly configured
-
"HTTP 401: Unauthorized"
- Verify your API key is correct
- Check that the API key has proper permissions
- Ensure the organization ID is valid (if required)
-
"Failed to parse response JSON"
- The API might be returning non-JSON content
- Check the API endpoint URL
- Verify the API is responding correctly
To enable detailed logging, you can modify the API client to log requests:
// In lib/api.ts, add console.log statements
console.log('Making request to:', `${this.baseUrl}/tasks`);
console.log('Headers:', this.getHeaders());For complete API documentation, visit:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This demo application is provided as-is for educational and demonstration purposes.
Built with β€οΈ using Next.js, TypeScript, and Tailwind CSS.