โ—‰ LIVE
wikipedia.org โ†’ 0.18g COโ‚‚/visit ยท A+
โ—‰ SYSTEM ARCHITECTURE

External APIs &
Internal Endpoints

Every API this application uses โ€” third-party services, internal Next.js routes, request/response schemas, environment variables, and integration details.

๐Ÿ”Œ
0
External APIs
0 active
โš™๏ธ
2
Internal Routes
App Router
๐Ÿ”‘
5
Env Variables
2 required
๐Ÿ†“
0/0
Free Tier APIs
no cost to start
DATA FLOW ARCHITECTURE
Browser / Client
Homepage โ†’ analyze URL
Dashboard โ†’ list reports
Report Page โ†’ 4 tabs
Shared Page โ†’ public ESG
โ†’
Next.js API Routes
/api/analyze (POST/GET)
/api/chat (POST)
/api/share (POST)
/api/export (GET)
/api/hosting (GET)
/api/stats (GET)
โ†’
Service Layer
carbon-engine.ts
calculateCarbon()
generateESGReport()
generateRecommendations()
โ†’
MongoDB Atlas
AnalysisReport docs
Chat history array
Share tokens
Aggregated stats
โ”€โ”€ EXTERNAL INTEGRATIONS

Third-Party APIs

โ”€โ”€ INTERNAL ROUTES

Next.js App Router API

Method
Route
Purpose + Used By
Returns
POST
/api/analyze
Trigger full carbon analysis pipeline on a URL
HomepageDashboard quick-analyze
{ reportId, report }
GET
/api/analyze
List all reports with cursor pagination
Dashboard
{ reports[], pagination }
โ”€โ”€ CONFIGURATION

Environment Variables

Create .env.local in the project root:
# โ”€โ”€ Required โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/carbon-analyzer
NEXT_PUBLIC_BASE_URL=https://your-domain.com

# โ”€โ”€ Optional (improves accuracy) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
GREENWEB_API_KEY=your_key          # Higher rate limit on green checks
IPAPI_KEY=your_key               # 30k/day (vs 1k free)

# โ”€โ”€ Planned โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
# ELECTRICITY_MAPS_KEY=your_key     # Real-time grid intensity
# WAPPALYZER_API_KEY=your_key       # Tech stack detection
MONGODB_URI
requiredFree / M0 Atlas
Get key โ†—
NEXT_PUBLIC_BASE_URL
requiredFree
GREENWEB_API_KEY
optionalFree
Get key โ†—
IPAPI_KEY
optional1k/day free
Get key โ†—
ELECTRICITY_MAPS_KEY
plannedFree non-commercial
Get key โ†—