How shamil3923/carbon-footprint-monitoring-platform works
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: backend.js Backend Routes · EvaluationServiceImple.java Evaluation Workflow · ServiceRegistryCfmsApplication.java Eureka Registry · index.js Node.js BFF
Components 16
React Client
- React/Vite SPA · Authentication, management, and evaluation workflows.
CFMS_Frontend/src/App.jsx - API Client
CFMS_Frontend/src/Api.jsx - Evaluation Form
CFMS_Frontend/src/forms/CarbonEmissionEvaluationForm.jsx
BFF Edge
- Node.js BFF · Client-facing routing, aggregation, and authorization boundary.
CFMS_BFF/index.js - Auth Middleware
CFMS_BFF/middleware/auth.js - Backend Routes · Forwards auth and domain requests to discovered services.
CFMS_BFF/routes/backend.js - Discovery Client
CFMS_BFF/utils/serviceDiscovery.js
Spring Services
- Eureka Registry · Discovery endpoint for the BFF and Java services.
CFMS_Backend/Service-Registry-CFMS/src/main/java/org/cfms/serviceregistrycfms/ServiceRegistryCfmsApplication.java - Customer Service · Owns customer data and API.
CFMS_Backend/Customer-Service-CFMS/src/main/java/org/cfms/customerservicecfms/controller/CustomerController.java - Vehicle Service · Owns vehicle data and API.
CFMS_Backend/Vehicle-Service-CFMS/src/main/java/org/cfms/vehicleservicecfms/controller/VehicleController.java - Vendor 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
CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/controller/EvaluationController.java - Evaluation Workflow · 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
CFMS_Backend/CO2e-Evaluation-CFMS/src/main/java/org/cfms/co2eevaluationcfms/service/implementation/ProductionEmissionServiceClient.java
Model Services
- Transportation Emissions · Serves transportation estimates from a trained model.
CFMS_Backend/Transportation-Emission-CFMS/main.py - Livestock Emissions · Independent livestock model-serving capability.
CFMS_Backend/Livestock-Emission-CFMS/main.py
Connections 21
- 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