How wei-shaw/sub2api works
Sub2API is an AI API gateway platform for distributing subscription quota. The principal workflow is a client sending a compatible model request, the gateway routing it to an upstream AI account, and the platform recording usage against quota. Separate product areas handle account authentication, administration, payments, monitoring, and image workloads. The graph also shows the frontend and persistence layers. Backend wiring and most handlers were not sampled, so inferred runtime links are dashed and have no evidence path.
Main entry points: client.ts HTTP API client · client.go Application data · openai_gateway_cc_pipeline.go Gateway processing · App.vue Web application
Components 19
Client application
- Web application
frontend/src/App.vue - HTTP API client
frontend/src/api/client.ts
AI gateway
- Backend server
backend/cmd/server/main.go - Gateway endpoints
backend/internal/handler/gateway_handler.go - OpenAI-compatible API
backend/internal/handler/openai_gateway_handler.go - Gateway processing
backend/internal/service/openai_gateway_cc_pipeline.go
Accounts and access
- Authentication
backend/internal/handler/auth_handler.go - Admin management
backend/internal/handler/admin/account_handler.go - Subscriptions
backend/internal/handler/subscription_handler.go - Payment processing
backend/internal/handler/payment_handler.go
Platform operations
- Channel monitoring
backend/internal/handler/channel_monitor_v2_handler.go - Batch image jobs
backend/internal/handler/batch_image_handler.go - Image storage
backend/internal/service/image_storage.go - Management MCP
backend/internal/managementmcp/server.go
Persistence
- Application data
backend/ent/client.go
Other components
- API client
- AI providers
- Payment providers
- S3-compatible storage
Connections 20
- API client → Web application: uses console
- Web application → HTTP API client: requests data
- HTTP API client → Backend server: calls API
- Backend server → Gateway endpoints: serves gateway
- Gateway endpoints → OpenAI-compatible API: dispatches requests
- OpenAI-compatible API → Gateway processing: processes requests
- Gateway processing → AI providers: routes model calls
- Gateway processing → Application data: records usage
- HTTP API client → Authentication: calls auth API
- HTTP API client → Admin management: calls admin API
- HTTP API client → Subscriptions: calls subscription API
- HTTP API client → Payment processing: calls payment API
- Payment processing → Payment providers: initiates payments
- HTTP API client → Channel monitoring: calls monitoring API
- HTTP API client → Batch image jobs: calls image API
- Batch image jobs → Image storage: stores images
- Image storage → S3-compatible storage: uploads objects
- Management MCP → Application data: manages platform data
- Authentication → Application data: persists identity
- Admin management → Application data: manages records