This is the backend server for the CarbonScope Frontend.
It integrates with ClimateTRACE for data and Google Gemini for AI-powered insights.
Report Bug
·
Request Feature
The CarbonScope Backend is a robust RESTful API that powers the CarbonScope platform. Beyond standard data processing, it leverages Generative AI to analyze complex emission data and provide actionable summaries.
Related Repository:
- 🖥️ Frontend: https://github.com/thughari/carbon-scope (Angular + Tailwind CSS)
- 🌍 ClimateTRACE Integration: Fetches real-time global emission data filtered by sector, country, and gas type.
- 🤖 AI-Powered Insights: Uses Google Gemini 2.0 Flash to analyze emission trends and generate human-readable environmental impact reports.
- 🔐 CORS Configured: Pre-configured to work securely with the frontend hosted on GitHub Pages (
thughari.github.io) and Localhost. - 🐳 Dockerized: Optimized multi-stage Docker build for easy deployment.
- Language: Java 21
- Framework: Spring Boot 3
- AI Model: Google Gemini 2.0 Flash
- Data Source: ClimateTRACE API
- Containerization: Docker
To run this application, you must provide a Google Gemini API Key.
Visit Google AI Studio to generate a free API key.
You can set the key in src/main/resources/application-dev.properties (for local dev) or pass it as an environment variable.
Option A: properties file (Local Dev)
Open src/main/resources/application-dev.properties:
spring.application.name=carbonscope
# AI Configuration
GEMINI_API_KEY=YOUR_ACTUAL_API_KEY_HERE
gemini.model=gemini-2.0-flash
# CORS Configuration
app.cors.allowed-origins=https://thughari.github.io,http://localhost:4200
app.cors.allowed-methods=GET,POST,PUT,DELETE,OPTIONSOption B: Environment Variable
- Java 21
- Maven
-
Clone the repository
git clone https://github.com/thughari/carbonscope.git cd carbonscope -
Build
mvn clean package
-
Run (Local) Ensure you have set your API key in the properties file before running.
java -jar target/carbonscope-0.0.1-SNAPSHOT.jar
When running with Docker, pass the API key as an environment variable (-e).
-
Build Image
docker build -t carbonscope-backend . -
Run Container
docker run -p 8082:8082 \ -e GEMINI_API_KEY="your_api_key_here" \ carbonscope-backend
src/
├── main/
│ ├── java/com/carbonscope/
│ │ ├── client/ # ClimateTraceClient.java
│ │ ├── config/ # CorsConfig, AppConfig
│ │ ├── controller/ # REST Controllers (AiController, EmissionController)
│ │ ├── dto/ # Data Transfer Objects
│ │ ├── model/ # Data Entities
│ │ ├── service/ # Business Logic
│ │ └── CarbonscopeApplication.java
│ └── resources/
│ ├── application-dev.properties
│ ├── application-prod.properties
│ └── application.properties
└── Dockerfile
Thughari - Portfolio
Email - haribabutatikonda3@gmail.com
- Backend Repo: https://github.com/thughari/carbonscope
- Frontend Repo: https://github.com/thughari/carbon-scope