Commit Graph

108 Commits

Author SHA1 Message Date
zenfun
5826db3954 perf(json): replace encoding/json with bytedance/sonic
Migrate all JSON marshaling and unmarshaling operations to use
github.com/bytedance/sonic for improved performance. This affects
adapters, middleware, proxy handlers, and the sync store.
2025-12-10 23:21:51 +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
zenfun
25e5e105b3 feat(auth): enhance security with token hashing and sync integration
- Add token hash fields to Master and Key models for indexed lookups
- Implement SyncService integration in admin and master handlers
- Update master key validation with backward-compatible digest lookup
- Hash child keys in database and store token digests for Redis sync
- Add master metadata sync to Redis for balancer validation
- Ensure backward compatibility with legacy rows during migration
2025-12-05 00:17:22 +08:00
zenfun
8645b22b83 feat(auth): implement master key authentication system with child key issuance
Add admin and master authentication layers with JWT support. Replace direct
key creation with hierarchical master/child key system. Update database
schema to support master accounts with configurable limits and epoch-based
key revocation. Add health check endpoint with system status monitoring.

BREAKING CHANGE: Removed direct POST /keys endpoint in favor of master-based
key issuance through /v1/tokens. Database migration requires dropping old User
table and creating Master table with new relationships.
2025-12-05 00:16:47 +08:00
b8bd613f77 feat(provider): add Models field to ProviderDTO and update provider handling 2025-12-02 16:32:03 +08:00
zenfun
aa57af874c feat(core): implement group-based routing and optimize sync
Replace direct provider linkage with group-based routing for Keys and
Providers. This allows for more flexible load balancing and tiering
strategies.

Changes include:
- Remove `ProviderID` from Key model and DTO
- Add `Group` field to Key and Provider models
- Refactor Redis sync to use Hashes for O(1) partial updates
- Update API handlers to perform incremental syncs

BREAKING CHANGE: Key API payload no longer accepts `provider_id`. Redis
configuration storage format has changed from JSON strings to Hashes.
2025-12-02 14:49:03 +08:00
zenfun
64d71953a6 feat(server): implement management endpoints and redis sync
Enable full resource management via API and support data plane
synchronization.

- Add CRUD handlers for Providers, Models, and Keys using DTOs
- Implement LogWriter service for asynchronous, batched audit logging
- Update SyncService to snapshot full configuration state to Redis
- Register new API routes and initialize background services
- Add configuration options for logging performance tuning
2025-12-02 14:26:16 +08:00
zenfun
58dfe5e9ac feat(server): initialize project skeleton with db and api setup
Establish the foundational structure for the ez-api server.

Key changes include:
- Set up main entry point with graceful shutdown and Gin router
- Configure database connections for PostgreSQL (GORM) and Redis
- Define core data models (User, Provider, Key, Model)
- Implement configuration loading and basic key creation handler
- Add Dockerfile for multi-stage builds and .gitignore
2025-12-02 13:35:17 +08:00