Skip to main content

Developer Portal (developer-portal-service) — Service Overview

Version: 1.0 Status: Draft Owner: Product + Developer Relations (DevRel) Last Updated: 2026-04-20 Companion: DOMAIN_MODEL · API_CONTRACTS · EVENT_SCHEMAS · AI_INTEGRATION Related ADR: ADR-0004 National-Backbone Resilience §6 (developer ecosystem)


1. Purpose — The Front Door for Developers Building on the National SMS Backbone

The Developer Portal is the canonical, public-facing surface through which every external developer — start-up engineer, bank integrator, government solutions architect, NGO field worker, large-tenant DevOps team — discovers, learns, evaluates, and adopts the Ghasi SMS Gateway. It is conceptually equivalent to the developer surfaces of Twilio, Vonage, MessageBird, Infobip, and Plivo.

Where the customer-portal is the operational tenant console (billing, dashboards, support tickets), the Developer Portal is the technical adoption surface. It owns:

  1. Documentation — versioned API reference (rendered from OpenAPI), conceptual guides, tutorials, migration notes, regulator-compliance primers.
  2. Sandbox environment — a fully-functional, no-cost, non-deliverable replica of the production SMS, Voice, WhatsApp, and Verify pipelines that returns realistic DLRs without touching MNO networks.
  3. Self-serve API key & SDK credentials — developers can generate, rotate, scope, and revoke API keys without filing a ticket; portal calls auth-service and propagates revocations within ≤ 60 s.
  4. Consumption analytics for developers — per-key request volumes, error rates, latency percentiles, and segment counts surfaced as charts and CSV exports, sourced from analytics-service.
  5. Official server-side SDKs — Node, Python, Java, .NET, Go, PHP — with synchronised semver release pipelines.
  6. Mobile SDKs — native Android (Kotlin), iOS (Swift), and Flutter — for OTP capture, in-app messaging, and Verify flows.
  7. Postman / OpenAPI / code-snippet generator — pre-baked Postman collections, downloadable OpenAPI 3.1 specs, and a per-endpoint snippet generator that produces idiomatic copy-paste code in 10+ languages.
  8. Verify API — a managed OTP product equivalent to Twilio Verify, abstracting SMS / Voice / WhatsApp / email channel fallback behind a single POST /v1/verify call.

Every capability is delivered with product-grade UX, regulator-aware copy, and Pashto / Dari / English localisation.


2. Position in the Platform — The Adoption Funnel

┌────────────────────────────────────────────┐
│ External Developer / Tenant Engineer │
└────────────────────┬───────────────────────┘
│ https://developers.ghasi.af

┌──────────────────────────────────────────────────────────┐
│ developer-portal-service │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌────────────────┐ │
│ │ Docs site │ │ Sandbox API │ │ SDK / snippet │ │
│ │ (Next.js) │ │ proxy │ │ generator │ │
│ └──────────────┘ └──────────────┘ └────────────────┘ │
│ ┌──────────────┐ ┌──────────────┐ ┌────────────────┐ │
│ │ Key self- │ │ Consumption │ │ Verify API │ │
│ │ serve UI │ │ analytics │ │ orchestrator │ │
│ └──────────────┘ └──────────────┘ └────────────────┘ │
└──────────────────────────────┬───────────────────────────┘

┌──────────────────────┬──────────────────┼──────────────────┬─────────────────┐
▼ ▼ ▼ ▼ ▼
┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐
│ auth- │ │ sms- │ │ analytics- │ │ billing- │ │ webhook- │
│ service │ │ orchestr. │ │ service │ │ service │ │ dispatcher │
│ (keys/JWT) │ │ (Verify │ │ (per-key │ │ (sandbox │ │ (sandbox │
│ │ │ + send) │ │ metrics) │ │ $0 meter) │ │ DLR push)│
└────────────┘ └────────────┘ └────────────┘ └────────────┘ └────────────┘

The Developer Portal is not on the SMS data plane — it is a control-plane and presentation-plane surface that shapes how the data plane is consumed.


3. Bounded Context

DimensionValue
DomainDeveloper Experience / Product / Adoption
Owner squadProduct + Developer Relations (DevRel)
Deployment unitKubernetes Deploymentdeveloper-portal-service (Next.js + NestJS API), plus a dedicated developer-portal-sandbox namespace
Communication styleInbound: HTTPS (browser, SDK release CI) · Outbound: HTTPS / gRPC to auth-service, sms-orchestrator, analytics-service, billing-service
StoragePostgreSQL schema devportal · Redis cache · S3-compatible object store (SDK release artifacts, OpenAPI bundles)
Failure modeFail-soft — docs are statically rendered and cacheable at edge; sandbox failure surfaces a status banner; production data plane is never affected by portal outage

4. Responsibilities

#Responsibility
R1Render versioned API documentation from the canonical OpenAPI 3.1 spec (/openapi/v1.json) using Redoc as the primary renderer and Swagger UI as the interactive try-it surface
R2Operate a sandbox environment that mimics the production API surface 1:1 but returns simulated DLRs (no MNO traffic, no charges)
R3Allow developers to self-serve API keys scoped per environment (sandbox / production), with revocation propagated to auth-service JWKS / key cache within ≤ 60 s
R4Surface per-key consumption analytics (requests, errors, latency, segments) sourced from analytics-service, exportable to CSV/JSON
R5Publish official server-side SDKs (Node, Python, Java, .NET, Go, PHP) with synchronised semver, tagged releases, and a single source-of-truth release pipeline
R6Publish mobile SDKs (Android, iOS, Flutter) for OTP capture, Verify flows, and in-app messaging
R7Maintain the Postman collection, the canonical OpenAPI bundle, and a per-endpoint code-snippet generator producing copy-paste examples in ≥ 10 languages
R8Operate the Verify API (POST /v1/verify/{channel}) — a managed OTP product orchestrating SMS, Voice, WhatsApp, and email channels behind a single contract
R9Localise documentation copy in English, Pashto, and Dari (UI chrome + curated guides; reference auto-translated only where reviewed)
R10Emit devportal.* events for key creation, sandbox usage, Verify lifecycle, and SDK downloads; consumed by analytics-service and billing-service

5. Non-Responsibilities

  • Does not authenticate end users or own the identity store — delegates to auth-service.
  • Does not dispatch real SMS — sandbox uses an in-process simulator; production traffic flows through sms-orchestrator.
  • Does not own pricing or invoicing — surfaces read-only consumption from analytics-service; billing remains in billing-service.
  • Does not make routing or compliance decisions — those remain in routing-engine / compliance-engine.
  • Does not host the regulator portal — separate regulator-portal-service.

6. Upstream / Downstream Dependencies

DirectionServiceProtocolPurpose
Inbound userBrowser (developer)HTTPSDocs, sandbox, key UI, analytics dashboards
Inbound machineSDK release CI (GitHub Actions)HTTPS (signed webhook)Trigger SDK publish pipelines, OpenAPI artifact upload
Inbound integrationTenant app (production traffic)HTTPSPOST /v1/verify/* Verify API calls
Outboundauth-servicegRPC (mTLS)Create / rotate / revoke API keys; resolve developer accounts
Outboundsms-orchestratorHTTPS / gRPCVerify API send fan-out (channel = SMS)
Outboundchannel-router-servicegRPCVerify API channel fallback (SMS → WhatsApp → Voice)
Outboundanalytics-servicegRPCPer-key consumption metrics, time-series analytics
Outboundbilling-servicegRPCSandbox-vs-production attribution; Verify spend metering
OutboundS3-compatible object storeHTTPSSDK release artifacts, OpenAPI bundles, Postman collections
Outbound eventsNATS JetStreamTCPdevportal.key.*, devportal.verify.*, devportal.sdk.*

7. High-Level Flow — Verify API End-to-End


8. Key Design Decisions

DecisionRationale
Redoc as the primary docs renderer; Swagger UI for interactive try-it; Stoplight Elements evaluated and rejected for v1 (heavier client bundle)Redoc gives the cleanest read-only reference; Swagger UI's "Try it" is industry-standard and developers already know it. Two surfaces > one mediocre compromise.
OpenAPI 3.1 as the single source of truth for every public endpointAll SDKs, Postman, snippet generator, and docs are generated from one spec. No drift possible.
Sandbox is a separate namespace + separate base URL (api-sandbox.ghasi.af)Hard isolation prevents accidental production charges; matches Twilio / Vonage convention developers expect.
Sandbox returns deterministic synthetic DLRs (e.g. +93700000001 always returns DELIVERED, +93700000002 always returns UNDELIV, +93700000003 always times out)Predictable test fixtures enable CI/E2E without flakiness.
API key revocation propagates via NATS event + Redis pub/sub to auth-service JWKS cacheEnsures revocation is effective platform-wide within ≤ 60 s SLO; documented in API_CONTRACTS.md §3
Verify API orchestrates channels but does not own the channel implementationsAvoids re-building SMS/Voice/WhatsApp pipelines; reuses sms-orchestrator, channel-router-service, and channel adapters
Verify codes stored as HMAC-SHA-256(code, server-pepper), never plaintext, with constant-time comparePrevents timing attacks and rainbow-table compromise of OTP store
Verify supports rate limiting (max 5 attempts / 10 minutes per verificationId; max 5 starts / hour per recipient)Mitigates OTP-grinding and brute-force; aligns with fraud-intel-service rules
Snippet generator uses templated AST emitters per language, optionally augmented by AI for natural-language descriptions only (never for credentials or logic)Deterministic snippets are auditable; AI's role is narrow and reviewable
SDK release pipeline uses a monorepo of generators (OpenAPI Generator + per-language post-processors) with required human review on every releaseAvoids "auto-generated SDK feels machine-translated" syndrome — DevRel reviews ergonomics before publish
All docs and portal UI localise to English, Pashto, DariAfghan national platform must speak Afghan languages; reduces adoption friction for local engineers
Status page (status.ghasi.af) is a separate static site fed by analytics-service, linked from portalDecoupling means portal outages don't take the status page down
No code execution of submitted snippets in the browserEliminates an entire XSS / RCE attack surface; "Try it" runs against sandbox via signed proxy only
Static export of docs to a CDN edgeLCP < 1.2 s globally; portal failure does not break docs

9. Runtime Topology

ComponentStackReplicas (prod)Notes
Docs (Next.js SSG + ISR)Next.js 15 / React 193Static export to CDN; ISR for OpenAPI rebuilds
Portal API (NestJS)Node 22 / NestJS 113Key management, Verify API, snippet generator endpoint
Sandbox API proxyNode 22 / Fastify4Stateless proxy w/ deterministic DLR simulator
Verify workerNode 222Channel-fallback timers, attempt accounting
PostgreSQLPostgres 161 primary + 2 replicasdevportal schema (keys metadata, Verify sessions, SDK metadata)
RedisRedis 7 cluster3 nodesVerify session state, rate limits, key revocation pub/sub
Object storeS3-compatiblen/aSDK artifacts, OpenAPI bundles, Postman collections

10. Aggregates Owned

  • DeveloperAccount (linked 1:1 with auth-service Account) — profile, default tenant, preferred language, MFA preference for portal login
  • ApiKey (metadata only; secret material lives in auth-service) — environment, scope, label, last-used timestamp
  • SandboxSession — short-lived sandbox usage record per developer
  • VerifySessionverificationId, hashed code, channel state machine, attempts, expiry
  • VerifyTemplate — approved Verify message templates (locale × channel matrix)
  • SdkRelease — version, language, artifact URI, changelog, signing certificate fingerprint
  • DocsArticle — markdown + frontmatter for guides/tutorials, locale variants

11. Standards & Compliance

  • OpenAPI 3.1 for spec authoring; CI-validated against spectral ruleset before publish
  • OAS-to-SDK generation pipeline (forked OpenAPI Generator) with per-language post-processors
  • W3C WCAG 2.2 AA for portal UI (DevRel runs axe-core on every PR)
  • NIST SP 800-63B AAL2 for portal MFA; AAL3 for Verify API consumers operating high-risk flows
  • GDPR / Afghan Data Protection principles for developer profile data — see SECURITY_MODEL.md §4

12. Cross-Service Contracts (summary)

  • Consumes auth-service CreateApiKey, RotateApiKey, RevokeApiKey gRPC RPCs; emits devportal.key.created/revoked events
  • Consumes sms-orchestrator POST /v1/sms/send for Verify SMS dispatch
  • Consumes channel-router-service RequestFallback gRPC for Verify multi-channel cascade
  • Consumes analytics-service QueryConsumption(keyId, range) for developer dashboards
  • Emits devportal.verify.requested, devportal.verify.approved, devportal.verify.failed, devportal.sdk.downloaded events

13. Out-of-Scope (v1.0)

  • AI-pair-programming "ask the docs" assistant — tracked for v1.1; will be a separate docs-assistant-service calling the AI gateway, not embedded in this service.
  • Marketplace for third-party integrations (Zapier, n8n, Make) — tracked for v1.2.
  • Embedded billing UI — customer-portal continues to own billing; portal links out.

14. Glossary

TermDefinition
SandboxNon-deliverable replica of production API; predictable synthetic DLRs
Verify APIManaged OTP product abstracting channel selection, code generation, attempt accounting
Snippet generatorPer-endpoint code emitter producing idiomatic samples in 10+ languages
OASOpenAPI Specification (3.1 in this service)
Pre-baked PostmanA Postman collection generated from OAS, signed and versioned per release

15. Companion documents