/pages - Next.js pages and routing
/components - Reusable React components
/hooks - Custom React hooks (auth, API)
/lib/utils - Utility functions (logger, API client, templates)
/lib/styles - Global CSS and styling themes
/constants - Configuration constants
/types - TypeScript type definitions
- Next.js 13+: React framework with App Router
- TypeScript: Type safety throughout the codebase
- Tailwind CSS: Utility-first CSS framework with custom theme
- Supabase: Authentication and user management
- Nation API: Backend agent management and chat
The application includes a comprehensive logging system controlled by the IS_DEV flag:
- Set
NEXT_PUBLIC_APP_ENV=devorNODE_ENV=development - All logs displayed in browser console
- Includes API calls, authentication events, component lifecycle, and errors
- Set
NEXT_PUBLIC_APP_ENV=prodorNODE_ENV=production - All logging disabled for performance and security
import logger from '../utils/logger';
// Log API calls
logger.apiCall('POST', '/agents', agentData);
// Log authentication events
logger.auth('User signed in', { userId: user.id });
// Log component events
logger.component('mounted', 'ComponentName');
// Log errors with context
logger.error('Failed to create agent', { error: error.message });The apiClient.ts provides a centralized HTTP client with:
- Authentication: Automatic bearer token handling
- Error Handling: Comprehensive error response processing
- Logging: All requests/responses logged in development
- Type Safety: TypeScript interfaces for all API responses
Uses Supabase with React hooks:
import { useSupabaseAuth } from '../hooks/useSupabaseAuth';
const { user, signIn, signOut, loading } = useSupabaseAuth();Centralized theme configuration in lib/utils/theme.ts:
- Neon Color Palette: Lime, cyan, pink, purple variants
- CSS Custom Properties: Variables for dynamic theming
- Component Styles: Reusable style functions
- Dark Mode: Built-in dark theme support
# Create feature branch
git checkout -b feat/feature-name
# Make changes
npm run dev
# Test thoroughly
npm run build- TypeScript: Strict type checking enabled
- ESLint: Linting rules for code consistency
- Prettier: Code formatting (applied before commits)
- Manual Testing: Use development mode with logging
- Integration Testing: Test with sandbox API
- Browser Testing: Test across different browsers
/user/agents- Get user's agents with full data/user/agents/{id}- Get single agent with system prompts/agents/{id}/chats- Get chat threads/agents/{id}/chats/{thread_id}/messages- Get messages/agents- Create new agents
- Network errors automatically retried
- Authentication errors trigger re-login
- User-friendly error messages shown via toast
- Contact support links shown for persistent errors
For development questions: support@crestal.network