// Neo4j initialization script for Turash MVP // This script creates the initial graph schema and indexes // Create constraints for uniqueness CREATE CONSTRAINT business_id IF NOT EXISTS FOR (b:Business) REQUIRE b.id IS UNIQUE; CREATE CONSTRAINT site_id IF NOT EXISTS FOR (s:Site) REQUIRE s.id IS UNIQUE; CREATE CONSTRAINT resource_flow_id IF NOT EXISTS FOR (r:ResourceFlow) REQUIRE r.id IS UNIQUE; CREATE CONSTRAINT user_id IF NOT EXISTS FOR (u:User) REQUIRE u.id IS UNIQUE; // Create indexes for performance CREATE INDEX business_email IF NOT EXISTS FOR (b:Business) ON (b.email); CREATE INDEX business_sector IF NOT EXISTS FOR (b:Business) ON (b.sector); CREATE INDEX site_business_id IF NOT EXISTS FOR (s:Site) ON (s.business_id); CREATE INDEX resource_flow_business_id IF NOT EXISTS FOR (r:ResourceFlow) ON (r.business_id); CREATE INDEX resource_flow_site_id IF NOT EXISTS FOR (r:ResourceFlow) ON (r.site_id); CREATE INDEX resource_flow_direction IF NOT EXISTS FOR (r:ResourceFlow) ON (r.direction); CREATE INDEX resource_flow_type IF NOT EXISTS FOR (r:ResourceFlow) ON (r.type); CREATE INDEX resource_flow_temperature IF NOT EXISTS FOR (r:ResourceFlow) ON (r.temperature_celsius); CREATE INDEX user_email IF NOT EXISTS FOR (u:User) ON (u.email); // Create some sample data for testing CREATE (b1:Business { id: "business-001", name: "Berlin Heat GmbH", email: "contact@berlinheat.de", sector: "35.30", description: "District heating provider", certifications: ["ISO 9001", "ISO 14001"], readiness_maturity: 4, trust_score: 0.85, created_at: datetime(), updated_at: datetime() }); CREATE (b2:Business { id: "business-002", name: "Green Brewery Berlin", email: "info@greenbrewery.de", sector: "11.05", description: "Craft brewery with waste heat utilization", certifications: ["ISO 14001"], readiness_maturity: 3, trust_score: 0.75, created_at: datetime(), updated_at: datetime() }); CREATE (b3:Business { id: "business-003", name: "Eco Hotel Berlin", email: "reservations@ecohotel.berlin", sector: "55.10", description: "Sustainable hotel with heat recovery", certifications: ["ISO 9001"], readiness_maturity: 3, trust_score: 0.70, created_at: datetime(), updated_at: datetime() }); // Create sites CREATE (s1:Site { id: "site-001", business_id: "business-001", name: "Main Heating Plant", address: "Hauptstraße 123, 10115 Berlin", latitude: 52.5200, longitude: 13.4050, created_at: datetime(), updated_at: datetime() }); CREATE (s2:Site { id: "site-002", business_id: "business-002", name: "Brewery Facility", address: "Braustraße 45, 10179 Berlin", latitude: 52.5230, longitude: 13.4120, created_at: datetime(), updated_at: datetime() }); CREATE (s3:Site { id: "site-003", business_id: "business-003", name: "Hotel Building", address: "Hotelweg 78, 10117 Berlin", latitude: 52.5180, longitude: 13.4080, created_at: datetime(), updated_at: datetime() }); // Create relationships MATCH (b1:Business {id: "business-001"}), (s1:Site {id: "site-001"}) CREATE (b1)-[:OPERATES_AT]->(s1); MATCH (b2:Business {id: "business-002"}), (s2:Site {id: "site-002"}) CREATE (b2)-[:OPERATES_AT]->(s2); MATCH (b3:Business {id: "business-003"}), (s3:Site {id: "site-003"}) CREATE (b3)-[:OPERATES_AT]->(s3); // Create resource flows CREATE (r1:ResourceFlow { id: "flow-001", business_id: "business-001", site_id: "site-001", direction: "output", type: "heat", quality: { temperature_celsius: 80.0, physical_state: "liquid", pressure_bar: 3.0, purity_percent: 95.0 }, quantity: { amount: 1000.0, unit: "kWh", temporal_unit: "per_hour" }, economic_data: { cost_out: 0.03, currency: "EUR" }, constraints: { max_distance_km: 5.0, regulatory_compliance: true }, precision_level: "measured", source_type: "device", availability_schedule: { monday: ["08:00-18:00"], tuesday: ["08:00-18:00"], wednesday: ["08:00-18:00"], thursday: ["08:00-18:00"], friday: ["08:00-18:00"], saturday: [], sunday: [] }, seasonality: ["all_year"], supply_pattern: "continuous", created_at: datetime(), updated_at: datetime() }); CREATE (r2:ResourceFlow { id: "flow-002", business_id: "business-002", site_id: "site-002", direction: "input", type: "heat", quality: { temperature_celsius: 60.0, physical_state: "liquid", pressure_bar: 2.0, purity_percent: 90.0 }, quantity: { amount: 200.0, unit: "kWh", temporal_unit: "per_hour" }, economic_data: { cost_in: 0.08, currency: "EUR" }, constraints: { max_distance_km: 3.0, regulatory_compliance: true }, precision_level: "estimated", source_type: "calculated", availability_schedule: { monday: ["06:00-22:00"], tuesday: ["06:00-22:00"], wednesday: ["06:00-22:00"], thursday: ["06:00-22:00"], friday: ["06:00-22:00"], saturday: ["08:00-20:00"], sunday: ["10:00-18:00"] }, seasonality: ["all_year"], supply_pattern: "continuous", created_at: datetime(), updated_at: datetime() }); CREATE (r3:ResourceFlow { id: "flow-003", business_id: "business-003", site_id: "site-003", direction: "input", type: "heat", quality: { temperature_celsius: 70.0, physical_state: "liquid", pressure_bar: 2.5, purity_percent: 92.0 }, quantity: { amount: 150.0, unit: "kWh", temporal_unit: "per_hour" }, economic_data: { cost_in: 0.06, currency: "EUR" }, constraints: { max_distance_km: 4.0, regulatory_compliance: true }, precision_level: "measured", source_type: "device", availability_schedule: { monday: ["00:00-24:00"], tuesday: ["00:00-24:00"], wednesday: ["00:00-24:00"], thursday: ["00:00-24:00"], friday: ["00:00-24:00"], saturday: ["00:00-24:00"], sunday: ["00:00-24:00"] }, seasonality: ["all_year"], supply_pattern: "continuous", created_at: datetime(), updated_at: datetime() }); // Create relationships between sites and resource flows MATCH (s1:Site {id: "site-001"}), (r1:ResourceFlow {id: "flow-001"}) CREATE (s1)-[:HOSTS]->(r1); MATCH (s2:Site {id: "site-002"}), (r2:ResourceFlow {id: "flow-002"}) CREATE (s2)-[:HOSTS]->(r2); MATCH (s3:Site {id: "site-003"}), (r3:ResourceFlow {id: "flow-003"}) CREATE (s3)-[:HOSTS]->(r3); // Create admin user CREATE (u1:User { id: "user-admin", email: "admin@turash.dev", password_hash: "$2a$10$example.hash.for.demo.purposes.only", role: "admin", created_at: datetime(), updated_at: datetime() });