API gateway & rate limiting database schema

How an API platform is modelled: consumers and applications, hashed API keys with scopes and rotation, upstream services and routes, rate limit policies, durable usage counters, rolled-up aggregates, sampled request logs, plans, quotas and overage billing.

API Gateway ER diagram

API gateway & rate limiting database schema n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 n1 consumers idBIGINT nameVARCHAR external_referenceVARCHAR contact_emailVARCHAR statusVARCHAR created_atTIMESTAMPTZ applications idBIGINT consumer_idBIGINT nameVARCHAR environmentVARCHAR descriptionVARCHAR owner_emailVARCHAR statusVARCHAR created_atTIMESTAMPTZ api_keys idBIGINT application_idBIGINT key_prefixVARCHAR key_hashVARCHAR scopesJSONB statusVARCHAR expires_atTIMESTAMPTZ last_used_atTIMESTAMPTZ revoked_atTIMESTAMPTZ replaces_key_idBIGINT created_atTIMESTAMPTZ services idBIGINT slugVARCHAR nameVARCHAR upstream_urlVARCHAR timeout_msINTEGER retry_countSMALLINT health_pathVARCHAR is_activeBOOLEAN routes idBIGINT service_idBIGINT path_patternVARCHAR http_methodVARCHAR auth_requiredBOOLEAN required_scopeVARCHAR rate_limit_policy…BIGINT strip_prefixBOOLEAN prioritySMALLINT is_activeBOOLEAN plans idBIGINT codeVARCHAR nameVARCHAR monthly_price_min…BIGINT currency_codeCHAR included_requestsBIGINT overage_price_per…BIGINT rate_limit_policy…BIGINT max_applicationsSMALLINT is_publicBOOLEAN rate_limit_policies idBIGINT nameVARCHAR scopeVARCHAR algorithmVARCHAR window_secondsINTEGER max_requestsINTEGER burst_sizeINTEGER on_exceedVARCHAR subscriptions idBIGINT consumer_idBIGINT plan_idBIGINT statusVARCHAR started_atTIMESTAMPTZ ends_atTIMESTAMPTZ quota_override_re…BIGINT billing_daySMALLINT usage_counters idBIGINT api_key_idBIGINT route_idBIGINT window_startTIMESTAMPTZ window_secondsINTEGER request_countBIGINT rejected_countBIGINT updated_atTIMESTAMPTZ usage_aggregates idBIGINT application_idBIGINT route_idBIGINT period_startTIMESTAMPTZ granularityVARCHAR request_countBIGINT error_countBIGINT rejected_countBIGINT bytes_inBIGINT bytes_outBIGINT latency_p50_msINTEGER latency_p95_msINTEGER latency_p99_msINTEGER request_logs idBIGINT request_idUUID trace_idVARCHAR api_key_idBIGINT route_idBIGINT occurred_atTIMESTAMPTZ methodVARCHAR pathVARCHAR status_codeSMALLINT latency_msINTEGER upstream_latency_…INTEGER bytes_outINTEGER client_ipINET user_agentVARCHAR sample_rateSMALLINT is_errorBOOLEAN ip_allowlist_entries idBIGINT application_idBIGINT cidr_blockCIDR descriptionVARCHAR created_atTIMESTAMPTZ expires_atTIMESTAMPTZ is_activeBOOLEAN billing_periods idBIGINT subscription_idBIGINT period_startDATE period_endDATE included_requestsBIGINT actual_requestsBIGINT overage_requestsBIGINT overage_amount_mi…BIGINT currency_codeCHAR statusVARCHAR closed_atTIMESTAMPTZ

Related database schemas