A modern React-based dashboard for tracking, analyzing, and optimizing AI API costs across multiple providers.
- Cost Katana Frontend
- 🎨 Modern UI/UX: Built with React 18, TypeScript, and Tailwind CSS
- 📊 Real-time Analytics: Interactive charts and visualizations with Chart.js
- 🌓 Dark Mode: Full dark mode support with system preference detection
- 📱 Responsive Design: Works seamlessly on desktop and mobile devices
- 🔐 Secure Authentication: JWT-based auth with refresh tokens
- 🚀 Optimized Performance: Code splitting, lazy loading, and caching
- 🎯 Type Safety: Full TypeScript support with strict typing
- 🧪 Testing Ready: Jest and React Testing Library setup
- Real-time cost overview with service breakdown charts
- Recent activity feed and AI-powered insights
- Detailed usage history with advanced filtering and search
- Export functionality (CSV/JSON) and token/cost analysis
- Time-series visualizations and service/model comparisons
- Cost predictions and trend analysis
- AI-powered prompt optimization with cost saving suggestions
- Optimization history and bulk optimization support
- API key management and notification preferences
- Subscription management and alert configuration
- Framework: React 18 with TypeScript
- Build Tool: Vite
- Styling: Tailwind CSS
- State Management: Zustand + React Query
- Routing: React Router v6
- Charts: Chart.js with react-chartjs-2
- Forms: React Hook Form with Zod validation
- UI Components: Headless UI + Heroicons
- HTTP Client: Axios
- Animations: Framer Motion
- Node.js 18+ and npm
- Backend API running (default:
http://localhost:3000)
- Clone the repository:
git clone https://github.com/your-org/costkatana-frontend.git
cd costkatana-frontend- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration- Start the development server:
npm run devThe app will be available at http://localhost:3001
# API Configuration
VITE_API_URL=http://localhost:8000/api
# App Configuration
VITE_APP_NAME=Cost Katana
VITE_APP_VERSION=1.0.0
# Feature Flags
VITE_ENABLE_MOCK_DATA=false
VITE_ENABLE_ANALYTICS=truenpm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production buildnpm run lint # Run ESLint
npm run lint:fix # Fix ESLint errors
npm run format # Format code with Prettier
npm run type-check # Run TypeScript compilernpm run test # Run tests
npm run test:ui # Run tests with UI
npm run test:coverage # Generate coverage reportsrc/
├── components/ # Reusable components
│ ├── auth/ # Authentication components
│ ├── common/ # Common/shared components
│ ├── dashboard/ # Dashboard components
│ ├── usage/ # Usage tracking components
│ ├── analytics/ # Analytics components
│ └── optimization/ # Optimization components
├── contexts/ # React contexts (Auth, Theme, Notifications)
├── hooks/ # Custom React hooks
├── pages/ # Page components
├── services/ # API services
├── types/ # TypeScript type definitions
├── utils/ # Utility functions
└── styles/ # Global styles
React Query - Server state management:
- Automatic caching and background refetching
- Optimistic updates and pagination support
Zustand - Client state:
- UI preferences, temporary form data, filter states
Context API - Global app state:
- Authentication, theme (dark/light mode), notifications
All API calls are centralized in the services/ directory:
import { usageService } from '@/services/usage.service';
// Track usage
const usage = await usageService.trackUsage(data);
// Get usage with filters
const result = await usageService.getUsage(filters, pagination);The app uses Tailwind CSS with custom design tokens:
- Colors: Primary (#3B82F6), Success (#10B981), Warning (#F59E0B), Danger (#EF4444)
- Spacing: Base unit 4px (0.25rem), common values: 4, 8, 12, 16, 20, 24, 32, 48
- Typography: Inter font family, sizes: xs, sm, base, lg, xl, 2xl, 3xl
- Code Splitting: Routes are lazy loaded
- Image Optimization: WebP format with fallbacks
- Bundle Optimization: Vendor chunks for better caching
- React Query: Smart caching and refetching
- Memoization: Heavy computations are memoized
# Run all tests
npm run test
# Run tests in watch mode
npm run test:watch
# Generate coverage report
npm run test:coverage# Build the app
npm run build
# Preview the build
npm run preview
# Analyze bundle size
npm run build -- --analyzeFROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]Vercel/Netlify:
- Connect your GitHub repository
- Set environment variables
- Deploy with default settings
Traditional Hosting:
- Build the app:
npm run build - Upload the
dist/folder to your web server - Configure your server to serve the SPA correctly
- Chrome (last 2 versions)
- Firefox (last 2 versions)
- Safari (last 2 versions)
- Edge (last 2 versions)
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Check if backend is running
- Verify
VITE_API_URLin.env
- Clear
node_modulesand reinstall:rm -rf node_modules && npm install - Check for TypeScript errors:
npm run type-check
- Ensure Tailwind CSS is properly configured
- Check for CSS purging in production builds
For support, email support@costkatana.com or create an issue in the repository.
MIT License - see LICENSE file for details