Faysal Ahmed
Chapter 7

Security and Data Architecture

Threat modelling, zero trust, data modelling, storage strategies, and compliance.

Security Architecture

Threat Modelling

Identify threats before they become incidents. Use STRIDE per component:

ThreatDefinitionExampleMitigation
SpoofingImpersonationFake login credentialsMFA, certificate-based auth
TamperingData modificationAltering DB queries in transitTLS, integrity checks
RepudiationDenial of actionUser claims they didn't place orderAudit logs, digital signatures
Info disclosureData exposureAPI returns sensitive fieldsEncryption, access control
Denial of serviceOverwhelming the systemDDoS attackRate limiting, auto-scaling
Elevation of privilegeUnauthorised accessUser edits another user's dataRBAC, input validation
Figure 7.1 — STRIDE threat model. Apply to each component during design reviews.
How to run a threat modelling session

Walk through each STRIDE category for every component in your architecture diagram. For each threat, decide: Accept, Mitigate, Transfer (e.g., insurance, WAF), or Avoid (redesign). Document the outcome in your ADR.

Zero Trust

Trust no one by default. Verify every request regardless of origin.

PrincipleImplementation
Network segmentationMicro-segmentation limits lateral movement
Identity-firstEvery request authenticated and authorised
Least privilegeMinimum permissions needed for each role
Continuous verificationRe-evaluate trust on every request

Security Checklist

  • Encrypt data at rest and in transit (TLS 1.3+, AES-256)
  • Hash and salt passwords (bcrypt, Argon2)
  • Use API keys or OAuth2 — never share credentials
  • Implement rate limiting and input validation
  • Keep dependencies updated (automated scanning)

Data Architecture

Data Modelling

ModelBest ForACIDSchemaExamples
RelationalStructured, complex queriesYesFixedPostgreSQL, MySQL
DocumentFlexible JSON documentsConfigurableDynamicMongoDB, Couchbase
Key-ValueHigh throughput, simple lookupsLimitedNoneRedis, DynamoDB
GraphRelationships, recommendationsVariesFlexibleNeo4j, Dgraph
Time-seriesMetrics, logs, eventsLimitedFixedInfluxDB, TimescaleDB
Table 7.1 — Database model comparison for different use cases.

Storage Tiers

TierAccess PatternMediumCost
HotFrequently accessedSSD, in-memory cacheHigh
WarmLess frequentStandard diskMedium
ColdArchivalObject storage (S3 Glacier)Low
Table 7.2 — Storage tier characteristics. Match the tier to the data's access pattern to optimise cost.

Data Governance

  • Classification — tag data by sensitivity (public, internal, confidential, restricted)
  • Retention policies — how long to keep data, when to purge
  • Audit logging — who accessed what, when
  • GDPR / CCPA compliance — right to access, right to deletion, data portability
Compliance is not optional

Data governance requirements vary by industry (finance, healthcare, public sector) and geography (GDPR in EU, CCPA in California, LGPD in Brazil). Determine applicable regulations early — retrofitting data controls is expensive.


Next: Chapter 8 — Integration, APIs, and Microservices