Seeding wioth some data

main
Tom Peltonen 2026-03-08 10:23:32 +11:00
commit 07cf729d8e
17 changed files with 1164 additions and 0 deletions

5
solutions.md 100644
View File

@ -0,0 +1,5 @@
# Solutions
The solution documenation for various initatives are listed in the
solution folder.

View File

@ -0,0 +1,6 @@
# Test solution
This solution location is just an area for testing
the solution documentation for **qaskx-cli** tool
qaskx-cli -W ~/projects.design/todo.design/solutions/test rediops design -d ./specs -t ./design\solution-design.md.hbs -o ./todo-solution.md -v

View File

@ -0,0 +1,411 @@
# {{get (get (get business_requirements 0) "data") "name"}} - Solution Design Document
{{toc}}
**Generated:** {{generated_date}}
**Version:** 1.0
**Status:** Draft
---
# Executive Summary
This document provides a high-level solution design for
the **{{get (get (get business_requirements 0) "data") "name"}}**
platform. It consolidates
specifications across business requirements, security, APIs, databases, and deployment configurations.
{{overviewDiagram}}
---
# 1. Business Requirements
{{#if has_business_requirements}}
{{#each business_requirements}}
## {{get data "name"}}
**Description:** {{get data "description"}}
### Requirements
{{#each (get data "requirements")}}
- **{{id}}**: {{title}}
- {{description}}
- Priority: {{priority}}
{{/each}}
### Features
{{#each (get data "features")}}
#### {{name}}
{{#each components}}
- {{this}}
{{/each}}
{{/each}}
{{/each}}
{{else}}
*No business requirements specifications found.*
{{/if}}
---
# 2. Non-Functional Requirements
{{#if has_nfr}}
{{#each non_functional_requirements}}
### NFR Summary
| ID | Category | Title | Target |
|----|----------|-------|--------|
{{#each (get data "requirements")}}
| {{id}} | {{category}} | {{title}} | {{target}} |
{{/each}}
{{/each}}
{{else}}
*No NFR specifications found.*
{{/if}}
---
# 3. Security Architecture
{{#if has_security}}
{{#each security}}
## Encryption
- **At Rest:** {{get (get data "encryption") "at_rest"}}
- **In Transit:** {{get (get data "encryption") "in_transit"}}
## Compliance
{{#each (get (get data "compliance") "standards")}}
- **{{name}}** ({{#each regions}}{{this}}{{/each}})
{{/each}}
## Threat Model
| Threat | Severity | Mitigation |
|--------|----------|------------|
{{#each (get (get data "threat_model") "threats")}}
| {{name}} | {{severity}} | {{mitigation}} |
{{/each}}
{{/each}}
{{else}}
*No security specifications found.*
{{/if}}
---
# 4. Authentication & Authorization
{{#if has_authentication}}
## Authentication
{{#each authentication}}
### Methods
{{#each (get data "methods")}}
- **{{type}}**: {{#if enabled}}Enabled{{else}}Disabled{{/if}}
{{/each}}
### Session Configuration
- Token Type: {{get (get data "session") "type"}}
- Access Token Expiry: {{get (get data "session") "access_token_expiry"}}
- Refresh Token Expiry: {{get (get data "session") "refresh_token_expiry"}}
{{/each}}
{{/if}}
{{#if has_authorization}}
## Authorization
{{#each authorization}}
### Model: {{upper (get data "model")}}
### Roles
| Role | Description | Permissions |
|------|-------------|-------------|
{{#each (get data "roles")}}
| {{name}} | {{description}} | {{join permissions ", "}} |
{{/each}}
{{/each}}
{{/if}}
{{sequenceDiagram "Authentication Flow"}}
---
# 5. Database Design
{{#if has_database}}
{{#each database}}
## Database: {{get data "type"}}
- **Engine:** {{get data "engine"}}
- **Version:** {{get data "version"}}
### Schemas
{{#each (get data "schemas")}}
#### Schema: {{name}}
{{#each tables}}
**Table: {{name}}**
| Column | Type | Constraints |
|--------|------|-------------|
{{#each columns}}
| {{name}} | {{type}} | {{#if primary_key}}PK{{/if}}{{#if unique}}UNIQUE{{/if}}{{#if not_null}}NOT NULL{{/if}}{{#if foreign_key}}FK: {{foreign_key}}{{/if}} |
{{/each}}
{{/each}}
{{/each}}
### Replication & Backup
- **Replication Type:** {{get (get data "replication") "type"}}
- **Replicas:** {{get (get data "replication") "replicas"}}
- **Backup Frequency:** {{get (get data "backup") "frequency"}}
- **Retention:** {{get (get data "backup") "retention"}}
{{/each}}
{{dbDiagram}}
{{else}}
*No database specifications found.*
{{/if}}
---
# 6. API Specifications
{{#if has_openapi}}
{{#each openapi}}
## Published APIs
{{#each (get (get data "apis") "published")}}
### {{name}} ({{version}})
**Base Path:** `{{base_path}}`
| Method | Path | Description | Used | Impact | Auth Required |
|--------|------|-------------|------|--------|---------------|
{{#each endpoints}}
| {{method}} | {{path}} | {{description}} | {{#if used}}Yes{{else}}No{{/if}} | {{impact}} | {{#if auth_required}}Yes{{else}}No{{/if}} |
{{/each}}
{{/each}}
## Consumed APIs (External)
{{#each (get (get data "apis") "consumed")}}
### **{{name}}** ({{provider}}): `{{base_url}}`
| Method | Path | Description | Used | Impact | Auth Required |
|--------|------|-------------|------|--------|---------------|
{{#each endpoints}}
| {{method}} | {{path}} | {{description}} | {{#if used}}Yes{{else}}No{{/if}} | {{impact}} | {{#if auth_required}}Yes{{else}}No{{/if}} |
{{/each}}
{{/each}}
{{/each}}
{{sequenceDiagram "API Request Flow"}}
{{else}}
*No API specifications found.*
{{/if}}
---
# 7. Message Queues (OpenSync)
{{#if has_opensync}}
{{#each opensync}}
## Broker: {{get data "broker"}} ({{get data "version"}})
### Published Queues
| Queue | Exchange | Routing Key | Description |
|-------|----------|-------------|-------------|
{{#each (get (get data "queues") "published")}}
| {{name}} | {{exchange}} | {{routing_key}} | {{description}} |
{{/each}}
### Consumed Queues
| Queue | Exchange | Handler | Description |
|-------|----------|---------|-------------|
{{#each (get (get data "queues") "consumed")}}
| {{name}} | {{exchange}} | {{handler}} | {{description}} |
{{/each}}
### Dead Letter Queue
- **Enabled:** {{get (get data "dlq") "enabled"}}
- **Max Retries:** {{get (get data "dlq") "max_retries"}}
{{/each}}
{{sequenceDiagram "Message Queue Flow"}}
{{else}}
*No message queue specifications found.*
{{/if}}
---
# 8. Observability
## Telemetry
{{#if has_telemetry}}
{{#each telemetry}}
### Metrics
- **Provider:** {{get (get data "metrics") "provider"}}
- **Endpoint:** {{get (get data "metrics") "endpoint"}}
#### Custom Metrics
{{#each (get (get data "metrics") "custom_metrics")}}
- `{{name}}` ({{type}}): {{description}}
{{/each}}
### Distributed Tracing
- **Provider:** {{get (get data "traces") "provider"}}
- **Sampling Rate:** {{get (get data "traces") "sampling_rate"}}
{{/each}}
{{else}}
*No telemetry specifications found.*
{{/if}}
## Analytics
{{#if has_analytics}}
{{#each analytics}}
### Events Tracked
{{#each (get (get data "tracking") "events")}}
- **{{name}}**: {{join properties ", "}}
{{/each}}
{{/each}}
{{else}}
*No analytics specifications found.*
{{/if}}
## Logging
{{#if has_logging}}
{{#each logging}}
### Log Destinations
{{#each (get data "destinations")}}
- **{{name}}** ({{type}}): Level = {{level}}
{{/each}}
### Retention Policy
- Hot Storage: {{get (get data "retention") "hot"}}
- Warm Storage: {{get (get data "retention") "warm"}}
- Cold Storage: {{get (get data "retention") "cold"}}
{{/each}}
{{else}}
*No logging specifications found.*
{{/if}}
---
# 9. Deployment Architecture
{{#if has_deployment}}
{{#each deployment}}
## Container Configuration
- **Base Image:** {{get (get data "docker") "base_image"}}
## Kubernetes Resources
### Deployments
{{#each (get (get data "kubernetes") "deployments")}}
#### {{name}}
- **Replicas:** {{replicas}}
- **Image:** {{image}}
- **CPU Request/Limit:** {{get (get resources "requests") "cpu"}} / {{get (get resources "limits") "cpu"}}
- **Memory Request/Limit:** {{get (get resources "requests") "memory"}} / {{get (get resources "limits") "memory"}}
{{/each}}
### Auto-Scaling
- **Enabled:** {{get (get (get data "kubernetes") "autoscaling") "enabled"}}
- **Min/Max Replicas:** {{get (get (get data "kubernetes") "autoscaling") "min_replicas"}} - {{get (get (get data "kubernetes") "autoscaling") "max_replicas"}}
{{/each}}
{{else}}
*No deployment specifications found.*
{{/if}}
---
# 10. Service Level Agreements
{{#if has_service_level}}
{{#each service_level}}
## SLA
- **Availability Target:** {{get (get data "sla") "availability"}}
## Service Level Objectives
| Objective | Target | Window |
|-----------|--------|--------|
{{#each (get data "slo")}}
| {{name}} | {{target}} | {{window}} |
{{/each}}
## Error Budget
- **Monthly Budget:** {{get (get data "error_budget") "monthly_budget"}}
- **Alert Threshold:** {{get (get data "error_budget") "alerting_threshold"}}
{{/each}}
{{else}}
*No service level specifications found.*
{{/if}}
---
# Appendix
## A. Specification Files Summary
| File | Type |
|------|------|
{{#each all_files}}
| {{name}} | {{type}} |
{{/each}}
## B. Document History
| Version | Date | Author | Changes |
|---------|------|--------|---------|
| 1.0 | {{generated_date}} | {{generator_product}} | Initial generation |
---
*This document was automatically generated by **{{generator_product}}** v{{generator_version}} on {{generated_at}}*

View File

@ -0,0 +1,54 @@
spec_type: analytics
name: Analytics Configuration
version: "1.0"
provider: segment
tracking:
events:
- name: page_viewed
properties:
- page_name
- referrer
- session_id
- name: product_viewed
properties:
- product_id
- product_name
- category
- price
- name: add_to_cart
properties:
- product_id
- quantity
- cart_value
- name: purchase_completed
properties:
- order_id
- total
- items_count
- payment_method
user_traits:
- user_id
- email
- signup_date
- subscription_tier
dashboards:
- name: Sales Overview
metrics:
- daily_revenue
- orders_count
- average_order_value
- conversion_rate
- name: User Engagement
metrics:
- daily_active_users
- session_duration
- pages_per_session
- bounce_rate

View File

@ -0,0 +1,38 @@
spec_type: authentication
name: Authentication Configuration
version: "1.0"
methods:
- type: email_password
enabled: true
password_policy:
min_length: 12
require_uppercase: true
require_lowercase: true
require_numbers: true
require_special: true
max_age_days: 90
- type: oauth2
enabled: true
providers:
- name: google
client_id_env: GOOGLE_CLIENT_ID
scopes: [email, profile]
- name: github
client_id_env: GITHUB_CLIENT_ID
scopes: [user:email]
- type: mfa
enabled: true
options:
- totp
- sms
- email
session:
type: jwt
access_token_expiry: 15m
refresh_token_expiry: 7d
secure_cookie: true
same_site: strict

View File

@ -0,0 +1,65 @@
spec_type: authorization
name: Authorization Model
version: "1.0"
model: RBAC
roles:
- name: admin
description: Full system access
permissions:
- "*"
- name: seller
description: Manage own products and orders
permissions:
- products:create
- products:read
- products:update
- products:delete:own
- orders:read:own
- analytics:read:own
- name: customer
description: Browse and purchase products
permissions:
- products:read
- cart:*
- orders:create
- orders:read:own
- profile:*:own
- name: guest
description: Browse only
permissions:
- products:read
permissions:
products:
- create
- read
- update
- delete
orders:
- create
- read
- update
- cancel
users:
- create
- read
- update
- delete
- ban
resource_policies:
- resource: products
owner_field: seller_id
actions:
update: owner_only
delete: owner_only
- resource: orders
owner_field: customer_id
actions:
read: owner_or_admin
cancel: owner_only

View File

@ -0,0 +1,62 @@
spec_type: business_requirements
name: E-Commerce Platform
version: "1.0"
description: Online marketplace for digital products
requirements:
- id: BR-001
title: User Registration
description: Users must be able to create accounts with email verification
priority: high
acceptance_criteria:
- Email validation required
- Password strength enforcement
- Email verification link sent
- id: BR-002
title: Product Catalog
description: Display products with search and filtering capabilities
priority: high
acceptance_criteria:
- Category-based navigation
- Full-text search
- Price range filtering
- id: BR-003
title: Shopping Cart
description: Users can add/remove items and proceed to checkout
priority: high
acceptance_criteria:
- Persistent cart across sessions
- Quantity modification
- Price calculation with discounts
features:
- name: User Management
components:
- Registration
- Login
- Profile management
- Password reset
- name: Product Management
components:
- Product listing
- Product details
- Reviews and ratings
- Inventory tracking
- name: Order Management
components:
- Cart management
- Checkout flow
- Order tracking
- Order history
stakeholders:
- name: Product Owner
role: Decision maker
- name: Development Team
role: Implementation
- name: End Users
role: Consumers

View File

@ -0,0 +1,65 @@
spec_type: database
name: Database Configuration
version: "1.0"
type: postgresql
engine: PostgreSQL 15
engine_version: "15.4"
configuration:
max_connections: 200
shared_buffers: 256MB
work_mem: 4MB
maintenance_work_mem: 64MB
schemas:
- name: users
tables:
- name: users
columns:
- name: id
type: uuid
primary_key: true
- name: email
type: varchar(255)
unique: true
not_null: true
- name: password_hash
type: varchar(255)
not_null: true
- name: created_at
type: timestamp
default: now()
indexes:
- columns: [email]
unique: true
- name: products
tables:
- name: products
columns:
- name: id
type: uuid
primary_key: true
- name: seller_id
type: uuid
foreign_key: users.id
- name: name
type: varchar(255)
- name: price
type: decimal(10,2)
- name: status
type: varchar(50)
indexes:
- columns: [seller_id]
- columns: [status, created_at]
replication:
type: streaming
replicas: 2
sync_mode: async
backup:
frequency: daily
retention: 30 days
type: point_in_time

View File

@ -0,0 +1,63 @@
spec_type: deployment
name: Deployment Configuration
version: "1.0"
docker:
base_image: node:20-alpine
build_stages:
- name: builder
commands:
- COPY package*.json ./
- RUN npm ci
- COPY . .
- RUN npm run build
- name: runtime
commands:
- COPY --from=builder /app/dist ./dist
- CMD ["node", "dist/main.js"]
kubernetes:
namespace: production
deployments:
- name: api-server
replicas: 3
image: app/api:latest
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 1000m
memory: 1Gi
health_checks:
liveness:
path: /health
port: 8080
initial_delay: 30
readiness:
path: /ready
port: 8080
services:
- name: api-service
type: ClusterIP
port: 80
target_port: 8080
ingress:
host: api.example.com
tls: true
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: letsencrypt
autoscaling:
enabled: true
min_replicas: 3
max_replicas: 10
metrics:
- type: cpu
target_utilization: 70
- type: memory
target_utilization: 80

View File

@ -0,0 +1,47 @@
spec_type: logging
name: Logging Configuration
version: "1.0"
destinations:
- name: stdout
type: console
format: json
level: info
- name: elasticsearch
type: elasticsearch
hosts:
- https://logs.example.com:9200
index_pattern: "app-logs-%{+YYYY.MM.dd}"
level: debug
- name: cloudwatch
type: aws_cloudwatch
log_group: /app/production
region: us-east-1
level: warn
format:
type: json
fields:
- timestamp
- level
- message
- service
- trace_id
- span_id
- user_id
- request_id
retention:
hot: 7 days
warm: 30 days
cold: 90 days
redaction:
enabled: true
fields:
- password
- token
- credit_card
- ssn

View File

@ -0,0 +1,42 @@
spec_type: non_functional_requirements
name: Platform NFRs
version: "1.0"
requirements:
- id: NFR-001
category: performance
title: Response Time
description: API response time must be under 200ms for 95th percentile
metric: p95_latency
target: "< 200ms"
- id: NFR-002
category: scalability
title: Concurrent Users
description: System must support 10,000 concurrent users
metric: concurrent_connections
target: ">= 10000"
- id: NFR-003
category: availability
title: Uptime SLA
description: System availability must be 99.9%
metric: uptime_percentage
target: ">= 99.9%"
- id: NFR-004
category: security
title: Data Encryption
description: All data at rest and in transit must be encrypted
requirements:
- TLS 1.3 for transit
- AES-256 for storage
- id: NFR-005
category: reliability
title: Data Durability
description: No data loss in case of single node failure
requirements:
- Multi-region replication
- Daily backups
- Point-in-time recovery

View File

@ -0,0 +1,56 @@
spec_type: opensync
name: Message Queue Configuration
version: "1.0"
broker: rabbitmq
broker_version: "3.12"
queues:
published:
- name: order.created
description: Emitted when a new order is created
exchange: orders
routing_key: order.created
payload_schema:
type: object
properties:
order_id:
type: string
customer_id:
type: string
items:
type: array
total:
type: number
- name: payment.completed
description: Emitted when payment is confirmed
exchange: payments
routing_key: payment.completed
payload_schema:
type: object
properties:
payment_id:
type: string
order_id:
type: string
amount:
type: number
consumed:
- name: inventory.updated
description: Consumed to update product availability
exchange: inventory
routing_key: inventory.#
handler: InventoryHandler
- name: notification.send
description: Consumed to send notifications
exchange: notifications
routing_key: notification.*
handler: NotificationHandler
dlq:
enabled: true
max_retries: 3
retry_delay: 5000

View File

@ -0,0 +1,51 @@
spec_type: security
name: Security Specifications
version: "1.0"
encryption:
at_rest:
algorithm: AES-256-GCM
key_management: AWS KMS
in_transit:
protocol: TLS 1.3
certificate_authority: Let's Encrypt
data_protection:
pii_fields:
- email
- phone
- address
- payment_info
retention_policy:
active_data: 3 years
deleted_data: 30 days
anonymization:
enabled: true
method: k-anonymity
compliance:
standards:
- name: GDPR
regions: [EU]
requirements:
- Right to be forgotten
- Data portability
- Consent management
- name: PCI-DSS
level: 1
requirements:
- Secure cardholder data
- Access control
- Network monitoring
threat_model:
threats:
- name: SQL Injection
mitigation: Parameterized queries
severity: high
- name: XSS
mitigation: Output encoding, CSP headers
severity: high
- name: CSRF
mitigation: CSRF tokens
severity: medium

View File

@ -0,0 +1,52 @@
spec_type: service_level
name: Service Level Agreements
version: "1.0"
sla:
availability: 99.9%
support_response:
critical: 15 minutes
high: 1 hour
medium: 4 hours
low: 24 hours
slo:
- name: API Availability
target: 99.95%
measurement: uptime_percentage
window: 30 days
- name: API Latency (p99)
target: 500ms
measurement: response_time_p99
window: 1 hour
- name: Error Rate
target: 0.1%
measurement: error_percentage
window: 1 hour
- name: Throughput
target: 10000 rps
measurement: requests_per_second
window: 1 minute
sli:
- name: request_latency
type: histogram
good_events: latency < 200ms
total_events: all_requests
- name: availability
type: ratio
good_events: successful_requests
total_events: all_requests
- name: error_rate
type: ratio
good_events: non_error_requests
total_events: all_requests
error_budget:
monthly_budget: 43.2 minutes
alerting_threshold: 50%

View File

@ -0,0 +1,83 @@
spec_type: openapi
name: API Specifications
version: "1.0"
apis:
published:
- name: Products API
version: v1
base_path: "/api/v1/products"
endpoints:
- method: GET
path: /
used: true
impact: modify
description: List all products
query_params:
- name: page
type: integer
- name: limit
type: integer
- name: category
type: string
response: ProductList
- method: GET
path: /{id}
used: true
impact: no change
description: Get product by ID
response: Product
- method: POST
path: /
used: true
impact: config
description: Create new product
auth_required: true
roles: [seller, admin]
request: CreateProduct
response: Product
- name: Orders API
version: v1
base_path: /api/v1/orders
endpoints:
- method: POST
path: /
used: false
impact: no change
description: Create new order
auth_required: true
request: CreateOrder
response: Order
- method: GET
path: /{id}
used: true
impact: no change
description: Get order by ID
auth_required: true
response: Order
- name: Dynamic navigation
specification: "https://apicuriows.shaun.sku61.com/sharing/b50006fc-510a-466c-bfa7-3ba808f52d47?content=true"
specification_include: false
base_path: /api/dyna_menu
consumed:
- name: Payment Gateway
provider: Stripe
base_url: "https://api{environment}.stripe.com/v1"
endpoints:
- method: POST
path: /v1/payment_intents
description: Create payment intent
- name: Email Service
provider: SendGrid
base_url: "https://api{environment}.sendgrid.com/v2"
endpoints:
- method: POST
path: /v3/mail/send
description: Send transactional email

View File

@ -0,0 +1,44 @@
spec_type: telemetry
name: Observability Configuration
version: "1.0"
metrics:
provider: prometheus
endpoint: /metrics
custom_metrics:
- name: http_requests_total
type: counter
labels: [method, path, status]
description: Total HTTP requests
- name: order_processing_duration
type: histogram
buckets: [0.1, 0.5, 1, 2, 5]
description: Order processing time in seconds
- name: active_sessions
type: gauge
description: Current number of active user sessions
traces:
provider: jaeger
sampling_rate: 0.1
propagation: w3c
spans:
- name: http_request
attributes: [method, path, user_id]
- name: database_query
attributes: [query_type, table]
- name: external_api_call
attributes: [service, endpoint]
instrumentation:
auto_instrument:
- http
- database
- redis
custom_spans:
- order_processing
- payment_processing

View File

@ -0,0 +1,20 @@
{
"spec_type": "business_requirements",
"name": "JSON Test Application",
"version": "1.0",
"description": "Testing JSON specification format",
"requirements": [
{
"id": "BR-JSON-001",
"title": "JSON Support",
"description": "System must support JSON specification files",
"priority": "high"
}
],
"features": [
{
"name": "JSON Parsing",
"components": ["Parser", "Validator", "Generator"]
}
]
}