Skip to main content

Example: a secured marketplace

Worked stack
Two production applications and every security layer turned on

This is a marketplace stack the Stacktic team runs as its security reference: a catalog API, a shop front end, an AI assistant, and around them every security component the catalog offers. Every control below is a component, a sub-component, a link or an attribute on its diagram.

WHO REACHES ITroute apirate limit 10000/minroute shoprate limit 100/minWAF profile wafCrowdSec AppSecKeycloaklogin for the MCP serverAPPLICATIONScatalog-svcDjango · 2 replicasportal-frontendNode.js · 2 replicasWHAT CATALOG-SVC USEScatalog-dbCloudNativePGcatalog-imagesSeaweedFS bucketvalkeycacheopensearchsearchbids · ordersKafka topicsai-gatewayroute to a modelMODEL · vLLMchat modelmarketplace-chatSECURITY AROUND ITADMISSIONOPA · 8 policies4 deny · 2 warn · 2 dryrunNETWORKpolicies per linkSuricata → OpenSearchSECRETSOpenBaoExternal Secrets syncSUPPLY CHAINgates · SAST · DASTTrivy · SonarQube · Nuclei
The design of the secured marketplace. Solid lines are links, dashed lines the WAF profile protecting both applications. The bottom band is the security generated around the same components.

The design​

29 components. Names are the ones on the diagram.

LayerCells
Applicationscatalog-svc (external source code, Django, port 8000) · portal-frontend (external source code, Node.js, port 8080) — both env: production, 2 replicas
Who reaches themapisix with 8 routes and an AI gateway sub-component · crowdsec with the WAF profile waf · keycloak-operator · cert-manager
Data and eventscnpg with catalog-db and sonarqube · kafka with the topics bids and orders, a bridge and two node pools · opensearch · valkey · seaweedfs with six buckets
Modelvllm with the model marketplace-chat
Data jobsairflow with the ETL sub-component catalog-export
Scale and loadkeda with the triggers api-load and shop-load · k6 with the suite shop-journey-r2
Securityopa with 8 policies · falco · suricata · crowdsec · openbao · external-secrets · trivy · sonarqube · nuclei
Observabilityprometheus (12 scrape links) · grafana
Deliveryargo-cd (28 links) · reloader
Operationsstack-agent · fastmcp

The applications​

catalog-svcportal-frontend
Routeapi.<domain>, rate limit 10000 requests per minute per client address, CORS on, body up to 10 MiBshop.<domain>, rate limit 100 requests per minute, CORS on, body up to 10 MiB
WAFProfile waf, waf_failure_action: passthroughThe same profile, passthrough
Gateway loginOff: the application handles its own usersOff
Workload hardeningpod_security, container_security, read_only_fs, drop_capabilities, no_privilege_escalation, no_host_access, seccompThe same seven
Build gatesbuild_gate: enforce, sast_gate: enforce, SonarQube scan through sonarqube-external_source_codeThe same
DASTnuclei-external_source_codenuclei-external_source_code
AutoscalingKEDA trigger api-load (prometheus_query-external_source_code)KEDA trigger shop-load

catalog-svc's own links: external_source_code-db to catalog-db, external_source_code-swbucket to catalog-images, external_source_code-valkey, external_source_code-opensearch, external_source_code-topic to bids and to orders, and external_source_code-ai_gateway to ai-gateway, which links ai_gateway-model to marketplace-chat. Each one puts its variables into the application's environment, in the Django form for the database, the cache and the bucket — see How a stack fits together.

Security, layer by layer​

At the edge​

ControlOn the diagramWhat it does here
Rate limitsrate_limiting and rate_limit_count on seven of the eight route links (not on Grafana)APISIX limit-count per client address, counted on each gateway replica
Web application firewallCrowdSec waf sub-component, linked waf-external_source_code to both applications; apisix-crowdsecCrowdSec's AppSec engine (Coraza with the OWASP Core Rule Set, virtual patches, generic rules) checks every request to both applications. The profile runs in detect: matches raise alerts, nothing is blocked yet. With passthrough, an unreachable WAF lets requests through
IP banscrowdsec_firewall_bouncer on, crowdsec_simulation off, remediation ban for 4 hoursScenario overflows produce real decisions; the firewall bouncer drops traffic from a banned address on every node. Operator addresses are on crowdsec_allowlist so they are never banned
Log sources for CrowdSecapisix-crowdsec, crowdsec-suricata; collections suricata, base-http-scenarios, http-cveThe agent on every node reads the gateway access log and Suricata's events

In the network and at admission​

ControlOn the diagramWhat it does here
Network policiesGenerated from every link, standard setOne policy per link; the OPA policy network-policy-enforcement refuses workloads in namespaces without one
Admission policyopa with 8 policy sub-componentslabel-deny, pod-level-security, network-policy-enforcement and resource-policy at deny; image-policy and rbac-enforcement at warn; securitycontext and probes at dryrun. Every policy is scoped to the stack label stacktic.io/stack. opa_failure_policy: Ignore: if Gatekeeper is down, admission does not fail
Kafka clientsmtls on the Kafka componentEach application linked to a topic gets its own TLS client certificate and ACLs

Watching​

ControlOn the diagramWhat it does here
Network intrusion detectionsuricata, linked suricata-opensearchA passive sensor on every node, Emerging Threats Open rules refreshed every 24 hours, alerts and stats shipped to OpenSearch
Runtime detectionfalco, modern_ebpf driver, Falcosidekick onSyscall rules on every node. The design has no falco-opensearch link, so Falco's events are not shipped to the SIEM
CrowdSec alertscrowdsec-opensearchEvery alert, WAF matches included, in the index crowdsec-alerts, with the SIEM dashboards and the new-decision monitor
Vulnerability reportstrivy-opensearchTrivy's reports in the SIEM
RetentionOpenSearch retention_hot_days: 7, retention_warm_days: 90, retention_total_days: 365The index lifecycle policy moves the SIEM indices (Falco, APISIX, OPA, audit, OpenTelemetry, Suricata, CrowdSec) to warm after 7 days and deletes them after 365
Metricsprometheus-suricata, prometheus-crowdsec, prometheus-opa and nine moreAlert rules per component and the provisioned dashboards

Secrets​

external-secrets links external_secrets-openbao: a seed Job writes the stack's secrets into OpenBao, and External Secrets syncs them into the namespaces that use them. openbao-swbucket takes Raft snapshots of OpenBao into a bucket on a schedule. See Identity and secrets.

Before anything runs​

GateOn the diagramEffect
Source scanbuild_gate: enforce on both applicationsA finding stops the build
Your own rulessast_gate: enforceOpengrep with the stack's rules stops the build on a match
Quality gatesonarqube-external_source_code to both applications, scan_enabled on, enforce_quality_gate off; sonarqube-dbSonarQube scans both applications on every build; a failed quality gate is reported, not blocking, until enforce_quality_gate is turned on
DASTnuclei linked to both applications, the gateway and the stack agentOne scan contract per link, its runs pushed to the stack agent
Evidencestack_agent-swbucket to compliance-evidence, cve_decisions_enabled onCompliance evidence files in a bucket; a recorded decision per image vulnerability

See Development security for the three gates in detail.

Scale, load and data movement​

SCALE AND LOADapi-load → catalog-svcprometheus_query triggershop-load → portal-frontendprometheus_query triggerdb · topic · model triggerscatalog-db · bids · chat modelk6 journeyendpoints suiteresultsPrometheus · GrafanaDATA FLOWScatalog-db → catalog-exportdb-etl · Airflow ETLcatalog-export → etl-exportsetl-swbucket · bucketbids → opensearchtopic-opensearch · Connect sink
Scaling, load testing and data movement are sub-components and links too, so they are versioned with the stack and visible in a diff.
Link or sub-componentWhat it generates
keda-prometheus + prometheus_query sub-components api-load and shop-load, each linked to its applicationA KEDA ScaledObject per application, scaling on a Prometheus query. The applications run with hpa: false, as KEDA requires
keda-db to catalog-dbA ScaledObject on the CloudNativePG cluster itself: its instance count follows a PostgreSQL query
keda-topic to bidsScales the consumers of the topic on their lag
keda-model to marketplace-chatScales the model's vLLM runtime
k6 endpoints sub-component shop-journey-r2A load-test suite of virtual shoppers following a journey, results labelled per step in Prometheus (prometheus-k6) and shown in Grafana
Airflow catalog-export: db-etl from catalog-db, etl-swbucket to etl-exportsAn ETL job reading the catalog database and writing exports to a bucket
topic-opensearch from bidsA Kafka Connect sink writing every bid into OpenSearch

Delivery and operations​

ConcernOn the diagramWhat it gives this stack
Deliveryargo-cd linked to 28 components · reloaderOne Application per component, data never deleted by Argo CD, pods restarted when their Secret changes
Backupscnpg-swbucket, opensearch-swbucket, openbao-swbucketDatabase backups, OpenSearch snapshots and OpenBao snapshots, each in its own bucket
Stack agentdeploy_access, backup_apply_access and cve_decisions_enabled onDeploys committed branches, runs guarded restore operations, records vulnerability decisions
MCP serverfastmcp linked to mcp-client, opa, stack-agent, valkey, kafka; ai_workflow: spec-kitKeycloak login, admission-policy tools, the agent's scans, persistent client storage, Kafka tools, and spec-driven development kits in the application folders

What the design deliberately leaves out​

These are choices on this diagram, not gaps in the platform:

  • The application routes do not use gateway login; the applications authenticate their own users.
  • The WAF runs in detect. Switching the profile's waf_mode to block turns matches into refusals once the alerts have been reviewed.
  • Falco has no OpenSearch link, so its events are not in the SIEM.

→ How a stack fits together · Security, layer by layer