turash/docs/concept/schemas/resource_flow.json
Damir Mukimov 000eab4740
Major repository reorganization and missing backend endpoints implementation
Repository Structure:
- Move files from cluttered root directory into organized structure
- Create archive/ for archived data and scraper results
- Create bugulma/ for the complete application (frontend + backend)
- Create data/ for sample datasets and reference materials
- Create docs/ for comprehensive documentation structure
- Create scripts/ for utility scripts and API tools

Backend Implementation:
- Implement 3 missing backend endpoints identified in gap analysis:
  * GET /api/v1/organizations/{id}/matching/direct - Direct symbiosis matches
  * GET /api/v1/users/me/organizations - User organizations
  * POST /api/v1/proposals/{id}/status - Update proposal status
- Add complete proposal domain model, repository, and service layers
- Create database migration for proposals table
- Fix CLI server command registration issue

API Documentation:
- Add comprehensive proposals.md API documentation
- Update README.md with Users and Proposals API sections
- Document all request/response formats, error codes, and business rules

Code Quality:
- Follow existing Go backend architecture patterns
- Add proper error handling and validation
- Match frontend expected response schemas
- Maintain clean separation of concerns (handler -> service -> repository)
2025-11-25 06:01:16 +01:00

365 lines
9.2 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://cityresourcegraph.com/schemas/resource_flow.json",
"title": "Resource Flow Entity",
"description": "Resource flow (input/output) representation",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "Unique resource flow identifier"
},
"business_id": {
"type": "string",
"format": "uuid",
"description": "Owning business"
},
"site_id": {
"type": "string",
"format": "uuid",
"description": "Physical site location"
},
"direction": {
"type": "string",
"enum": [
"input",
"output"
],
"description": "Resource flow direction"
},
"type": {
"type": "string",
"enum": [
"heat",
"water",
"steam",
"CO2",
"biowaste",
"cooling",
"logistics",
"materials",
"service"
],
"description": "Type of resource or service"
},
"quality": {
"type": "object",
"properties": {
"temperature_celsius": {
"type": "number",
"minimum": -273.15,
"maximum": 2000,
"description": "Temperature in Celsius (for thermal flows)"
},
"pressure_bar": {
"type": "number",
"minimum": 0,
"maximum": 1000,
"description": "Pressure in bar (for pressurized flows)"
},
"purity_pct": {
"type": "number",
"minimum": 0,
"maximum": 100,
"description": "Purity percentage"
},
"grade": {
"type": "string",
"maxLength": 100,
"description": "Quality grade (food-grade, industrial-grade, etc.)"
},
"hazardousness": {
"type": "boolean",
"description": "Hazardous material flag"
},
"composition": {
"type": "string",
"maxLength": 1000,
"description": "Chemical composition or ingredients"
},
"physical_state": {
"type": "string",
"enum": [
"solid",
"liquid",
"gas"
],
"description": "Physical state of the material"
}
},
"description": "Quality parameters of the resource flow"
},
"quantity": {
"type": "object",
"properties": {
"amount": {
"type": "number",
"minimum": 0,
"description": "Quantity amount"
},
"unit": {
"type": "string",
"enum": [
"kg",
"tonnes",
"m3",
"liters",
"kWh",
"MWh",
"GJ",
"hours",
"days",
"m2",
"m",
"barrels",
"cubic_feet"
],
"description": "Unit of measurement"
},
"temporal_unit": {
"type": "string",
"enum": [
"per_second",
"per_minute",
"per_hour",
"per_day",
"per_week",
"per_month",
"per_year",
"continuous"
],
"description": "Time period for the quantity"
},
"variability": {
"type": "number",
"minimum": 0,
"maximum": 1,
"description": "Coefficient of variation (0-1)"
}
},
"required": [
"amount",
"unit"
],
"description": "Quantity parameters of the resource flow"
},
"time_profile": {
"type": "object",
"properties": {
"availability": {
"type": "object",
"properties": {
"monday": {
"$ref": "#/$defs/timeRange"
},
"tuesday": {
"$ref": "#/$defs/timeRange"
},
"wednesday": {
"$ref": "#/$defs/timeRange"
},
"thursday": {
"$ref": "#/$defs/timeRange"
},
"friday": {
"$ref": "#/$defs/timeRange"
},
"saturday": {
"$ref": "#/$defs/timeRange"
},
"sunday": {
"$ref": "#/$defs/timeRange"
}
},
"description": "Weekly availability schedule"
},
"seasonality": {
"type": "array",
"items": {
"type": "string",
"enum": [
"january",
"february",
"march",
"april",
"may",
"june",
"july",
"august",
"september",
"october",
"november",
"december"
]
},
"uniqueItems": true,
"description": "Months when resource is available"
},
"supply_pattern": {
"type": "string",
"enum": [
"continuous",
"batch",
"seasonal",
"on_demand",
"irregular"
],
"description": "Supply pattern characteristics"
}
},
"description": "Temporal characteristics of the resource flow"
},
"economic_data": {
"type": "object",
"properties": {
"cost_in": {
"type": "number",
"minimum": 0,
"description": "Cost per unit for inputs (€)"
},
"cost_out": {
"type": "number",
"minimum": 0,
"description": "Selling price per unit for outputs (€)"
},
"waste_disposal_cost": {
"type": "number",
"minimum": 0,
"description": "Current waste disposal cost (€/unit)"
},
"primary_input_cost": {
"type": "number",
"minimum": 0,
"description": "Cost of primary input replacement (€/unit)"
},
"transportation_cost": {
"type": "number",
"minimum": 0,
"description": "Transportation cost (€/km)"
},
"cost_sharing_fraction": {
"type": "number",
"minimum": 0,
"maximum": 1,
"description": "Fraction of costs shared in symbiosis"
}
},
"description": "Economic parameters of the resource flow"
},
"constraints": {
"type": "object",
"properties": {
"max_distance_km": {
"type": "number",
"minimum": 0,
"maximum": 1000,
"description": "Maximum viable transport distance"
},
"requires_permit": {
"type": "boolean",
"description": "Requires regulatory permits"
},
"min_quality_threshold": {
"type": "string",
"maxLength": 500,
"description": "Minimum quality requirements for matching"
},
"regulatory_compliance": {
"type": "boolean",
"description": "Complies with relevant regulations"
}
},
"description": "Constraints and requirements for the resource flow"
},
"service_details": {
"type": "object",
"properties": {
"domain": {
"type": "string",
"maxLength": 255,
"description": "Service domain (maintenance, consulting, transport, inspection)"
},
"mobility": {
"type": "string",
"enum": [
"on_site",
"remote"
],
"description": "Whether service is performed on-site or remotely"
},
"capacity_h_per_month": {
"type": "number",
"minimum": 0,
"description": "Service capacity in hours per month"
},
"service_area_km": {
"type": "number",
"minimum": 0,
"description": "Service area radius in kilometers"
}
},
"description": "Additional details for service-type resource flows"
},
"precision_level": {
"type": "string",
"enum": [
"rough",
"estimated",
"measured"
],
"description": "Data precision level"
},
"source_type": {
"type": "string",
"enum": [
"declared",
"device",
"calculated"
],
"description": "Data source type"
},
"device_signature": {
"type": "string",
"maxLength": 255,
"description": "Cryptographic signature for verified device data"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"updated_at": {
"type": "string",
"format": "date-time"
}
},
"required": [
"id",
"business_id",
"site_id",
"direction",
"type"
],
"$defs": {
"timeRange": {
"type": "object",
"properties": {
"start": {
"type": "string",
"pattern": "^([01]?[0-9]|2[0-3]):[0-5][0-9]$",
"description": "Start time (HH:MM)"
},
"end": {
"type": "string",
"pattern": "^([01]?[0-9]|2[0-3]):[0-5][0-9]$",
"description": "End time (HH:MM)"
}
},
"required": [
"start",
"end"
]
}
},
"additionalProperties": false
}