Commit Graph

38 Commits

Author SHA1 Message Date
zenfun
f52c7acbe6 docs(swagger): document admin master child key endpoints 2026-01-10 01:19:53 +08:00
zenfun
5349c9c833 feat(api): add admin master key listing/revoke
Add admin endpoints to list and revoke child keys under a master.
Standardize OpenAPI responses to use ResponseEnvelope with MapData
for error payloads, and regenerate swagger specs accordingly.
2026-01-10 01:10:36 +08:00
zenfun
f400ffde95 refactor(api): update traffic chart response structure
Change the traffic chart API response from bucket-based to series-based
to better support frontend visualization libraries. The new format
provides a shared X-axis and aligned data arrays for each model series.

- Replace `buckets` with `x` and `series` in response
- Implement data alignment and zero-filling for time slots
- Update Swagger documentation including pending definitions

BREAKING CHANGE: The `GET /admin/logs/stats/traffic-chart` response
schema has changed. `buckets` and `models` fields are removed.
2026-01-08 18:40:44 +08:00
zenfun
8a52d58674 docs(admin): add dashboard feature design and mockup assets
Organize admin panel feature documentation into a dedicated directory
and include an interactive HTML mockup along with a reference
screenshot for the EZ-API Control Plane Dashboard.
2026-01-03 17:11:02 +08:00
zenfun
295faa8e01 docs(admin): update dashboard feature specification
- Add detailed interaction tables for system status, metrics, and charts
- Update API field mappings to match backend implementation
- Clarify error handling, loading states, and edge cases
2026-01-02 23:39:18 +08:00
zenfun
47991bd5f3 docs(api): update swagger documentation for traffic charts and trends
Regenerate API documentation to reflect recent statistics features:
- Add definition for new `/admin/logs/stats/traffic-chart` endpoint
- Update dashboard summary with `include_trends` parameter and new time periods
- Add `DashboardTrends` and `TrafficChartResponse` data structures
- Update alert types to include `traffic_spike
2026-01-02 23:22:36 +08:00
zenfun
5c01497ce0 fix(api): handle zero-baseline edge cases in trend calculation
Introduce `CalculateTrendFloatWithBaseline` to correctly handle scenarios where previous period metrics (Error Rate, Latency) are zero or missing. This prevents arithmetic errors and distinguishes between "new" data and actual increases ("up") when starting from zero.

Also updates the admin panel dashboard documentation to reflect current project status.
2026-01-02 23:17:55 +08:00
zenfun
08a8a1e42f feat(api): add trend analysis and extended periods to dashboard summary
- Add `include_trends` query parameter to enable trend calculation
- Implement trend comparison logic (delta % and direction) against previous periods
- Add support for `last7d`, `last30d`, and `all` time period options
- Update `DashboardSummaryResponse` to include optional `trends` field
- Add helper functions for custom time window aggregation
- Add unit tests for trend calculation and period window logic
- Update feature documentation with new parameters and response schemas
2026-01-02 22:30:38 +08:00
zenfun
7b20c35fba docs(admin): clarify dashboard key metrics and limitations
Update dashboard summary specification to distinguish between provider
keys (upstream) and internal keys. Change summary metrics to use
`provider_keys` fields for better clarity.

Add section on known limitations regarding time period logic and
missing trend data.
2026-01-02 22:07:18 +08:00
zenfun
0ba94026d4 docs(admin): update dashboard alert severity color mapping
Update the UI specification to distinguish warning severity with orange
color instead of grouping it with critical (red). Also remove redundant
project overview table.
2026-01-02 21:53:50 +08:00
zenfun
e5624c62f1 docs(admin): update dashboard integration specs
Restructure documentation into tables for improved readability and
include detailed specifications for the new traffic chart endpoint.
Define explicit data refresh strategies, error handling guidelines, and
response structures for admin panel components.
2026-01-02 21:45:46 +08:00
zenfun
b1fe1ecb97 docs(admin): add dashboard integration documentation
Add detailed specification for the EZ-API Control Plane Dashboard
frontend-backend integration. This document defines the data mapping,
API endpoints, and UI logic for global navigation, real-time metrics,
traffic analysis, and alert summaries.
2026-01-02 21:40:55 +08:00
zenfun
9d082ff375 feat(api): add admin traffic chart statistics endpoint
Add new endpoint GET /admin/logs/stats/traffic-chart to provide
aggregated traffic metrics grouped by time and model. Features include:
- Time granularity selection (hour/minute)
- Top-N model breakdown with "other" aggregation
- Metrics for request counts and token usage

Includes generated Swagger documentation.
2026-01-02 21:24:56 +08:00
zenfun
4bcd2b4167 docs(swagger): add generated swagger API documentation
Add auto-generated Swagger/OpenAPI documentation files for the
EZ-API Control Plane. These files are generated by swaggo/swag
and provide comprehensive API documentation including:

- All admin endpoints (alerts, API keys, bindings, masters, etc.)
- Master/tenant endpoints for token management and stats
- Internal endpoints for DP-CP communication
- Authentication schemes (AdminAuth, MasterAuth)
- Request/response schema definitions
2025-12-31 18:01:56 +08:00
zenfun
0b9556ee7e docs(api): add alert thresholds endpoints to swagger documentation
Add OpenAPI documentation for the new alert threshold management
endpoints used in traffic spike detection:

- GET /admin/alerts/thresholds - retrieve current threshold config
- PUT /admin/alerts/thresholds - update threshold configuration

Include AlertThresholdView and UpdateAlertThresholdsRequest schema
definitions with properties for QPS, RPM, TPM, RPD, TPD limits.
2025-12-31 15:57:27 +08:00
zenfun
ba54abd424 feat(alerts): add traffic spike detection with configurable thresholds
Introduce traffic_spike alert type for monitoring system and per-master
traffic levels with configurable thresholds stored in database.

- Add AlertThresholdConfig model for persistent threshold configuration
- Implement GET/PUT /admin/alerts/thresholds endpoints for threshold management
- Add traffic spike detection in alert detector cron job:
  - Global QPS monitoring across all masters
  - Per-master RPM/TPM checks with minimum sample thresholds
  - Per-master RPD/TPD checks for daily limits
- Use warning severity at threshold, critical at 2x threshold
- Include metric metadata (value, threshold, window) in alert details
- Update API documentation with new endpoints and alert type
2025-12-31 15:56:17 +08:00
zenfun
85d91cdd2e feat(cron): add automatic alert detector for anomaly monitoring
Implement AlertDetector background task that runs every minute to detect
and create alerts for various anomalies:

- Rate limit detection: monitors masters hitting rate limits
- Error spike detection: flags keys with >= 10% error rate
- Quota exceeded: warns when key quota usage >= 90%
- Provider down: alerts when API keys have >= 50% failure rate

Includes fingerprint-based deduplication with 5-minute cooldown to
prevent duplicate alerts for the same issue.
2025-12-31 14:49:51 +08:00
zenfun
6cab7e257a docs(admin): update dashboard and operations API references
- Add dashboard alerts, realtime, and apikey-stats endpoints
- Document time range parameters for logs and apikey-stats
- Update daily operations workflow with new monitoring endpoints
- Clarify period parameter behavior (default returns all data)
2025-12-31 14:38:07 +08:00
zenfun
dab07caca2 docs(api): add apikey-stats time range and internal alerts report endpoints
Document two new API endpoints:
- GET /admin/apikey-stats/summary with optional since/until params
  for querying statistics within a specific time range
- POST /internal/alerts/report for Data Plane to report alerts
  with fingerprint-based deduplication mechanism
2025-12-31 14:25:55 +08:00
zenfun
57797f38cb docs(api): add alerts report endpoint and apikey-stats query params
- Add internal /internal/alerts/report POST endpoint documentation
- Add reportAlertEntry, reportAlertsRequest, reportAlertsResponse schemas
- Add since/until query parameters to /admin/apikey-stats/summary endpoint
2025-12-31 14:18:42 +08:00
zenfun
71f7578c7b docs(api): add dashboard statistics and alert management API documentation
Add comprehensive API documentation for new admin endpoints:

- Dashboard summary endpoint with period/time range parameters
- System-level realtime statistics (QPS, RPM, rate limits)
- Log stats aggregation by hour/minute with time constraints
- API key status filtering (active/suspended/disabled)
- Complete alert management system documentation:
  - Alert types, severity levels, and status definitions
  - CRUD endpoints for alert lifecycle management
  - Alert statistics endpoint
2025-12-31 13:48:30 +08:00
zenfun
170d16894f docs: update swagger docs for alerts API and minute-level stats
Add OpenAPI documentation for the new alerts management system:
- CRUD endpoints for system alerts (/admin/alerts)
- Alert acknowledgment and resolution endpoints
- Alert statistics endpoint
- Alert filtering by status, severity, and type

Also document minute-level aggregation support for log stats
with 6-hour time range limitation.
2025-12-31 13:45:18 +08:00
zenfun
53c18c3867 feat(api): add dashboard summary and system realtime endpoints
Add new admin API endpoints for dashboard metrics and system-wide
realtime statistics:

- Add /admin/dashboard/summary endpoint with aggregated metrics
  including requests, tokens, latency, masters, keys, and provider
  keys statistics with time period filtering
- Add /admin/realtime endpoint for system-level realtime stats
  aggregated across all masters
- Add status filter parameter to ListAPIKeys endpoint
- Add hour grouping option to log stats aggregation
- Update OpenAPI documentation with new endpoints and schemas
2025-12-31 13:17:23 +08:00
zenfun
cca0802620 docs(swagger): update dp_claude_cross_upstream description to include Google-family providers
Clarify that the dp_claude_cross_upstream feature flag controls routing
of Claude protocol requests to both OpenAI-compatible and Google-family
upstream providers.
2025-12-27 20:06:50 +08:00
zenfun
637bfa8210 feat(api): add public status endpoints with version injection
Replace health_handler with status_handler providing public /status and
/about endpoints. Add build-time version injection via ldflags in
Makefile, and support --version/-v CLI flag.

- Add /status endpoint returning runtime status, uptime, and version
- Add /about endpoint with system metadata (name, description, repo)
- Configure VERSION variable with git describe fallback
- Update swagger docs and api.md for new public endpoints
- Remove deprecated /api/status/test endpoint
2025-12-27 13:24:13 +08:00
zenfun
c83fe03892 docs(swagger): update API documentation for log endpoints
Add new response types and parameters for logs API:
- Add GroupedStatsItem and GroupedStatsResponse definitions
- Add ListLogsResponse and LogView definitions for detailed log records
- Add group_by enum parameter (model/day/month) to stats endpoint
- Update endpoint descriptions to clarify response types and request_body inclusion
- Update response schema references to use correct types
2025-12-26 11:12:47 +08:00
30f15a84b5 feat(api): add /auth/whoami endpoint and build automation 2025-12-25 14:54:52 +08:00
b566eb8058 fix(swagger): restore apikey security definition with Bearer usage description 2025-12-25 11:32:55 +08:00
c8fced4cf1 fix(swagger): fix swagger authorization header 2025-12-25 11:26:56 +08:00
zenfun
44a82fa252 delete: remove png 2025-12-24 17:01:56 +08:00
zenfun
72d7920534 doc: add admin panel map 2025-12-24 15:12:06 +08:00
zenfun
38d2329991 doc: 增加 .env 的注释 2025-12-24 14:51:57 +08:00
zenfun
d731e42ae5 docs: update swagger specs for provider-groups and api-keys refactor
Regenerate OpenAPI documentation to reflect the architectural split
of Provider into ProviderGroup and APIKey models:

- Replace /admin/providers endpoints with /admin/provider-groups
- Add new /admin/api-keys CRUD and batch endpoints
- Update BindingDTO to use group_id instead of route_group
- Remove provider-specific DTOs (ProviderCustomCreateDTO, ProviderPresetCreateDTO, ProviderGoogleCreateDTO)
- Add APIKeyDTO and ProviderGroupDTO definitions
- Update model definitions for APIKey, Binding, and ProviderGroup
2025-12-24 02:20:32 +08:00
zenfun
ee6c28afc9 docs(api): update and expand business documentation
Rewrite docs/api.md to provide a more structured overview of business
logic, core models, and authentication mechanisms. Include detailed
cURL examples for typical operations and add a new management
relationship diagram asset.

- Significant rewrite of docs/api.md with better formatting and content
- Add mermaid diagram for resource relationships
- Update README.md to reference the expanded documentation
- Add docs/管理关系图.png asset
2025-12-22 14:45:18 +08:00
zenfun
d8682acfe5 add doc 2025-12-22 14:34:22 +08:00
zenfun
de1d23cce5 docs: regenerate swagger docs with new API endpoints
Add comprehensive API documentation for new endpoints including:
- Bindings CRUD and batch operations
- Namespaces management
- Master tenant CRUD, access settings, and realtime stats
- Provider CRUD with preset/custom/google variants
- Model registry status, refresh, check, and rollback
- Log management with stats and webhook config
- Key access settings endpoints
- Internal stats flush endpoint
- Health check endpoint

Also adds swagger annotations for FlushStats internal handler.
2025-12-22 13:03:52 +08:00
zenfun
ca03ac1b79 docs(api): update swagger documentation for admin endpoints
Reflect recent API changes in Swagger documentation:
- Add endpoints for feature flag management (/admin/features)
- Add endpoint for issuing child keys to masters (/admin/masters/{id}/keys)
- Add endpoint for updating providers (/admin/providers/{id})
- Update provider model definitions with new fields (auto_ban, google_* attributes, status)
2025-12-15 16:12:56 +08:00
770a9fef2b feat: Add Swagger documentation for admin and master API endpoints
- Added Swagger documentation for the following admin endpoints:
  - Create a new master tenant
  - Create a new provider
  - Register a new model
  - List all models
  - Update a model
  - Force sync snapshot
  - Ingest logs

- Added Swagger documentation for the master endpoint:
  - Issue a child key

- Updated go.mod and go.sum to include necessary dependencies for Swagger.
2025-12-05 15:01:35 +08:00