# Control Panel Documentation

## Overview

The Token Aggregation Service includes a web-based control panel for managing API keys, endpoints, and DEX factory configurations.

## Access

- **URL**: `http://<container-ip>` (after Proxmox deployment)
- **Default Port**: 80 (nginx serves frontend, proxies API to port 3000)

## Features

### 1. Dashboard
- Service status overview
- Statistics for API keys, endpoints, and DEX factories
- Real-time updates

### 2. API Keys Management
- Add new API keys for:
  - CoinGecko
  - CoinMarketCap
  - DexScreener
  - Custom providers
- View active/inactive keys
- Set rate limits
- Set expiration dates
- Enable/disable keys

### 3. Endpoints Management
- Add RPC endpoints for ChainID 138 and 651940
- Add explorer endpoints
- Add indexer endpoints
- Set primary endpoints
- Health check status
- Enable/disable endpoints

### 4. DEX Factories Management
- Add UniswapV2 factory addresses
- Add UniswapV3 factory addresses
- Add DODO PoolManager addresses
- Configure router addresses
- Set start blocks
- Add descriptions

## Authentication

### Creating Admin User

Use the provided script:

```bash
cd smom-dbis-138/services/token-aggregation
./scripts/create-admin-user.sh
```

Or via API:

```bash
curl -X POST http://localhost:3000/api/v1/admin/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"your-password"}'
```

### Roles

- **super_admin**: Full access, can manage users
- **admin**: Can manage API keys, endpoints, factories
- **operator**: Can view and enable/disable items
- **viewer**: Read-only access

## API Endpoints

All admin endpoints are under `/api/v1/admin/`:

- `POST /api/v1/admin/auth/login` - Login
- `GET /api/v1/admin/api-keys` - List API keys
- `POST /api/v1/admin/api-keys` - Create API key
- `PUT /api/v1/admin/api-keys/:id` - Update API key
- `DELETE /api/v1/admin/api-keys/:id` - Delete API key
- `GET /api/v1/admin/endpoints` - List endpoints
- `POST /api/v1/admin/endpoints` - Create endpoint
- `PUT /api/v1/admin/endpoints/:id` - Update endpoint
- `GET /api/v1/admin/dex-factories` - List DEX factories
- `POST /api/v1/admin/dex-factories` - Create DEX factory
- `GET /api/v1/admin/status` - Service status
- `GET /api/v1/admin/audit-log` - Audit log

## Deployment

The control panel is automatically deployed with the service to Proxmox. See `scripts/deploy-to-proxmox.sh` for details.
