2026-01-28 10:58:15 +08:00
|
|
|
# API CLIENTS KNOWLEDGE BASE
|
|
|
|
|
|
|
|
|
|
**Generated:** 2026-01-28
|
|
|
|
|
**Parent:** EmailBill/AGENTS.md
|
|
|
|
|
|
|
|
|
|
## OVERVIEW
|
2026-02-15 10:10:28 +08:00
|
|
|
|
2026-01-28 10:58:15 +08:00
|
|
|
Axios-based HTTP client modules for backend API integration with request/response interceptors.
|
|
|
|
|
|
|
|
|
|
## STRUCTURE
|
2026-02-15 10:10:28 +08:00
|
|
|
|
2026-01-28 10:58:15 +08:00
|
|
|
```
|
|
|
|
|
Web/src/api/
|
|
|
|
|
├── request.js # Base HTTP client setup
|
|
|
|
|
├── auth.js # Authentication API
|
|
|
|
|
├── budget.js # Budget management API
|
|
|
|
|
├── transactionRecord.js # Transaction CRUD API
|
|
|
|
|
├── transactionCategory.js # Category management
|
|
|
|
|
├── transactionPeriodic.js # Periodic transactions
|
|
|
|
|
├── statistics.js # Analytics API
|
|
|
|
|
├── message.js # Message API
|
|
|
|
|
├── notification.js # Push notifications
|
|
|
|
|
├── emailRecord.js # Email records
|
|
|
|
|
├── config.js # Configuration API
|
|
|
|
|
├── billImport.js # Bill import
|
|
|
|
|
├── log.js # Application logs
|
|
|
|
|
└── job.js # Background job management
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## WHERE TO LOOK
|
2026-02-15 10:10:28 +08:00
|
|
|
|
|
|
|
|
| Task | Location | Notes |
|
|
|
|
|
| --------------- | ---------------------- | ---------------------------------- |
|
|
|
|
|
| Base HTTP setup | request.js | Axios interceptors, error handling |
|
|
|
|
|
| Authentication | auth.js | Login, token management |
|
|
|
|
|
| Budget data | budget.js | Budget CRUD, statistics |
|
|
|
|
|
| Transactions | transactionRecord.js | Transaction operations |
|
|
|
|
|
| Categories | transactionCategory.js | Category management |
|
|
|
|
|
| Statistics | statistics.js | Analytics, reports |
|
|
|
|
|
| Notifications | notification.js | Push subscription handling |
|
2026-01-28 10:58:15 +08:00
|
|
|
|
|
|
|
|
## CONVENTIONS
|
2026-02-15 10:10:28 +08:00
|
|
|
|
2026-01-28 10:58:15 +08:00
|
|
|
- All functions return Promises with async/await
|
|
|
|
|
- Error handling via try/catch with user messages
|
|
|
|
|
- HTTP methods: get, post, put, delete mapping to REST
|
|
|
|
|
- Request/response data transformation
|
|
|
|
|
- Token-based authentication via headers
|
|
|
|
|
- Consistent error message format
|
|
|
|
|
|
|
|
|
|
## ANTI-PATTERNS (THIS LAYER)
|
2026-02-15 10:10:28 +08:00
|
|
|
|
2026-01-28 10:58:15 +08:00
|
|
|
- Never fetch directly without going through these modules
|
|
|
|
|
- Don't hardcode API endpoints (use environment variables)
|
|
|
|
|
- Avoid synchronous operations
|
|
|
|
|
- Don't duplicate request logic across components
|
|
|
|
|
- No business logic in API clients
|
|
|
|
|
|
|
|
|
|
## UNIQUE STYLES
|
2026-02-15 10:10:28 +08:00
|
|
|
|
2026-01-28 10:58:15 +08:00
|
|
|
- Chinese error messages for user feedback
|
|
|
|
|
- Automatic token refresh handling
|
|
|
|
|
- Request/response logging for debugging
|
|
|
|
|
- Paged query patterns for list endpoints
|
2026-02-15 10:10:28 +08:00
|
|
|
- File upload handling for imports
|