# Server Architecture CoreLicense License Server architecture — Go API, Admin Console, data model, policy tokens, and operational design. Canonical HTML URL: https://corelicense.net/docs/server-architecture Plain-text URL: https://corelicense.net/docs/server-architecture.txt ---# CoreLicense Server Architecture > Public overview for developers integrating with CoreLicense — system components, technology stack, and domain model. Database DDL, admin-console APIs, deployment configuration, and other operator-only details are **not** published here. ## 1. System Overview CoreLicense Server is the central hub for managing: - Product - Customer / Client - Application - License - Instance - Policy - Feature flags - Limits / Quotas - License checking history - Activation history - Revocation / suspension - Admin users - Audit logs Client applications use the Node.js SDK to call the server in order to: - Register / activate an app instance - Check license status - Refresh the policy token - Obtain a signed token - Report minimum SDK version - Receive a new policy when available The server does not collect business data from client applications. --- ## 2. High-Level Architecture ```txt ┌──────────────────────────────────────┐ │ Client Application │ │ Node.js App + CoreLicense SDK │ └───────────────────┬──────────────────┘ │ │ HTTPS ▼ ┌──────────────────────────────────────┐ │ CoreLicense API │ │ Backend: Go │ │ - Activate │ │ - Check │ │ - Refresh Token │ │ - Policy Signing │ │ - Check History │ └───────────────────┬──────────────────┘ │ ▼ ┌──────────────────────────────────────┐ │ Database / Cache / Queue │ │ PostgreSQL + Redis │ └───────────────────┬──────────────────┘ │ ▼ ┌──────────────────────────────────────┐ │ Admin Frontend │ │ Next.js │ │ - Product management │ │ - License management │ │ - Client app management │ │ - Check history │ │ - Policy editor │ │ - Audit log │ └──────────────────────────────────────┘ ``` --- ## 3. Recommended Technology Stack Backend: ```txt Language: Go HTTP framework: Gin / Chi / Fiber Database: PostgreSQL Cache: Redis ORM/Query: sqlc or GORM Migration: Goose / Atlas / golang-migrate Auth: JWT session or secure cookie session Crypto: Ed25519 signing Logging: Zap / Zerolog Config: Viper / envconfig Queue optional: Asynq or NATS ``` Frontend: ```txt Framework: Next.js Language: TypeScript UI: Tailwind CSS + shadcn/ui Data fetching: TanStack Query or Server Actions Auth: NextAuth or custom session Charts: Recharts Forms: React Hook Form + Zod Table: TanStack Table ``` Infra: ```txt Reverse proxy: Nginx / Caddy TLS: Cloudflare / Let's Encrypt Deploy: Docker Compose Monitoring: Prometheus / Grafana optional Logs: Loki optional ``` --- ## 4. Main Components ```txt corelicense-server/ cmd/ api/ main.go internal/ config/ database/ redis/ http/ middleware/ auth/ crypto/ license/ product/ client/ instance/ policy/ checklog/ audit/ admin/ errors/ migrations/ docs/ docker-compose.yml ``` ```txt corelicense-admin/ app/ dashboard/ products/ licenses/ clients/ instances/ checks/ policies/ audit/ settings/ components/ lib/ hooks/ services/ types/ ``` --- ## 5. Domain Model ### 5.1. Product A Product is your software product. Examples: - MediaHub - CorpMaster - VPS Manager - Browser App - Automation Toolkit Fields: ```txt id name slug description public_key_id status created_at updated_at ``` Status: ```txt active deprecated disabled ``` --- ### 5.2. Customer / Client A Customer is the person or organization granted a license. Fields: ```txt id name email company phone telegram note status created_at updated_at ``` Status: ```txt active blocked watchlist ``` --- ### 5.3. Application An Application is a specific app that a client registers under a product. Examples: ```txt Product: MediaHub Application: mediahub-production-client-a ``` Fields: ```txt id product_id customer_id name environment domain description status created_at updated_at ``` Environment: ```txt production staging development test ``` --- ### 5.4. License A License is a usage entitlement. Fields: ```txt id product_id customer_id application_id license_key_hash license_key_prefix plan status starts_at expires_at max_instances features_json limits_json policy_version created_at updated_at revoked_at suspended_at reason ``` Do not store the plain license key. Store only the hash. Status: ```txt active limited suspended revoked expired pending ``` --- ### 5.5. Instance An Instance is a single deployment environment of the application. Fields: ```txt id license_id product_id application_id instance_id domain_hash sdk_name sdk_version runtime runtime_version app_version status first_seen_at last_seen_at last_check_at check_count created_at updated_at ``` Status: ```txt active blocked replaced suspicious ``` --- ### 5.6. Policy A Policy defines features, limits, and the status response for a license. Fields: ```txt id product_id license_id nullable version name features_json limits_json rules_json status created_at updated_at created_by ``` Status: ```txt draft active archived ``` --- ### 5.7. CheckLog Client check history. Fields: ```txt id request_id product_id license_id application_id instance_id status_returned reason sdk_name sdk_version runtime runtime_version app_version ip_hash user_agent_hash created_at ``` Do not store raw IP addresses in a privacy-first design. You may store a hash plus country if needed. --- ### 5.8. AuditLog Admin action log. Fields: ```txt id actor_id action resource_type resource_id before_json after_json ip_hash user_agent_hash created_at ``` --- ### 5.9. AdminUser Fields: ```txt id name email password_hash role status mfa_enabled last_login_at created_at updated_at ``` Roles: ```txt owner admin support viewer auditor ``` --- --- ## Related documentation - [Client API Reference](/docs/client-api) — activate, check, refresh, and status endpoints - [Node.js SDK Quick Start](/docs/nodejs-sdk/quick-start) — install and configure the SDK - [Deep Integration](/docs/nodejs-sdk/deep-integration) — feature gates, quotas, and policy enforcement For license terms and acceptable use, see [Policy](/policy).