Engineering Architecture & Data Flow Guideline

Department

Technology

Table of Contents


Purpose

This guideline defines the essential engineering architecture and data flow standards for Technology at Kiluth.

Outcome
Systems have clear responsibility boundaries, predictable data flow, and maintainable code that can evolve without breaking integrations.

Scope

Applies to web applications, CLI tools, microservices, background jobs, and integrations built by Technology.

This document focuses on code organization, data flow patterns, and responsibility boundaries. It does not prescribe languages, frameworks, or deployment choices.


Definitions

TermDefinition
Contract / DTOA data structure that defines an external boundary (request/response/event payload). It is the “agreement” across systems or layers
Business entityA domain concept used inside application logic (e.g., User, Order)
Storage modelA persistence representation (DB schema/record/file format) used inside data access
Entry pointDelivery mechanism boundary (HTTP handler/controller, CLI command, job handler, event handler)
Application logicBusiness rules and orchestration (services/use cases)
Data accessRepositories/adapters that read/write storage or call external systems

Operating Model

Operating Model
1Asana is the system of record for work tracking, approvals, and handoffs.
2Use checkpoints and decision points: don’t move forward until the previous step is “done”, and branches are explicit.
3Handoff order: upstream defines handoff artifacts/exit criteria; downstream defines execution after handoff.

Core Architecture Pattern

Data structure types (keep them separate)

TypeUsed forLives in
Contract / DTOExternal boundariesEntry points / API layer
Business entityCore business logicApplication logic
Storage modelPersistence representationData access

Layer responsibilities

Dependency flow is one-way:

Entry point → Application logic → Data access → Storage / External systems

LayerResponsibilityMust not
Contracts / DTOsDefine boundary data shapesContain business rules, leak storage structure
Entry pointsParse/validate input shape, map DTO ↔ entity, call application logic, map errors to interface responseContain business logic, access storage directly
Application logicEnforce business rules, coordinate data access, work with entitiesKnow about HTTP/CLI formats, work with DTOs/storage models
Data accessRead/write storage, handle queries/transactions, map storage ↔ entity; integrate external servicesMake business decisions, expose storage/external details upward
Storage modelsRepresent persistence (tables/records/files)Leak into application logic or entry points
Outcome
Code is easier to test, safer to change, and clearer to review.

Contract-First Workflow (Step-by-step)

Use this workflow for new systems and significant changes.

Step
1Define contracts first (DTOs at every boundary). Agree on data shapes before implementation
2Define business entities required to serve the contracts
3Implement application logic using entities only
4Implement data access (storage/external) and translation (entity ↔ storage / entity ↔ external)
5Implement entry points and translation (DTO ↔ entity)
6Add minimum observability + tests + documentation (see below)
Outcome
Boundaries are explicit and changes are visible and reviewable.

Minimum Engineering Requirements

Validation & errors (layered)

WhereWhat to validateNotes
Entry pointsInput shape/parsing, basic required fieldsTreat inputs as untrusted; map to contracts
Application logicBusiness rules (always)The source of truth for business validation

Standard error shape:

{ code: string, message: string, details?: object }

Outcome
Failures are consistent, debuggable, and safe to expose externally.

Observability (minimum)

Every use case should be diagnosable without ad-hoc logging.

Minimum logging
1Log at entry points for start + completion (status, latency)
2Include correlation IDs when available (requestId/traceId) + useCase
3Do not log secrets; avoid full payload logs by default

Configuration & secrets

RuleDescription
Config flows outside-inRead config in composition root / entry point setup; inject into inner layers
Never store secrets in code/contracts/logsUse env/secret managers; redact sensitive values

Security (minimum)

Minimum expectations
1Parameterized queries (no SQL string concatenation)
2Safe error messages externally; log details internally with correlation IDs
3Authorization decisions belong in application logic (when applicable)

Testing (minimum)

LayerTest focus
Application logicBusiness rules + error paths (highest priority)
Entry pointsMapping + error translation
Data accessQuery logic + translation correctness

Documentation (minimum)

Use lightweight, searchable artifacts:

Artifact
1Contracts (DTOs) documented where they are defined (comments/readme when needed)
2Short architecture notes for significant changes (e.g., ADR-style decisions)

Common Anti-Patterns (Avoid)

Anti-patternWhy it hurts
1Business logic in entry pointsHard to test, duplicates rules, creates inconsistent behavior
2Application logic using DTOs/storage models directlyBoundaries blur; changes ripple across layers
3Direct storage access from controllers/handlersBreaks responsibility boundaries; increases coupling
4Implicit contracts (no DTOs)Integrations break silently; harder reviews and migrations
5Logging secrets / raw PIISecurity risk and compliance risk

Asana Card Templates (When Needed)

Use templates when a change crosses boundaries, impacts contracts, or requires explicit review.

Architecture / Contract Change Review

Asana Card Template
TitleArchitecture / contract change review – [System / Feature]
AssigneeTechnology (owner)
DescriptionPlease review the proposed architecture / contract change:

Context
• System: [System]
• Change summary: [What is changing]
• Related proposal / delivery context: [Link]

Boundary impact
• Contracts/DTOs changed: [Yes/No] (list)
• External integrations impacted: [Yes/No] (list)
• Data storage impacted: [Yes/No] (list)

Requested outcome
• Confirm responsibility boundaries and data flow
• Confirm backward compatibility or migration plan (if needed)
• Confirm minimum logging/testing requirements are met

When done, add a short decision note and move to In Review.

Architecture Checklist (Technology Use)

Contracts & boundaries

Checklist
1☐ Contracts/DTOs are explicit at boundaries
2☐ Business entities are used only inside application logic
3☐ Storage models stay inside data access

Data flow & layering

Checklist
1☐ Dependency flow is one-way (entry point → application logic → data access)
2☐ Entry points translate DTO ↔ entity
3☐ Data access translates entity ↔ storage/external contracts

Safety & operability

Checklist
1☐ Validation responsibilities are correct (shape at edge, business rules in core)
2☐ Minimum logging present and safe (no secrets/PII)
3☐ Tests cover application logic critical paths
4☐ A short decision note exists for significant changes (ADR-style when needed)