Skip to content

AIDotNet/ClaudeCodeProxy

Repository files navigation

ClaudeCodeProxy

ClaudeCodeProxy Logo

πŸš€ Enterprise-Grade AI API Proxy Management Platform

.NET React TypeScript License PRs Welcome

A sophisticated, production-ready proxy management system for AI APIs with comprehensive monitoring, analytics, and multi-platform integration.

πŸš€ Getting Started β€’ πŸ“– Documentation β€’ 🌟 Features β€’ πŸ› οΈ API Reference


πŸ“‹ Table of Contents


✨ Features

🎯 Core Capabilities

πŸ”‘ API Key Management

  • Multi-platform API key lifecycle management
  • Granular permissions & access controls
  • Rate limiting & token quotas
  • Automatic expiration handling
  • Encryption at rest & in transit

🏒 Account Integration

  • OAuth flow management
  • Multi-service authentication
  • Intelligent load balancing
  • Automatic failover & health checks
  • Priority-based routing

πŸ“Š Advanced Analytics

  • Real-time usage monitoring
  • Cost tracking & attribution
  • Performance metrics (RPM/TPM)
  • Predictive capacity planning
  • Custom reporting dashboards

πŸ›‘οΈ Enterprise Security

  • JWT-based authentication
  • IP restriction controls
  • Comprehensive audit logging
  • Role-based access control
  • Secure credential storage

🎨 Management Interface

  • Professional Dashboard - Real-time metrics, system health, and KPI monitoring
  • Advanced Statistics - Multi-dimensional analytics with interactive visualizations
  • Request Logging - Comprehensive audit trails with filtering and search capabilities
  • Cost Analysis - Financial tracking with detailed flow analysis and forecasting
  • User Management - Secure authentication with role-based permissions

πŸ—οΈ Architecture

graph TB
    subgraph "Frontend (React 19)"
        A[Admin Dashboard] --> B[API Key Manager]
        A --> C[Analytics Dashboard]
        A --> D[Account Manager]
        A --> E[Request Logger]
    end
    
    subgraph "Backend (.NET 9 API)"
        F[Authentication Service] --> G[Proxy Engine]
        G --> H[Rate Limiter]
        H --> I[Cost Calculator]
        I --> J[Request Logger]
    end
    
    subgraph "AI Platforms"
        K[Claude/Anthropic]
        L[OpenAI]
        M[Google Gemini]
    end
    
    subgraph "Data Layer"
        N[SQLite Database]
        O[Memory Cache]
    end
    
    A --> F
    G --> K
    G --> L
    G --> M
    J --> N
    I --> O
Loading

πŸ› οΈ Tech Stack

Component Technology Version
Backend .NET Core 9.0
Frontend React + TypeScript 19.x + 5.6
Database SQLite + EF Core Latest
UI Framework Tailwind CSS + Shadcn/ui 3.x
Build Tool Vite 6.x
Authentication JWT -

πŸš€ Getting Started

πŸ“‹ Prerequisites

⚑ Quick Start

  1. Clone the repository

    git clone https://github.com/AIDotNet/ClaudeCodeProxy.git
    cd ClaudeCodeProxy
  2. Start the backend

    cd src/ClaudeCodeProxy.Host
    dotnet restore
    dotnet run
  3. Start the frontend

    cd web
    npm install
    npm run dev
  4. Access the application


πŸ› οΈ Installation

🐳 Docker Deployment

# Build and run with Docker Compose
docker-compose up -d

πŸ–₯️ Manual Deployment

  1. Backend Setup

    cd src/ClaudeCodeProxy.Host
    dotnet publish -c Release -o ./publish
    cd publish
    dotnet ClaudeCodeProxy.Host.dll
  2. Frontend Build

    cd web
    npm run build
    # Serve the dist folder with your preferred web server

βš™οΈ Configuration

πŸ”§ Environment Variables

Create appsettings.json in the Host project:

{
  "ThorPlatformOptions": {
    "DatabaseConnectionString": "Data Source=claudecodeproxy.db",
    "JwtSettings": {
      "SecretKey": "your-secret-key-here",
      "Issuer": "ClaudeCodeProxy",
      "Audience": "ClaudeCodeProxy-Users",
      "ExpirationHours": 24
    }
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  }
}

πŸŽ›οΈ Frontend Configuration

Update web/src/config/api.ts:

export const API_CONFIG = {
  baseURL: process.env.VITE_API_URL || 'http://localhost:5000',
  timeout: 30000,
  retries: 3
};

πŸ“Š Dashboard

🎯 Real-time Metrics

Dashboard Overview

Key Features:

  • Live system performance indicators
  • Cost tracking with trend analysis
  • Token usage analytics (input/output/cache)
  • API key status monitoring
  • System uptime and health metrics

πŸ“ˆ Advanced Analytics

  • Usage Heat Maps - Visual representation of API usage patterns
  • Cost Flow Analysis - Detailed financial attribution and forecasting
  • Performance Trends - Historical data with predictive insights
  • User Profiling - Behavioral analysis and usage optimization

πŸ”§ API Reference

πŸ” Authentication

All API endpoints require JWT authentication:

# Login to get JWT token
curl -X POST "http://localhost:5000/api/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"password"}'

# Use token in subsequent requests
curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  "http://localhost:5000/api/apikeys"

πŸ“ Core Endpoints

Method Endpoint Description
GET /api/apikeys List all API keys
POST /api/apikeys Create new API key
PUT /api/apikeys/{id} Update API key
DELETE /api/apikeys/{id} Delete API key
GET /api/accounts List service accounts
GET /api/dashboard Dashboard statistics
GET /api/logs Request logs

πŸ”„ Proxy Endpoints

# Claude API Proxy
curl -X POST "http://localhost:5000/v1/messages" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-3-sonnet","messages":[...]}'

# OpenAI API Proxy  
curl -X POST "http://localhost:5000/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4","messages":[...]}'

🌐 Multi-Platform Support

πŸ€– Supported AI Platforms

Claude
Claude
OAuth Integration
OpenAI
OpenAI
Full API Support
Gemini
Gemini
Project-based Auth

⚑ Platform Features

  • Intelligent Routing - Automatic platform selection based on request parameters
  • Model Mapping - Cross-platform model compatibility management
  • Cost Calculation - Platform-specific pricing models and usage tracking
  • Error Handling - Platform-specific error codes and retry logic

πŸ“ˆ Monitoring & Analytics

πŸ“Š Metrics Collection

  • Request/Response Tracking - Complete API transaction logging
  • Token Usage Monitoring - Detailed input/output token calculation
  • Cost Attribution - Real-time cost calculation and allocation
  • Performance Metrics - Response time, throughput, and error rates

🚨 Alerting & Notifications

  • Real-time status updates and system health monitoring
  • Usage threshold alerts with automatic notifications
  • Error tracking with immediate notification of system issues
  • Capacity planning with proactive scaling recommendations

πŸ”’ Security

πŸ›‘οΈ Security Features

  • πŸ” JWT Authentication - Secure token-based authentication with configurable expiration
  • πŸ”’ Encrypted Storage - API keys encrypted at rest and in transit
  • 🚦 Rate Limiting - Comprehensive throttling to prevent abuse
  • 🌐 IP Restrictions - Client IP whitelisting for enhanced access control
  • πŸ“‹ Audit Logging - Complete audit trails for compliance and security monitoring

πŸ”§ Security Best Practices

{
  "SecurityRecommendations": {
    "JwtSecretKey": "Use a strong, randomly generated secret key (256+ bits)",
    "DatabaseEncryption": "Enable SQLite encryption in production environments",
    "TLS": "Always use HTTPS in production deployments",
    "RateLimiting": "Configure appropriate rate limits based on your usage patterns",
    "Monitoring": "Enable comprehensive logging and monitoring for security events"
  }
}

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

πŸš€ Development Setup

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ Code Style


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments


⭐ Star this repo if you find it helpful!

πŸ› Report Bug β€’ ✨ Request Feature β€’ πŸ’¬ Discussions


🌍 Documentation

πŸ“š English | δΈ­ζ–‡ζ–‡ζ‘£

⭐ Star this repo if you find it helpful!

πŸ› Report Bug β€’ ✨ Request Feature β€’ πŸ’¬ Discussions

Made with ❀️ by the ClaudeCodeProxy Team