# hicham-4r/smartfactory-dss architecture

> Architecture diagram of the GitHub repository hicham-4r/smartfactory-dss, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hicham-4r/smartfactory-dss
- Repository: https://github.com/hicham-4r/smartfactory-dss

## Overview

SmartFactory DSS combines a Laravel manufacturing decision-support application with a separate FastAPI ML service. The principal workflow is a user request through Laravel to verified inference and back into dashboards or secure reports; ERP synchronization supplies operational context, while guarded LLM explanations are an optional branch. The graph preserves production, maintenance, quality, security, and observability capabilities documented in the README. Sampled source confirms selected query, inference-client, and reporting behavior; some broader subsystem links rely on README documentation rather than inspected implementation.

Main entry points: [`laravel-app`](https://github.com/hicham-4r/smartfactory-dss/tree/main/laravel-app) (Laravel DSS), [`laravel-app/app/Http/Controllers/AI/AiInsightsController.php`](https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Http/Controllers/AI/AiInsightsController.php) (AI Insights requests), [`laravel-app/app/Console/Commands/ErpSyncCommand.php`](https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Console/Commands/ErpSyncCommand.php) (ERP synchronization), [`deploy/kubernetes/monitoring`](https://github.com/hicham-4r/smartfactory-dss/tree/main/deploy/kubernetes/monitoring) (Prometheus)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operations["Manufacturing Operations"]
  node_laravel["Laravel DSS"]
  node_production["Production workflows"]
  node_dashboards["Dashboards and KPIs"]
  node_quality["Quality workflows"]
  node_dss_db[("DSS database")]
end

subgraph group_ai["AI Decision Support"]
  node_inference_ui["AI Insights requests"]
  node_feature_source["Inference source features"]
  node_ai_client["FastAPI inference client"]
  node_fastapi_routes["Inference API routes<br/>[inference.py]"]
  node_inference_service["Inference service<br/>[service.py]"]
  node_model_registry["Model registry<br/>[registry.py]"]
  node_preprocessing["Dataset preprocessing<br/>[pipeline.py]"]
  node_feature_engineering["Feature engineering<br/>[pipeline.py]"]
  node_explanations["Guarded explanations<br/>[service.py]"]
  node_reports["AI report exports"]
end

subgraph group_erp["ERP Integration"]
  node_erp_sync["ERP synchronization<br/>[ErpSyncCommand.php]"]
  node_erp_monitor["ERP sync monitoring"]
  node_sage["Sage ERP simulator"]
  node_erp_db[("ERP database")]
end

subgraph group_platform["Access and Observability"]
  node_gateway["HTTPS gateway"]
  node_auth["Authentication and RBAC"]
  node_prometheus["Prometheus"]
  node_grafana["Grafana"]
end

node_browser(("Browser user"))
node_ollama["Ollama"]

node_browser -->|"HTTPS requests"| node_gateway
node_gateway -->|"routes requests"| node_laravel
node_browser -->|"signs in"| node_auth
node_laravel -->|"serves workflows"| node_production
node_laravel -->|"builds views"| node_dashboards
node_laravel -->|"serves workflows"| node_quality
node_production -->|"reads and writes"| node_dss_db
node_dashboards -->|"queries metrics"| node_dss_db
node_quality -->|"reads and writes"| node_dss_db
node_laravel -->|"runs synchronization"| node_erp_sync
node_erp_sync -->|"syncs records"| node_sage
node_sage -->|"stores simulated data"| node_erp_db
node_erp_sync -->|"persists sync state"| node_dss_db
node_laravel -->|"queries sync health"| node_erp_monitor
node_erp_monitor -->|"reads sync runs"| node_dss_db
node_laravel -->|"serves AI requests"| node_inference_ui
node_inference_ui -->|"prepares features"| node_feature_source
node_inference_ui -->|"requests inference"| node_ai_client
node_ai_client -->|"sends contract"| node_fastapi_routes
node_fastapi_routes -->|"dispatches inference"| node_inference_service
node_inference_service -->|"loads models"| node_model_registry
node_preprocessing -->|"prepares datasets"| node_feature_engineering
node_inference_ui -->|"exports saved results"| node_reports
node_inference_ui -.->|"requests narrative"| node_explanations
node_explanations -.->|"generates explanation"| node_ollama
node_prometheus -->|"scrapes metrics"| node_laravel
node_prometheus -->|"scrapes private metrics"| node_gateway
node_grafana -->|"queries metrics"| node_prometheus

click node_laravel "https://github.com/hicham-4r/smartfactory-dss/tree/main/laravel-app"
click node_production "https://github.com/hicham-4r/smartfactory-dss/tree/main/laravel-app/app/Http/Controllers/Production"
click node_dashboards "https://github.com/hicham-4r/smartfactory-dss/tree/main/laravel-app/app/Services/Dashboard"
click node_quality "https://github.com/hicham-4r/smartfactory-dss/tree/main/laravel-app/app/Http/Controllers/Analytics"
click node_erp_sync "https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Console/Commands/ErpSyncCommand.php"
click node_erp_monitor "https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Services/ERP/Monitoring/ErpMonitoringQueryService.php"
click node_sage "https://github.com/hicham-4r/smartfactory-dss/tree/main/sage-erp-simulator"
click node_inference_ui "https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Http/Controllers/AI/AiInsightsController.php"
click node_feature_source "https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Services/AI/Inference/EloquentAutomaticInferenceSourceRepository.php"
click node_ai_client "https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Services/AI/Inference/FastApiAiInferenceClient.php"
click node_fastapi_routes "https://github.com/hicham-4r/smartfactory-dss/blob/main/fastapi-ai/app/api/routes/inference.py"
click node_inference_service "https://github.com/hicham-4r/smartfactory-dss/blob/main/fastapi-ai/app/inference/service.py"
click node_model_registry "https://github.com/hicham-4r/smartfactory-dss/blob/main/fastapi-ai/app/inference/registry.py"
click node_preprocessing "https://github.com/hicham-4r/smartfactory-dss/blob/main/fastapi-ai/app/preprocessing/pipeline.py"
click node_feature_engineering "https://github.com/hicham-4r/smartfactory-dss/blob/main/fastapi-ai/app/features/pipeline.py"
click node_explanations "https://github.com/hicham-4r/smartfactory-dss/blob/main/fastapi-ai/app/llm/service.py"
click node_reports "https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Http/Controllers/Reports/AiInferenceReportController.php"
click node_auth "https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Services/Auth/SecureLoginService.php"
click node_prometheus "https://github.com/hicham-4r/smartfactory-dss/tree/main/deploy/kubernetes/monitoring"
click node_grafana "https://github.com/hicham-4r/smartfactory-dss/tree/main/deploy/kubernetes/monitoring"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_laravel,node_production,node_dashboards,node_quality,node_dss_db,node_browser toneBlue
class node_inference_ui,node_feature_source,node_ai_client,node_fastapi_routes,node_inference_service,node_model_registry,node_preprocessing,node_feature_engineering,node_explanations,node_reports toneAmber
class node_erp_sync,node_erp_monitor,node_sage,node_erp_db toneMint
class node_gateway,node_auth,node_prometheus,node_grafana toneRose
class node_ollama toneIndigo
```

## Components

### Manufacturing Operations

- [Laravel DSS](https://github.com/hicham-4r/smartfactory-dss/tree/main/laravel-app): `laravel-app`
- [Production workflows](https://github.com/hicham-4r/smartfactory-dss/tree/main/laravel-app/app/Http/Controllers/Production): `laravel-app/app/Http/Controllers/Production`
- [Dashboards and KPIs](https://github.com/hicham-4r/smartfactory-dss/tree/main/laravel-app/app/Services/Dashboard): `laravel-app/app/Services/Dashboard`
- [Quality workflows](https://github.com/hicham-4r/smartfactory-dss/tree/main/laravel-app/app/Http/Controllers/Analytics): `laravel-app/app/Http/Controllers/Analytics`
- **DSS database**

### AI Decision Support

- [AI Insights requests](https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Http/Controllers/AI/AiInsightsController.php): `laravel-app/app/Http/Controllers/AI/AiInsightsController.php`
- [Inference source features](https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Services/AI/Inference/EloquentAutomaticInferenceSourceRepository.php): `laravel-app/app/Services/AI/Inference/EloquentAutomaticInferenceSourceRepository.php`
- [FastAPI inference client](https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Services/AI/Inference/FastApiAiInferenceClient.php): `laravel-app/app/Services/AI/Inference/FastApiAiInferenceClient.php`
- [Inference API routes](https://github.com/hicham-4r/smartfactory-dss/blob/main/fastapi-ai/app/api/routes/inference.py): `fastapi-ai/app/api/routes/inference.py`
- [Inference service](https://github.com/hicham-4r/smartfactory-dss/blob/main/fastapi-ai/app/inference/service.py): `fastapi-ai/app/inference/service.py`
- [Model registry](https://github.com/hicham-4r/smartfactory-dss/blob/main/fastapi-ai/app/inference/registry.py): `fastapi-ai/app/inference/registry.py`
- [Dataset preprocessing](https://github.com/hicham-4r/smartfactory-dss/blob/main/fastapi-ai/app/preprocessing/pipeline.py): `fastapi-ai/app/preprocessing/pipeline.py`
- [Feature engineering](https://github.com/hicham-4r/smartfactory-dss/blob/main/fastapi-ai/app/features/pipeline.py): `fastapi-ai/app/features/pipeline.py`
- [Guarded explanations](https://github.com/hicham-4r/smartfactory-dss/blob/main/fastapi-ai/app/llm/service.py): `fastapi-ai/app/llm/service.py`
- [AI report exports](https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Http/Controllers/Reports/AiInferenceReportController.php): `laravel-app/app/Http/Controllers/Reports/AiInferenceReportController.php`

### ERP Integration

- [ERP synchronization](https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Console/Commands/ErpSyncCommand.php): `laravel-app/app/Console/Commands/ErpSyncCommand.php`
- [ERP sync monitoring](https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Services/ERP/Monitoring/ErpMonitoringQueryService.php): `laravel-app/app/Services/ERP/Monitoring/ErpMonitoringQueryService.php`
- [Sage ERP simulator](https://github.com/hicham-4r/smartfactory-dss/tree/main/sage-erp-simulator): `sage-erp-simulator`
- **ERP database**

### Access and Observability

- **HTTPS gateway**
- [Authentication and RBAC](https://github.com/hicham-4r/smartfactory-dss/blob/main/laravel-app/app/Services/Auth/SecureLoginService.php): `laravel-app/app/Services/Auth/SecureLoginService.php`
- [Prometheus](https://github.com/hicham-4r/smartfactory-dss/tree/main/deploy/kubernetes/monitoring): `deploy/kubernetes/monitoring`
- [Grafana](https://github.com/hicham-4r/smartfactory-dss/tree/main/deploy/kubernetes/monitoring): `deploy/kubernetes/monitoring`

### Other components

- **Browser user**
- **Ollama**

## Connections

- Browser user → HTTPS gateway: HTTPS requests
- HTTPS gateway → Laravel DSS: routes requests
- Browser user → Authentication and RBAC: signs in
- Laravel DSS → Production workflows: serves workflows
- Laravel DSS → Dashboards and KPIs: builds views
- Laravel DSS → Quality workflows: serves workflows
- Production workflows → DSS database: reads and writes
- Dashboards and KPIs → DSS database: queries metrics
- Quality workflows → DSS database: reads and writes
- Laravel DSS → ERP synchronization: runs synchronization
- ERP synchronization → Sage ERP simulator: syncs records
- Sage ERP simulator → ERP database: stores simulated data
- ERP synchronization → DSS database: persists sync state
- Laravel DSS → ERP sync monitoring: queries sync health
- ERP sync monitoring → DSS database: reads sync runs
- Laravel DSS → AI Insights requests: serves AI requests
- AI Insights requests → Inference source features: prepares features
- AI Insights requests → FastAPI inference client: requests inference
- FastAPI inference client → Inference API routes: sends contract
- Inference API routes → Inference service: dispatches inference
- Inference service → Model registry: loads models
- Dataset preprocessing → Feature engineering: prepares datasets
- AI Insights requests → AI report exports: exports saved results
- AI Insights requests → Guarded explanations: requests narrative
- Guarded explanations → Ollama: generates explanation
- Prometheus → Laravel DSS: scrapes metrics
- Prometheus → HTTPS gateway: scrapes private metrics
- Grafana → Prometheus: queries metrics
