Philosophy
- Project Name: FinLens
- Document Type: Data Contract / Data Architecture
- Audience: Architects; Engineers; UI Developers; Future Contributors; Auditors
- Document Nature: Highly Controlled, Living
- Stability: Very High (breaking changes are rare and expensive)
This document defines the data contract between:
- Backend (scanner + processor)
- Frontend (UI)
- Future versions of FinLens
- Humans reading archived reports
It answers:
- What data exists
- How data is structured
- What guarantees the data provides
- How data evolves safely over time
Processed JSON is the product. Everything else exists to create or interpret it.
- The processed JSON represents the complete, final, authoritative state
- UI must never infer, guess, or recalculate data
- Backend must never rely on UI logic
- A human should understand the file without tools
- Clear naming over compactness
- Explicit fields over implicit meaning
- Reports may be opened years later
- Meaning must survive:
- Cloud API changes
- FinLens version changes
- UI rewrites
- Data accuracy at scan time
- Deterministic structure
- Explicit meaning of all fields
- Stable schema version
- Faithful rendering of JSON
- No data mutation
- No hidden enrichment
- Respect for schema versioning
| Data Type | Description | Mutability |
|---|---|---|
| Metadata | Scan context | Immutable |
| Account Data | Processed account state | Immutable |
| Derived Signals | Enrichment outputs | Immutable |
| UI State | Filters, sorting | Ephemeral |
Only UI state is allowed to change.
Processed Report
schema_version
generated_at
account
account_id
account_name
currency
services
service[]
service_name
summary
resources[]
This hierarchy is fixed.
Purpose: Controls compatibility between generator and consumer.
Rules:
- Required
- Semantic versioning
- UI behavior may vary by version
Purpose: Defines when the data snapshot was taken.
Rules:
- ISO-8601 format
- Informational only
- UI must never use it for logic
Represents one cloud account at a specific moment.
Required Fields:
- account_id
- account_name
- currency
- services
No cross-account data allowed.
Represents one cloud service (e.g., EC2, Lambda).
Required Fields:
- service_id
- service_name
- region_scope
- summary
- resources
Purpose: Enable decision-making without drilling down.
Typical Fields:
- resource_count
- monthly_cost
- health_status
- optimization_potential
- risk_level
Rules:
- Aggregated from resources
- Must be explainable
- No hidden math
Represents one cloud resource.
Required Fields:
- resource_id
- resource_name
- region
- cost
- utilization
- health
- optimization
If data is unavailable:
- Field must exist
- Value must be null
- Never omit silently
This preserves trust.
- Costs are:
- Monthly
- Numeric
- In declared currency
- Zero cost = missing cost
- Cost breakdowns must be explicit
- Utilization is contextual, not absolute
- Values must include:
- Metric name
- Time window
- Interpretation hint
No raw metrics without explanation.
- Represents current operational state
- Example values:
- healthy
- warning
- unhealthy
Must include:
- Reason
- Evidence reference
- Represents potential future issue
- Must never be alarmist
- Must include reasoning
Rules
- Hints are suggestions, not actions
- Each hint must include:
- Reason
- Potential impact
- Confidence level
No automated recommendations without context.
- snake_case keys
- No abbreviations unless industry-standard
- No overloaded fields
- Same name = same meaning everywhere
- Arrays must have stable ordering
- Sorting rules must be deterministic
- UI may re-order visually but not mutate data
- Adding new fields
- Adding new services
- Adding optional fields
Breaking changes include:
- Renaming fields
- Changing meanings
- Removing fields
Require:
- Schema version bump
- Migration strategy
- Explicit documentation
- UI should support at least N-1 versions
- Older reports must remain readable
- Best-effort rendering is acceptable, failure is not
Before a report is considered valid:
- Schema version present
- Required fields present
- No silent drops
- JSON is parseable and readable
- UI-derived calculations
- Implicit meanings
- Magic numbers
- Schema-less extensions
- "Temporary" fields
There is no such thing as temporary in data contracts.
- Data contract is owned by Product + Architecture
- Any change requires:
- Impact analysis
- Document update
- Version bump (if needed)
This data contract is satisfied when:
- UI can render reports without backend
- Humans can understand JSON directly
- Old reports survive new releases
- Decisions can be traced to data