# jkep2004/tdp-capstone-2026 architecture

> Architecture diagram of the GitHub repository jkep2004/tdp-capstone-2026, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jkep2004/tdp-capstone-2026
- Repository: https://github.com/jkep2004/tdp-capstone-2026

## Overview

This is a customer-facing carbon and savings advisor: customers sign in, submit monthly spending, then view estimated emissions, category insights, recommendations, savings, trends, and challenges. The frontend calls a FastAPI API, which exposes domain routers and uses SQL storage; selected API services provide calculation and insight logic. The README documents the product capabilities, while several router and service implementations were not sampled, so those internal links are omitted where their call relationships cannot be verified.

Main entry points: [`api/src/main.py`](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/main.py) (FastAPI application), [`frontend/src/app/App.tsx`](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/app/App.tsx) (Application shell), [`frontend/src/services/api.ts`](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/services/api.ts) (API client), [`api/database/database.py`](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/database/database.py) (SQL database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer experience"]
  node_webapp["Application shell<br/>[App.tsx]"]
  node_spending_ui["Spending entry<br/>[SpendingPage.tsx]"]
  node_spending_form["Manual entry<br/>[SpendingForm.tsx]"]
  node_csv_upload["CSV upload<br/>[CsvUpload.tsx]"]
  node_insights_ui["Insights dashboard<br/>[InsightsPage.tsx]"]
  node_challenge_ui["Challenge experience<br/>[ChallengesPage.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and identity"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_auth_tokens["Token validation<br/>[auth.py]"]
  node_spend_api["Spending endpoints<br/>[spend.py]"]
  node_categories_api["Category endpoints<br/>[categories.py]"]
  node_recommendations_api["Recommendation endpoints<br/>[recommendations.py]"]
  node_challenges_api["Challenge endpoints<br/>[challenges.py]"]
  node_savings_api["Savings endpoints<br/>[savings.py]"]
  node_summary_api["Summary endpoints<br/>[summary.py]"]
  node_trends_api["Trend endpoints<br/>[trends.py]"]
  node_challenge_schema["Challenge response"]
end

subgraph group_insights["Carbon and insights"]
  node_calculation["Carbon calculation<br/>[carbon.py]"]
  node_recommendations["Recommendations<br/>[recommendations.py]"]
  node_summary["Monthly summary<br/>[summary.py]"]
  node_trends["Progress trends<br/>[trends.py]"]
  node_challenges["Challenge logic<br/>[challenges.py]"]
end

subgraph group_data["Persistence"]
  node_database[("SQL database<br/>[database.py]")]
end

node_customer(("Customer"))
node_entra(("Microsoft Entra"))

node_customer -->|"uses"| node_webapp
node_webapp -->|"signs in through"| node_entra
node_webapp -->|"opens"| node_spending_ui
node_webapp -->|"shows"| node_insights_ui
node_webapp -->|"shows"| node_challenge_ui
node_spending_ui -->|"renders"| node_spending_form
node_spending_ui -->|"renders"| node_csv_upload
node_spending_form -->|"submits through"| node_api_client
node_csv_upload -->|"submits through"| node_api_client
node_insights_ui -->|"loads insights"| node_api_client
node_challenge_ui -->|"loads challenges"| node_api_client
node_api_client -.->|"requests API"| node_api_app
node_api_app -->|"registers"| node_auth
node_api_app -->|"registers"| node_spend_api
node_api_app -->|"registers"| node_categories_api
node_api_app -->|"registers"| node_recommendations_api
node_api_app -->|"registers"| node_challenges_api
node_api_app -->|"registers"| node_savings_api
node_api_app -->|"registers"| node_summary_api
node_api_app -->|"registers"| node_trends_api
node_auth -->|"validates token"| node_auth_tokens
node_auth -->|"reads and writes"| node_database
node_auth_tokens -->|"provides dependency"| node_database
node_spend_api -->|"reads and writes"| node_database
node_categories_api -->|"reads"| node_database
node_recommendations_api -->|"delegates"| node_recommendations
node_challenges_api -->|"delegates"| node_challenges
node_challenges_api -->|"returns"| node_challenge_schema
node_calculation -.->|"uses"| node_database
node_summary_api -.->|"delegates"| node_summary
node_trends_api -.->|"delegates"| node_trends
node_savings_api -.->|"uses"| node_summary

click node_webapp "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/app/App.tsx"
click node_spending_ui "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/features/spending/SpendingPage.tsx"
click node_spending_form "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/features/spending/SpendingForm.tsx"
click node_csv_upload "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/features/spending/CsvUpload.tsx"
click node_insights_ui "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/features/insights/InsightsPage.tsx"
click node_challenge_ui "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/features/challenges/ChallengesPage.tsx"
click node_api_client "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/services/api.ts"
click node_api_app "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/main.py"
click node_auth "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/auth.py"
click node_auth_tokens "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Core/auth.py"
click node_spend_api "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/spend.py"
click node_categories_api "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/categories.py"
click node_calculation "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Services/carbon.py"
click node_recommendations "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Services/recommendations.py"
click node_summary "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Services/summary.py"
click node_trends "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Services/trends.py"
click node_challenges "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Services/challenges.py"
click node_recommendations_api "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/recommendations.py"
click node_challenges_api "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/challenges.py"
click node_savings_api "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/savings.py"
click node_summary_api "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/summary.py"
click node_trends_api "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/trends.py"
click node_database "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/database/database.py"
click node_challenge_schema "https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/schemas/ChallengeResponse.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_spending_ui,node_spending_form,node_csv_upload,node_insights_ui,node_challenge_ui,node_api_client toneBlue
class node_api_app,node_auth,node_auth_tokens,node_spend_api,node_categories_api,node_recommendations_api,node_challenges_api,node_savings_api,node_summary_api,node_trends_api,node_challenge_schema toneAmber
class node_calculation,node_recommendations,node_summary,node_trends,node_challenges toneMint
class node_database toneRose
class node_customer,node_entra toneIndigo
```

## Components

### Customer experience

- [Application shell](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/app/App.tsx): `frontend/src/app/App.tsx`
- [Spending entry](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/features/spending/SpendingPage.tsx): `frontend/src/features/spending/SpendingPage.tsx`
- [Manual entry](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/features/spending/SpendingForm.tsx): `frontend/src/features/spending/SpendingForm.tsx`
- [CSV upload](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/features/spending/CsvUpload.tsx): `frontend/src/features/spending/CsvUpload.tsx`
- [Insights dashboard](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/features/insights/InsightsPage.tsx): `frontend/src/features/insights/InsightsPage.tsx`
- [Challenge experience](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/features/challenges/ChallengesPage.tsx): `frontend/src/features/challenges/ChallengesPage.tsx`
- [API client](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### API and identity

- [FastAPI application](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/main.py): `api/src/main.py`
- [Authentication](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/auth.py): `api/src/Routers/auth.py`
- [Token validation](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Core/auth.py): `api/src/Core/auth.py`
- [Spending endpoints](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/spend.py): `api/src/Routers/spend.py`
- [Category endpoints](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/categories.py): `api/src/Routers/categories.py`
- [Recommendation endpoints](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/recommendations.py): `api/src/Routers/recommendations.py`
- [Challenge endpoints](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/challenges.py): `api/src/Routers/challenges.py`
- [Savings endpoints](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/savings.py): `api/src/Routers/savings.py`
- [Summary endpoints](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/summary.py): `api/src/Routers/summary.py`
- [Trend endpoints](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Routers/trends.py): `api/src/Routers/trends.py`
- [Challenge response](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/schemas/ChallengeResponse.py): `api/src/schemas/ChallengeResponse.py`

### Carbon and insights

- [Carbon calculation](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Services/carbon.py): `api/src/Services/carbon.py`
- [Recommendations](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Services/recommendations.py): `api/src/Services/recommendations.py`
- [Monthly summary](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Services/summary.py): `api/src/Services/summary.py`
- [Progress trends](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Services/trends.py): `api/src/Services/trends.py`
- [Challenge logic](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/src/Services/challenges.py): `api/src/Services/challenges.py`

### Persistence

- [SQL database](https://github.com/jkep2004/tdp-capstone-2026/blob/dev/api/database/database.py): `api/database/database.py`

### Other components

- **Customer**
- **Microsoft Entra**

## Connections

- Customer → Application shell: uses (evidence: `frontend/src/app/App.tsx`)
- Application shell → Microsoft Entra: signs in through (evidence: `frontend/src/app/App.tsx`)
- Application shell → Spending entry: opens (evidence: `frontend/src/app/App.tsx`)
- Application shell → Insights dashboard: shows (evidence: `frontend/src/app/App.tsx`)
- Application shell → Challenge experience: shows (evidence: `frontend/src/app/App.tsx`)
- Spending entry → Manual entry: renders (evidence: `frontend/src/features/spending/SpendingPage.tsx`)
- Spending entry → CSV upload: renders (evidence: `frontend/src/features/spending/SpendingPage.tsx`)
- Manual entry → API client: submits through (evidence: `frontend/src/features/spending/SpendingForm.tsx`)
- CSV upload → API client: submits through (evidence: `frontend/src/features/spending/CsvUpload.tsx`)
- Insights dashboard → API client: loads insights (evidence: `frontend/src/features/insights/InsightsPage.tsx`)
- Challenge experience → API client: loads challenges (evidence: `frontend/src/features/challenges/ChallengesPage.tsx`)
- API client → FastAPI application: requests API
- FastAPI application → Authentication: registers (evidence: `api/src/main.py`)
- FastAPI application → Spending endpoints: registers (evidence: `api/src/main.py`)
- FastAPI application → Category endpoints: registers (evidence: `api/src/main.py`)
- FastAPI application → Recommendation endpoints: registers (evidence: `api/src/main.py`)
- FastAPI application → Challenge endpoints: registers (evidence: `api/src/main.py`)
- FastAPI application → Savings endpoints: registers (evidence: `api/src/main.py`)
- FastAPI application → Summary endpoints: registers (evidence: `api/src/main.py`)
- FastAPI application → Trend endpoints: registers (evidence: `api/src/main.py`)
- Authentication → Token validation: validates token (evidence: `api/src/Routers/auth.py`)
- Authentication → SQL database: reads and writes (evidence: `api/src/Routers/auth.py`)
- Token validation → SQL database: provides dependency (evidence: `api/src/Core/auth.py`)
- Spending endpoints → SQL database: reads and writes (evidence: `api/src/Routers/spend.py`)
- Category endpoints → SQL database: reads (evidence: `api/src/Routers/categories.py`)
- Recommendation endpoints → Recommendations: delegates (evidence: `api/src/Routers/recommendations.py`)
- Challenge endpoints → Challenge logic: delegates (evidence: `api/src/Routers/challenges.py`)
- Challenge endpoints → Challenge response: returns (evidence: `api/src/Routers/challenges.py`)
- Carbon calculation → SQL database: uses
- Summary endpoints → Monthly summary: delegates
- Trend endpoints → Progress trends: delegates
- Savings endpoints → Monthly summary: uses
