# shamil3923/carbon-footprint-monitoring-platform architecture

> Architecture diagram of the GitHub repository shamil3923/carbon-footprint-monitoring-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shamil3923/carbon-footprint-monitoring-platform
- Repository: https://github.com/shamil3923/carbon-footprint-monitoring-platform

## Overview

#### 1. Purpose and Active System Shape
CFMS is a carbon-footprint management system organized as a React frontend, a Node.js BFF, and independently deployable domain and emission-calculation services. The apparent current implementation is under `CFMS_Frontend`, `CFMS_BFF`, and `CFMS_Backend`; `CFMS_Backend_Old` contains predecessor gateway, monolith, and service implementations.

#### 2. Client Application
The Vite/React SPA provides authentication, dashboard, and operational management workflows for customers, vehicles, vendors, vendor supplies, and carbon-emission evaluation. Its API boundary is centralized in:
- `CFMS_Frontend/src/main.jsx`
- `CFMS_Frontend/src/App.jsx`
- `CFMS_Frontend/src/Api.jsx`
- `CFMS_Frontend/src/utils/axiosInstance.js`

Feature pages compose management forms and tables; the evaluation input stage is `CFMS_Frontend/src/forms/CarbonEmissionEvaluationForm.jsx`.

#### 3. BFF and Edge Boundary
The Node.js BFF is the client-facing HTTP entry point. It applies authentication and error middleware, exposes auth plus domain route groups, resolves backend instances through Eureka, and contains AWS-related configuration:
- `CFMS_BFF/index.js`
- `CFMS_BFF/middleware/auth.js`
- `CFMS_BFF/routes/backend.js`
- `CFMS_BFF/utils/serviceDiscovery.js`

Requests flow SPA → BFF routes (`auth`, `customer`, `vehicle`, `vendor`, `supply`, `evaluation`) → discovered backend service. This layer is the principal API aggregation/routing and authorization boundary.

#### 4. Registry and CRUD Domain Services
A Spring Boot service registry supports discovery for the BFF and Java services:
- `CFMS_Backend/Service-Registry-CFMS/src/main/java/org/cfms/serviceregistrycfms/ServiceRegistryCfmsApplication.java`
- `CFMS_Backend/Service-Registry-CFMS/src/main/resources/application.properties`

Customer, vehicle, and vendor services own their respective JPA entities, repositories, DTOs, REST controllers, and service-layer logic:
- `CFMS_Backend/Customer-Service-CFMS/src/main/java/org/cfms/customerservicecfms/controller/CustomerController.java`
- `CFMS_Backend/Vehicle-Service-CFMS/src/main/java/org/cfms/vehicleservicecfms/controller/VehicleController.java`
- `CFMS_Backend/Vendor-Service-CFMS/src/main/java/org/cfms/vendorservicecfms/controller/VendorController.java`

Vendor additionally owns production-matrix and vendor-product/supply reference data.

#### 5. Supply and Evaluation Orchestrator
The CO2e Evaluation service is the core workflow owner. It persists supplies, supply items, evaluations, and results, while orchestrating information from customer, vehicle, vendor, production-emission, and transportation-emission dependencies:
- `CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/controller/EvaluationController.java`
- `CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/service/implementation/EvaluationServiceImple.java`
- `CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/service/implementation/ProductionEmissionServiceClient.java`

Primary evaluation flow: accept evaluation/supply data → retrieve customer/vendor/vehicle context and production matrix → invoke production and transportation emission services → calculate/store `Result` associated with `Evaluation` and supply data.

#### 6. ML Emission Services
Two Python services package trained model artifacts behind deployable application entry points:
- `CFMS_Backend/Transportation-Emission-CFMS/main.py`
- `CFMS_Backend/Transportation-Emission-CFMS/Transportation_Model.pkl`
- `CFMS_Backend/Livestock-Emission-CFMS/main.py`
- `CFMS_Backend/Livestock-Emission-CFMS/svr_model.pkl`

Both include Google App Engine deployment descriptors (`app.yaml`). Transportation estimation is explicitly consumed by the evaluation orchestrator; livestock estimation is present as a separate model-serving capability.

#### 7. Runtime and Persistence Boundaries
Java services are Maven/Spring Boot applications with per-service runtime configuration in `application.properties`; their controller → service → repository structure indicates separately owned persistence models. Node.js runs the BFF; React/Vite runs the frontend; Python runs model-serving services. Eureka is the identified service-discovery infrastructure, while AWS configuration exists at the BFF edge and Google App Engine manifests exist for ML deployments.

Main entry points: [`CFMS_BFF/routes/backend.js`](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_BFF/routes/backend.js) (Backend Routes), [`CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/service/implementation/EvaluationServiceImple.java`](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/service/implementation/EvaluationServiceImple.java) (Evaluation Workflow), [`CFMS_Backend/Service-Registry-CFMS/src/main/java/org/cfms/serviceregistrycfms/ServiceRegistryCfmsApplication.java`](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Service-Registry-CFMS/src/main/java/org/cfms/serviceregistrycfms/ServiceRegistryCfmsApplication.java) (Eureka Registry), [`CFMS_BFF/index.js`](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_BFF/index.js) (Node.js BFF)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React Client"]
  node_spa["React/Vite SPA<br/>client app<br/>[App.jsx]"]
  node_api["API Client<br/>HTTP client<br/>[Api.jsx]"]
  node_evaluation_form["Evaluation Form<br/>feature UI"]
end

subgraph group_edge["BFF Edge"]
  node_bff["Node.js BFF<br/>API gateway<br/>[index.js]"]
  node_auth["Auth Middleware<br/>[auth.js]"]
  node_backend_routes["Backend Routes<br/>route proxy<br/>[backend.js]"]
  node_discovery_client["Discovery Client<br/>service resolver"]
end

subgraph group_services["Spring Services"]
  node_registry{{"Eureka Registry<br/>service registry"}}
  node_customer["Customer Service<br/>Spring CRUD service"]
  node_vehicle["Vehicle Service<br/>Spring CRUD service"]
  node_vendor["Vendor Service<br/>Spring CRUD service"]
  node_evaluation_api["Evaluation Controller<br/>Spring REST API"]
  node_evaluation_workflow["Evaluation Workflow<br/>orchestration service"]
  node_production_client["Production Emission Client<br/>service client"]
end

subgraph group_ml["Model Services"]
  node_transport_ml["Transportation Emissions<br/>Python model service<br/>[main.py]"]
  node_livestock_ml["Livestock Emissions<br/>Python model service<br/>[main.py]"]
end

node_spa -->|"uses"| node_api
node_evaluation_form -->|"submits evaluation"| node_api
node_api -->|"HTTP"| node_bff
node_bff -->|"applies"| node_auth
node_bff -->|"routes"| node_backend_routes
node_backend_routes -->|"resolves target"| node_discovery_client
node_discovery_client -->|"queries"| node_registry
node_backend_routes -->|"customer requests"| node_customer
node_backend_routes -->|"vehicle requests"| node_vehicle
node_backend_routes -->|"vendor and supply requests"| node_vendor
node_backend_routes -->|"evaluation requests"| node_evaluation_api
node_evaluation_api -->|"delegates"| node_evaluation_workflow
node_evaluation_workflow -->|"retrieves customer context"| node_customer
node_evaluation_workflow -->|"retrieves vehicle context"| node_vehicle
node_evaluation_workflow -->|"retrieves vendor and matrix data"| node_vendor
node_evaluation_workflow -->|"requests production emissions"| node_production_client
node_evaluation_workflow -->|"requests transport emissions"| node_transport_ml
node_customer -.->|"registers"| node_registry
node_vehicle -.->|"registers"| node_registry
node_vendor -.->|"registers"| node_registry
node_evaluation_api -.->|"registers"| node_registry

click node_spa "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Frontend/src/App.jsx"
click node_api "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Frontend/src/Api.jsx"
click node_evaluation_form "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Frontend/src/forms/CarbonEmissionEvaluationForm.jsx"
click node_bff "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_BFF/index.js"
click node_auth "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_BFF/middleware/auth.js"
click node_backend_routes "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_BFF/routes/backend.js"
click node_discovery_client "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_BFF/utils/serviceDiscovery.js"
click node_registry "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Service-Registry-CFMS/src/main/java/org/cfms/serviceregistrycfms/ServiceRegistryCfmsApplication.java"
click node_customer "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Customer-Service-CFMS/src/main/java/org/cfms/customerservicecfms/controller/CustomerController.java"
click node_vehicle "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Vehicle-Service-CFMS/src/main/java/org/cfms/vehicleservicecfms/controller/VehicleController.java"
click node_vendor "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Vendor-Service-CFMS/src/main/java/org/cfms/vendorservicecfms/controller/VendorController.java"
click node_evaluation_api "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/controller/EvaluationController.java"
click node_evaluation_workflow "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/service/implementation/EvaluationServiceImple.java"
click node_production_client "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/service/implementation/ProductionEmissionServiceClient.java"
click node_transport_ml "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Transportation-Emission-CFMS/main.py"
click node_livestock_ml "https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Livestock-Emission-CFMS/main.py"

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_spa,node_api,node_evaluation_form toneBlue
class node_bff,node_auth,node_backend_routes,node_discovery_client toneAmber
class node_registry,node_customer,node_vehicle,node_vendor,node_evaluation_api,node_evaluation_workflow,node_production_client toneMint
class node_transport_ml,node_livestock_ml toneRose
```

## Components

### React Client

- [React/Vite SPA](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Frontend/src/App.jsx): client app · Authentication, management, and evaluation workflows. · `CFMS_Frontend/src/App.jsx`
- [API Client](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Frontend/src/Api.jsx): HTTP client · `CFMS_Frontend/src/Api.jsx`
- [Evaluation Form](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Frontend/src/forms/CarbonEmissionEvaluationForm.jsx): feature UI · `CFMS_Frontend/src/forms/CarbonEmissionEvaluationForm.jsx`

### BFF Edge

- [Node.js BFF](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_BFF/index.js): API gateway · Client-facing routing, aggregation, and authorization boundary. · `CFMS_BFF/index.js`
- [Auth Middleware](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_BFF/middleware/auth.js): middleware · `CFMS_BFF/middleware/auth.js`
- [Backend Routes](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_BFF/routes/backend.js): route proxy · Forwards auth and domain requests to discovered services. · `CFMS_BFF/routes/backend.js`
- [Discovery Client](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_BFF/utils/serviceDiscovery.js): service resolver · `CFMS_BFF/utils/serviceDiscovery.js`

### Spring Services

- [Eureka Registry](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Service-Registry-CFMS/src/main/java/org/cfms/serviceregistrycfms/ServiceRegistryCfmsApplication.java): service registry · Discovery endpoint for the BFF and Java services. · `CFMS_Backend/Service-Registry-CFMS/src/main/java/org/cfms/serviceregistrycfms/ServiceRegistryCfmsApplication.java`
- [Customer Service](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Customer-Service-CFMS/src/main/java/org/cfms/customerservicecfms/controller/CustomerController.java): Spring CRUD service · Owns customer data and API. · `CFMS_Backend/Customer-Service-CFMS/src/main/java/org/cfms/customerservicecfms/controller/CustomerController.java`
- [Vehicle Service](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Vehicle-Service-CFMS/src/main/java/org/cfms/vehicleservicecfms/controller/VehicleController.java): Spring CRUD service · Owns vehicle data and API. · `CFMS_Backend/Vehicle-Service-CFMS/src/main/java/org/cfms/vehicleservicecfms/controller/VehicleController.java`
- [Vendor Service](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Vendor-Service-CFMS/src/main/java/org/cfms/vendorservicecfms/controller/VendorController.java): Spring CRUD service · Owns vendors, products, supplies, and production matrix reference data. · `CFMS_Backend/Vendor-Service-CFMS/src/main/java/org/cfms/vendorservicecfms/controller/VendorController.java`
- [Evaluation Controller](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/controller/EvaluationController.java): Spring REST API · `CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/controller/EvaluationController.java`
- [Evaluation Workflow](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/service/implementation/EvaluationServiceImple.java): orchestration service · Persists supply, evaluation, and result data while coordinating emission calculations. · `CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/service/implementation/EvaluationServiceImple.java`
- [Production Emission Client](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/service/implementation/ProductionEmissionServiceClient.java): service client · `CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/service/implementation/ProductionEmissionServiceClient.java`

### Model Services

- [Transportation Emissions](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Transportation-Emission-CFMS/main.py): Python model service · Serves transportation estimates from a trained model. · `CFMS_Backend/Transportation-Emission-CFMS/main.py`
- [Livestock Emissions](https://github.com/shamil3923/carbon-footprint-monitoring-platform/blob/main/CFMS_Backend/Livestock-Emission-CFMS/main.py): Python model service · Independent livestock model-serving capability. · `CFMS_Backend/Livestock-Emission-CFMS/main.py`

## Connections

- React/Vite SPA → API Client: uses
- Evaluation Form → API Client: submits evaluation
- API Client → Node.js BFF: HTTP
- Node.js BFF → Auth Middleware: applies
- Node.js BFF → Backend Routes: routes
- Backend Routes → Discovery Client: resolves target
- Discovery Client → Eureka Registry: queries
- Backend Routes → Customer Service: customer requests
- Backend Routes → Vehicle Service: vehicle requests
- Backend Routes → Vendor Service: vendor and supply requests
- Backend Routes → Evaluation Controller: evaluation requests
- Evaluation Controller → Evaluation Workflow: delegates
- Evaluation Workflow → Customer Service: retrieves customer context
- Evaluation Workflow → Vehicle Service: retrieves vehicle context
- Evaluation Workflow → Vendor Service: retrieves vendor and matrix data
- Evaluation Workflow → Production Emission Client: requests production emissions
- Evaluation Workflow → Transportation Emissions: requests transport emissions
- Customer Service → Eureka Registry: registers
- Vehicle Service → Eureka Registry: registers
- Vendor Service → Eureka Registry: registers
- Evaluation Controller → Eureka Registry: registers
