Files
OCR/openspec/changes/simplify-frontend-add-billing/specs/backend-api/spec.md
egg 65abd51d60 feat: add translation billing stats and remove Export/Settings pages
- Add TranslationLog model to track translation API usage per task
- Integrate Dify API actual price (total_price) into translation stats
- Display translation statistics in admin dashboard with per-task costs
- Remove unused Export and Settings pages to simplify frontend
- Add GET /api/v2/admin/translation-stats endpoint

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 17:38:12 +08:00

23 lines
900 B
Markdown

# Spec Delta: backend-api
## ADDED Requirements
### Requirement: Translation Statistics Endpoint
The system SHALL provide a new admin API endpoint for translation usage statistics across all users.
#### Scenario: Admin requests translation statistics
- GIVEN the admin is authenticated
- WHEN GET /api/v2/admin/translation-stats is called
- THEN the response contains:
- total_translations: number of translation jobs
- total_input_tokens: sum of input tokens used
- total_output_tokens: sum of output tokens used
- estimated_cost: calculated cost based on token pricing
- by_language: breakdown of translations by target language
- recent_translations: list of recent translation activities
#### Scenario: Non-admin user requests translation statistics
- GIVEN a regular user is authenticated
- WHEN GET /api/v2/admin/translation-stats is called
- THEN the response is 403 Forbidden