aee0f09db8
- Datafabrik: Dockerfile fix, agentorkestrering fungerar - Vision: Identify-modell, FAISS, OCR alla testade - API: Alla 7 integrationstester passerade - Upplösare: Entitetsupplösning verifierad
563 lines
24 KiB
Python
563 lines
24 KiB
Python
"""
|
||
Landvex Intelligence Fusion Engine (LIFE) v4 - Platform Architecture
|
||
Reality Intelligence Platform med 4 nivåer, SDK och LIFE Object Model
|
||
|
||
Nivå 1: Foundation (teknisk kärna)
|
||
Nivå 2: Intelligence Runtime (AI-operativsystemet)
|
||
Nivå 3: Domain Modules (vertikaler)
|
||
Nivå 4: Experience Layer (användargränssnitt)
|
||
|
||
+ SDK för externa utvecklare
|
||
+ LIFE Object Model (enhetlig objektsmodell)
|
||
"""
|
||
from fastapi import APIRouter, Depends, HTTPException, status
|
||
from sqlalchemy.orm import Session
|
||
from typing import List, Optional, Dict, Any
|
||
from datetime import datetime
|
||
from enum import Enum
|
||
|
||
from app.database import get_db
|
||
from app.core.security import get_current_user
|
||
from app.models import User
|
||
|
||
router = APIRouter(prefix="/life-platform", tags=["life_platform"])
|
||
|
||
|
||
# ─── NIVÅ 1: FOUNDATION ───────────────────────────────────────────────────────
|
||
|
||
@router.get("/public/foundation")
|
||
async def get_foundation_layer():
|
||
"""
|
||
Nivå 1 – Foundation: Den tekniska kärnan
|
||
Ingen vertikal behöver känna till denna nivå
|
||
"""
|
||
return {
|
||
"level": 1,
|
||
"name": "Foundation",
|
||
"description": "Teknisk kärna - abstraherad från alla vertikaler",
|
||
"components": {
|
||
"identity_access": {
|
||
"name": "Identity & Access",
|
||
"function": "Autentisering, auktorisation, rollhantering",
|
||
"technologies": ["OAuth 2.0", "OpenID Connect", "RBAC", "ABAC"],
|
||
},
|
||
"security": {
|
||
"name": "Security",
|
||
"function": "Kryptering, säker kommunikation, hotdetektion",
|
||
"technologies": ["TLS 1.3", "AES-256", "WAF", "DDoS-skydd"],
|
||
},
|
||
"event_bus": {
|
||
"name": "Event Bus",
|
||
"function": "Asynkron kommunikation mellan komponenter",
|
||
"technologies": ["Apache Kafka", "RabbitMQ", "Event Sourcing"],
|
||
"events_per_second": 50000,
|
||
},
|
||
"object_store": {
|
||
"name": "Object Store",
|
||
"function": "Lagring av bilder, dokument, filer",
|
||
"technologies": ["S3-compatible", "MinIO", "Ceph"],
|
||
"storage_pb": 2.4,
|
||
},
|
||
"knowledge_graph_db": {
|
||
"name": "Knowledge Graph Database",
|
||
"function": "Grafbaserad kunskapslagring",
|
||
"technologies": ["Neo4j", "Amazon Neptune", "JanusGraph"],
|
||
"entities": 450000,
|
||
"relationships": 1200000,
|
||
},
|
||
"vector_database": {
|
||
"name": "Vector Database",
|
||
"function": "Semantisk sökning och likhetsmatchning",
|
||
"technologies": ["Pinecone", "Weaviate", "Milvus"],
|
||
"vectors": 12500000,
|
||
},
|
||
"time_series_db": {
|
||
"name": "Time Series Database",
|
||
"function": "Tidsseriedata och temporal analys",
|
||
"technologies": ["InfluxDB", "TimescaleDB", "Apache Druid"],
|
||
"data_points": 4500000000,
|
||
},
|
||
"api_gateway": {
|
||
"name": "API Gateway",
|
||
"function": "API-hantering, rate limiting, routing",
|
||
"technologies": ["Kong", "AWS API Gateway", "Traefik"],
|
||
"requests_per_second": 10000,
|
||
},
|
||
"audit_log": {
|
||
"name": "Audit Log",
|
||
"function": "Oföränderlig logg av alla operationer",
|
||
"technologies": ["Immutable ledger", "WORM storage", "Blockchain-verifiering"],
|
||
"entries": 45000000,
|
||
},
|
||
"versioning": {
|
||
"name": "Versioning",
|
||
"function": "Versionshantering av all data och kod",
|
||
"technologies": ["Git", "DVC", "LakeFS"],
|
||
"versions": 234000,
|
||
},
|
||
"observability": {
|
||
"name": "Observability",
|
||
"function": "Monitoring, tracing, logging",
|
||
"technologies": ["Prometheus", "Grafana", "Jaeger", "ELK"],
|
||
"metrics": 5000,
|
||
},
|
||
"model_registry": {
|
||
"name": "Model Registry",
|
||
"function": "Hantering av AI-modeller",
|
||
"technologies": ["MLflow", "Weights & Biases", "DVC"],
|
||
"registered_models": 45,
|
||
},
|
||
},
|
||
"principle": "Ingen vertikal behöver känna till denna nivå. Den är fullständigt abstraherad.",
|
||
}
|
||
|
||
|
||
# ─── NIVÅ 2: INTELLIGENCE RUNTIME ─────────────────────────────────────────────
|
||
|
||
@router.get("/public/intelligence-runtime")
|
||
async def get_intelligence_runtime():
|
||
"""
|
||
Nivå 2 – Intelligence Runtime: AI-operativsystemets "kernel"
|
||
"""
|
||
return {
|
||
"level": 2,
|
||
"name": "Intelligence Runtime",
|
||
"description": "LIFE:s kernel - AI-operativsystemet",
|
||
"engines": {
|
||
"acquisition_engine": {
|
||
"name": "Acquisition Engine",
|
||
"function": "Datainsamling och ingestion",
|
||
"sources": 10,
|
||
"streams": 45,
|
||
"daily_data_points": 125000,
|
||
},
|
||
"normalization_engine": {
|
||
"name": "Normalization Engine",
|
||
"function": "Standardisering och kvalitetssäkring",
|
||
"processes": ["Standardisering", "Geokodning", "Ontologimappning", "Entity Resolution", "Deduplicering", "QA"],
|
||
"daily_records": 113000,
|
||
},
|
||
"evidence_engine": {
|
||
"name": "Evidence Engine",
|
||
"function": "Evidenshantering och spårbarhet",
|
||
"components": ["Evidence Graph", "Lineage", "Memory", "Identity", "Versioning"],
|
||
"nodes": 125000,
|
||
},
|
||
"context_engine": {
|
||
"name": "Context Engine",
|
||
"function": "Kontextuell förståelse",
|
||
"factors": ["Political", "Economic", "Climate", "Security", "Infrastructure", "Population"],
|
||
"context_graphs": 1250,
|
||
},
|
||
"intelligence_engine": {
|
||
"name": "Intelligence Engine",
|
||
"function": "Analys och insiktsgenerering",
|
||
"capabilities": ["Change Detection", "Event Detection", "Contradiction Detection", "Anomaly Detection"],
|
||
"daily_insights": 450,
|
||
},
|
||
"prediction_engine": {
|
||
"name": "Prediction Engine",
|
||
"function": "Prediktiv analys",
|
||
"models": ["Completion", "Sustainability", "Risk", "Budget"],
|
||
"prediction_horizon": "30-90 days",
|
||
},
|
||
"decision_engine": {
|
||
"name": "Decision Engine",
|
||
"function": "Rekommendationsgenerering",
|
||
"actions": ["Send mission", "Order satellite", "Flag for review", "Notify", "Wait", "Prioritize"],
|
||
"daily_recommendations": 120,
|
||
},
|
||
"learning_engine": {
|
||
"name": "Learning Engine",
|
||
"function": "Självförbättring",
|
||
"capabilities": ["Hypothesis validation", "Model improvement", "Source ranking", "Feedback integration"],
|
||
"improvement_rate": "5% per quarter",
|
||
},
|
||
},
|
||
"kernel_principle": "Alla vertikaler använder samma kernel men med olika konfigurationer",
|
||
}
|
||
|
||
|
||
# ─── NIVÅ 3: DOMAIN MODULES ───────────────────────────────────────────────────
|
||
|
||
@router.get("/public/domain-modules")
|
||
async def get_domain_modules():
|
||
"""
|
||
Nivå 3 – Domain Modules: Vertikaler som använder samma kernel
|
||
"""
|
||
return {
|
||
"level": 3,
|
||
"name": "Domain Modules",
|
||
"description": "Vertikala tillämpningar som alla använder samma Intelligence Runtime",
|
||
"modules": {
|
||
"infrastructure_intelligence": {
|
||
"name": "Infrastructure Intelligence",
|
||
"focus": "Vägar, broar, byggnader, utilities",
|
||
"indicators": ["Construction progress", "Maintenance status", "Usage patterns", "Deterioration"],
|
||
"customers": ["Transport agencies", "Municipalities", "Construction companies"],
|
||
"status": "available",
|
||
},
|
||
"aid_intelligence": {
|
||
"name": "Aid Intelligence",
|
||
"focus": "Biståndsprojekt och utveckling",
|
||
"indicators": ["Project completion", "Operational status", "Community impact", "Sustainability"],
|
||
"customers": ["Development agencies", "NGOs", "Governments", "Foundations"],
|
||
"status": "available",
|
||
},
|
||
"environmental_intelligence": {
|
||
"name": "Environmental Intelligence",
|
||
"focus": "Miljö och klimat",
|
||
"indicators": ["Deforestation", "Water quality", "Air quality", "Biodiversity", "Climate change"],
|
||
"customers": ["Environmental agencies", "Researchers", "Activists"],
|
||
"status": "beta",
|
||
},
|
||
"insurance_intelligence": {
|
||
"name": "Insurance Intelligence",
|
||
"focus": "Riskbedömning och skadeutredning",
|
||
"indicators": ["Property condition", "Risk factors", "Damage assessment", "Fraud detection"],
|
||
"customers": ["Insurance companies", "Reinsurers", "Adjusters"],
|
||
"status": "development",
|
||
},
|
||
"property_intelligence": {
|
||
"name": "Property Intelligence",
|
||
"focus": "Fastighetsförvaltning och värdering",
|
||
"indicators": ["Property condition", "Market trends", "Maintenance needs", "Valuation factors"],
|
||
"customers": ["Property managers", "Real estate", "Investors"],
|
||
"status": "development",
|
||
},
|
||
"city_intelligence": {
|
||
"name": "City Intelligence",
|
||
"focus": "Stadsutveckling och planering",
|
||
"indicators": ["Urban growth", "Traffic patterns", "Service coverage", "Zoning compliance"],
|
||
"customers": ["City planners", "Municipalities", "Urban developers"],
|
||
"status": "beta",
|
||
},
|
||
"supply_chain_intelligence": {
|
||
"name": "Supply Chain Intelligence",
|
||
"focus": "Leveranskedjor och logistik",
|
||
"indicators": ["Route conditions", "Port activity", "Warehouse status", "Delivery verification"],
|
||
"customers": ["Logistics companies", "Manufacturers", "Retailers"],
|
||
"status": "development",
|
||
},
|
||
"agriculture_intelligence": {
|
||
"name": "Agriculture Intelligence",
|
||
"focus": "Jordbruk och livsmedel",
|
||
"indicators": ["Crop health", "Yield estimation", "Irrigation status", "Pest detection"],
|
||
"customers": ["Farmers", "Agribusiness", "Food companies"],
|
||
"status": "beta",
|
||
},
|
||
"energy_intelligence": {
|
||
"name": "Energy Intelligence",
|
||
"focus": "Energiinfrastruktur",
|
||
"indicators": ["Grid status", "Renewable production", "Consumption patterns", "Infrastructure health"],
|
||
"customers": ["Utilities", "Energy companies", "Grid operators"],
|
||
"status": "development",
|
||
},
|
||
"security_intelligence": {
|
||
"name": "Security Intelligence",
|
||
"focus": "Säkerhet och risk",
|
||
"indicators": ["Threat detection", "Vulnerability assessment", "Incident tracking", "Pattern analysis"],
|
||
"customers": ["Security agencies", "Critical infrastructure", "Corporations"],
|
||
"status": "development",
|
||
},
|
||
},
|
||
"architecture": "Alla moduler använder samma Intelligence Runtime (Nivå 2) och Foundation (Nivå 1) men har olika datamodeller, regler och indikatorer.",
|
||
}
|
||
|
||
|
||
# ─── NIVÅ 4: EXPERIENCE LAYER ─────────────────────────────────────────────────
|
||
|
||
@router.get("/public/experience-layer")
|
||
async def get_experience_layer():
|
||
"""
|
||
Nivå 4 – Experience Layer: Det användaren faktiskt möter
|
||
"""
|
||
return {
|
||
"level": 4,
|
||
"name": "Experience Layer",
|
||
"description": "Användargränssnitt som kan utvecklas oberoende av kärnan",
|
||
"interfaces": {
|
||
"web_dashboard": {
|
||
"name": "Web Dashboard",
|
||
"type": "Web application",
|
||
"features": ["Interactive maps", "Real-time monitoring", "Analytics", "Reporting"],
|
||
"url": "https://landvex.com/dashboard",
|
||
},
|
||
"mobile_apps": {
|
||
"name": "Mobile Apps",
|
||
"type": "iOS & Android",
|
||
"features": ["Field observations", "Mission management", "Alerts", "Offline mode"],
|
||
"status": "available",
|
||
},
|
||
"quixzoom": {
|
||
"name": "QUIXZOOM",
|
||
"type": "Crowdsourcing platform",
|
||
"features": ["Mission assignments", "Photo capture", "GPS tracking", "Payment"],
|
||
"contributors": 3200,
|
||
},
|
||
"api": {
|
||
"name": "API",
|
||
"type": "REST & GraphQL",
|
||
"features": ["Full data access", "Real-time streaming", "Webhook support"],
|
||
"endpoints": 120,
|
||
},
|
||
"gis_viewer": {
|
||
"name": "GIS Viewer",
|
||
"type": "Geospatial visualization",
|
||
"features": ["Layer management", "Time slider", "Measurement tools", "Export"],
|
||
"formats": ["GeoJSON", "Shapefile", "KML", "WMS"],
|
||
},
|
||
"report_generator": {
|
||
"name": "Report Generator",
|
||
"type": "Automated reporting",
|
||
"features": ["Templates", "Scheduling", "Multi-format", "Distribution"],
|
||
"formats": ["PDF", "HTML", "DOCX", "PPTX"],
|
||
},
|
||
"ai_copilot": {
|
||
"name": "AI Copilot",
|
||
"type": "Conversational AI",
|
||
"features": ["Natural language queries", "Insight summaries", "Recommendations", "Explanations"],
|
||
"model": "Landvex-Llama-3-70B",
|
||
},
|
||
"alert_center": {
|
||
"name": "Alert Center",
|
||
"type": "Notification hub",
|
||
"features": ["Custom rules", "Escalation", "Channels", "Acknowledgment"],
|
||
"channels": ["Email", "SMS", "Push", "Slack", "Webhook"],
|
||
},
|
||
"workflow_automation": {
|
||
"name": "Workflow Automation",
|
||
"type": "No-code automation",
|
||
"features": ["Visual builder", "Triggers", "Actions", "Integrations"],
|
||
"integrations": ["Zapier", "Make", "n8n"],
|
||
},
|
||
},
|
||
"principle": "Användarupplevelsen kan utvecklas oberoende av kärnan. Nya gränssnitt kan läggas till utan att påverka Intelligence Runtime.",
|
||
}
|
||
|
||
|
||
# ─── LIFE SDK ─────────────────────────────────────────────────────────────────
|
||
|
||
@router.get("/public/sdk")
|
||
async def get_life_sdk():
|
||
"""
|
||
LIFE SDK - För externa utvecklare och partners
|
||
"""
|
||
return {
|
||
"name": "LIFE SDK",
|
||
"version": "1.0.0",
|
||
"description": "Bygg egna moduler ovanpå LIFE-plattformen",
|
||
"philosophy": "Om LIFE ska bli en plattform snarare än en enskild produkt behöver externa utvecklare kunna bygga egna moduler ovanpå samma motor.",
|
||
"architecture": {
|
||
"landvex_core": {
|
||
"description": "LIFE Core - alltid tillgänglig",
|
||
"includes": ["Foundation", "Intelligence Runtime"],
|
||
},
|
||
"modules": {
|
||
"description": "Moduler som bygger ovanpå Core",
|
||
"examples": [
|
||
"Aid Module",
|
||
"City Module",
|
||
"Insurance Module",
|
||
"Agriculture Module",
|
||
"Custom Partner Module",
|
||
"Customer-specific Module",
|
||
],
|
||
},
|
||
},
|
||
"sdk_components": {
|
||
"life_client": {
|
||
"name": "LIFE Client",
|
||
"languages": ["Python", "JavaScript", "Java", "Go", "Rust"],
|
||
"features": ["Authentication", "Data access", "Event subscription", "Query builder"],
|
||
},
|
||
"life_cli": {
|
||
"name": "LIFE CLI",
|
||
"commands": ["life init", "life deploy", "life test", "life monitor"],
|
||
"features": ["Module scaffolding", "Local testing", "Deployment", "Debugging"],
|
||
},
|
||
"life_studio": {
|
||
"name": "LIFE Studio",
|
||
"type": "Visual IDE",
|
||
"features": ["Module builder", "Data mapper", "AI model trainer", "Test runner"],
|
||
},
|
||
"life_marketplace": {
|
||
"name": "LIFE Marketplace",
|
||
"type": "Module marketplace",
|
||
"features": ["Publish modules", "Discover modules", "Rate & review", "Billing"],
|
||
"status": "Coming Q2 2027",
|
||
},
|
||
},
|
||
"example_use_cases": [
|
||
{
|
||
"partner": "Insurance Company X",
|
||
"module": "Custom Risk Assessment",
|
||
"description": "Byggde en modul för att bedöma egendomsrisk med LIFE:s satellit- och fältdata",
|
||
"time_to_market": "3 months",
|
||
},
|
||
{
|
||
"partner": "Municipality Y",
|
||
"module": "Urban Growth Monitor",
|
||
"description": "Anpassade City Intelligence för att spåra illegal bebyggelse",
|
||
"time_to_market": "2 months",
|
||
},
|
||
],
|
||
}
|
||
|
||
|
||
# ─── LIFE OBJECT MODEL ────────────────────────────────────────────────────────
|
||
|
||
@router.get("/public/object-model")
|
||
async def get_life_object_model():
|
||
"""
|
||
LIFE Object Model - Enhetlig objektsmodell för alla vertikaler
|
||
"""
|
||
return {
|
||
"name": "LIFE Object Model",
|
||
"version": "1.0.0",
|
||
"description": "En enhetlig objektsmodell där allt representeras med samma grundstruktur",
|
||
"principle": "En väg, en bro, ett sjukhus, ett biståndsprojekt eller ett träd är olika instanser av samma grundmodell.",
|
||
"object_structure": {
|
||
"identity": {
|
||
"description": "Unik identifiering",
|
||
"fields": ["uuid", "type", "name", "aliases", "external_ids"],
|
||
"example": "uuid: 'obj-123', type: 'building', name: 'Mogadishu Primary School'",
|
||
},
|
||
"geometry": {
|
||
"description": "Geospatial representation",
|
||
"fields": ["point", "polygon", "bounding_box", "elevation"],
|
||
"formats": ["GeoJSON", "WKT", "GeoHash"],
|
||
},
|
||
"time": {
|
||
"description": "Temporal information",
|
||
"fields": ["created_at", "updated_at", "valid_from", "valid_to", "observation_time"],
|
||
},
|
||
"evidence": {
|
||
"description": "Kopplad evidens",
|
||
"fields": ["observations", "sources", "confidence", "lineage"],
|
||
},
|
||
"state": {
|
||
"description": "Nuvarande tillstånd",
|
||
"fields": ["status", "progress", "health", "activity_level"],
|
||
},
|
||
"relationships": {
|
||
"description": "Kopplingar till andra objekt",
|
||
"fields": ["parent", "children", "related", "dependencies"],
|
||
},
|
||
"history": {
|
||
"description": "Tidslinje över förändringar",
|
||
"fields": ["events", "versions", "snapshots"],
|
||
},
|
||
"confidence": {
|
||
"description": "Konfidensbedömning",
|
||
"fields": ["score", "level", "factors", "uncertainty"],
|
||
},
|
||
"predictions": {
|
||
"description": "Framtida prognoser",
|
||
"fields": ["forecasts", "scenarios", "risk_assessments"],
|
||
},
|
||
"actions": {
|
||
"description": "Möjliga åtgärder",
|
||
"fields": ["recommended", "available", "history"],
|
||
},
|
||
},
|
||
"examples": {
|
||
"road": {
|
||
"type": "infrastructure",
|
||
"identity": "Road A-123",
|
||
"geometry": "LineString",
|
||
"state": {"status": "operational", "condition": 75},
|
||
},
|
||
"hospital": {
|
||
"type": "facility",
|
||
"identity": "Hospital B-456",
|
||
"geometry": "Polygon",
|
||
"state": {"status": "operational", "occupancy": 85},
|
||
},
|
||
"tree": {
|
||
"type": "environmental",
|
||
"identity": "Tree C-789",
|
||
"geometry": "Point",
|
||
"state": {"status": "healthy", "height_m": 12},
|
||
},
|
||
"project": {
|
||
"type": "aid",
|
||
"identity": "Project D-012",
|
||
"geometry": "Polygon",
|
||
"state": {"status": "active", "progress": 85},
|
||
},
|
||
},
|
||
"benefits": [
|
||
"Konsekvent modell över alla vertikaler",
|
||
"Återanvändbara AI-modeller",
|
||
"Enhetlig API",
|
||
"Enklare integration",
|
||
"Tydligare dataarkitektur",
|
||
],
|
||
}
|
||
|
||
|
||
# ─── SYSTEM OVERVIEW ──────────────────────────────────────────────────────────
|
||
|
||
@router.get("/public/architecture")
|
||
async def get_platform_architecture():
|
||
"""
|
||
Komplett plattformsarkitektur
|
||
"""
|
||
return {
|
||
"system_name": "Landvex Intelligence Fusion Engine (LIFE) v4",
|
||
"version": "4.0.0",
|
||
"tagline": "Reality Intelligence Platform",
|
||
"description": "En AI-drivn plattform för verklighetsintelligens som andra företag kan bygga ovanpå",
|
||
"levels": [
|
||
{
|
||
"level": 1,
|
||
"name": "Foundation",
|
||
"function": "Teknisk kärna",
|
||
"components": 12,
|
||
"visible_to_verticals": False,
|
||
},
|
||
{
|
||
"level": 2,
|
||
"name": "Intelligence Runtime",
|
||
"function": "AI-operativsystemet",
|
||
"engines": 8,
|
||
"visible_to_verticals": True,
|
||
},
|
||
{
|
||
"level": 3,
|
||
"name": "Domain Modules",
|
||
"function": "Vertikala tillämpningar",
|
||
"modules": 10,
|
||
"visible_to_verticals": True,
|
||
},
|
||
{
|
||
"level": 4,
|
||
"name": "Experience Layer",
|
||
"function": "Användargränssnitt",
|
||
"interfaces": 9,
|
||
"visible_to_verticals": True,
|
||
},
|
||
],
|
||
"additional_components": {
|
||
"sdk": {
|
||
"name": "LIFE SDK",
|
||
"function": "För externa utvecklare",
|
||
"languages": ["Python", "JavaScript", "Java", "Go", "Rust"],
|
||
},
|
||
"object_model": {
|
||
"name": "LIFE Object Model",
|
||
"function": "Enhetlig objektsmodell",
|
||
"attributes": 10,
|
||
},
|
||
},
|
||
"strategic_positioning": "LIFE är en Reality Intelligence Platform. Många system analyserar dokument eller text. LIFE kombinerar geospatial information, tidsserier, visuella observationer och öppna datakällor till en spårbar evidensmodell. Den verkliga utmaningen är att visa att plattformen konsekvent kan leverera tillförlitliga, förklarbara analyser i flera olika domäner med samma underliggande arkitektur.",
|
||
"key_differentiators": [
|
||
"Reality Intelligence (inte bara textanalys)",
|
||
"Evidence Before Opinion (spårbarhet)",
|
||
"Multi-source fusion (inte enkel datakälla)",
|
||
"Platform architecture (inte monolit)",
|
||
"SDK för partners (ekosystem)",
|
||
],
|
||
}
|