โ 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
NEXT_PUBLIC_BASE_URL
requiredFree