Skip to content

thughari/carbonscope

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CarbonScope Backend

Scalable API Service for Carbon Footprint Tracking & AI Analysis

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


📖 About The Project

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:

✨ Key Features

  • 🌍 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.

🛠️ Tech Stack


⚙️ Configuration & API Keys

To run this application, you must provide a Google Gemini API Key.

1. Get a Gemini API Key

Visit Google AI Studio to generate a free API key.

2. Configure the Application

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,OPTIONS

Option B: Environment Variable


🚀 Getting Started

Prerequisites

  • Java 21
  • Maven

📥 Installation & Run

  1. Clone the repository

    git clone https://github.com/thughari/carbonscope.git
    cd carbonscope
  2. Build

    mvn clean package
  3. Run (Local) Ensure you have set your API key in the properties file before running.

    java -jar target/carbonscope-0.0.1-SNAPSHOT.jar

🐳 Docker Deployment

When running with Docker, pass the API key as an environment variable (-e).

  1. Build Image

    docker build -t carbonscope-backend .
  2. Run Container

    docker run -p 8082:8082 \
      -e GEMINI_API_KEY="your_api_key_here" \
      carbonscope-backend

📂 Project Structure

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

📧 Contact

Thughari - Portfolio

Email - haribabutatikonda3@gmail.com

Releases

No releases published

Packages

 
 
 

Contributors