# kds2383/earth-bloom-precision-agri architecture

> Architecture diagram of the GitHub repository kds2383/earth-bloom-precision-agri, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kds2383/earth-bloom-precision-agri
- Repository: https://github.com/kds2383/earth-bloom-precision-agri

## Overview

#### Purpose and Runtime
Earth Bloom is a Vite/React TypeScript single-page precision-agriculture client. It presents crop, soil, weather, recommendation, results, account, and contact experiences. The checked-in repository is frontend-focused; the README describes Node/Express, MongoDB, and Python ML services, but their source is not present. Primary browser entry points are `src/main.tsx` and `src/App.tsx`.

#### Application Composition and Navigation
`src/App.tsx` is the application shell/router composition point, mapping page-level views under `src/pages/`. `src/components/layout/Layout.tsx`, `src/components/layout/Navbar.tsx`, and `src/components/layout/Footer.tsx` provide the shared navigational frame. The landing route is composed from feature-oriented marketing sections in `src/pages/Index.tsx`, `src/components/home/HeroSection.tsx`, and `src/components/home/FeaturesSection.tsx`.

#### Identity and Access Boundary
Authentication state is centralized in `src/context/AuthContext.tsx`. Firebase initialization is isolated in `src/firebase.tsx`, making Firebase the implemented identity boundary. `src/components/auth/ProtectedRoute.tsx` gates authenticated routes, while `src/pages/Auth/SignIn.tsx` and `src/pages/Auth/SignUp.tsx` are the user onboarding entry points.

#### Farmer Profile and Persisted User Data
The account workflow is centered at `src/pages/Account.tsx` and assembled through `src/components/account/AccountForm.tsx`. It captures profile, farm, location, and preferences through `src/components/account/ProfileSection.tsx`, `src/components/account/FarmSection.tsx`, and `src/components/account/PreferencesSection.tsx`. User-facing Firebase persistence is encapsulated by `src/services/firebase/userService.ts`, keeping page components separated from data-store calls.

#### Environmental Data Acquisition and State
Location entry is a reusable input boundary in `src/components/location/LocationInput.tsx`. Weather API access is isolated in `src/utils/weatherApi.ts` and configured through `src/utils/envVars.ts`; the weather experience is exposed by `src/pages/Weather.tsx`. Soil data has dedicated client state in `src/store/soilDataStore.ts`, consumed by `src/pages/SoilData.tsx`; this is the likely integration point for the README’s SoilGrids-style environmental source.

#### Recommendation and Results Flow
The domain flow runs from farmer/location and environmental inputs toward advice and presented outcomes. `src/pages/Recommendation.tsx` is the recommendation-facing stage; `src/hooks/useResultsData.tsx` provides a results-data abstraction consumed by `src/pages/Results.tsx`. `src/utils/reportGenerator.ts` forms the export/reporting boundary for generated agricultural results. ML prediction, backend orchestration, and MongoDB storage are external/claimed capabilities rather than implementation present in this tree.

#### UI System and Client Infrastructure
The app uses Tailwind styling and a local reusable component system under `src/components/ui/`, with application-wide styles in `src/index.css` and `src/App.css`. Vite supplies the browser build/development runtime (`vite.config.ts`), and environment values are expected from `.env`. Contact submission behavior is separated from its page in `src/pages/Contact.tsx` and `src/utils/contactFormUtils.ts`.

Main entry points: [`src/App.tsx`](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/App.tsx) (App router shell), [`src/pages/Recommendation.tsx`](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Recommendation.tsx) (Recommendation stage), [`src/components/auth/ProtectedRoute.tsx`](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/components/auth/ProtectedRoute.tsx) (Protected routes), [`src/pages/Account.tsx`](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Account.tsx) (Account workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Browser Runtime"]
  node_vite{{"Vite runtime<br/>build runtime<br/>[vite.config.ts]"}}
  node_main(("Browser entry<br/>React entry<br/>[main.tsx]"))
end

subgraph group_experience["Application Experience"]
  node_app["App router shell<br/>route composition<br/>[App.tsx]"]
  node_layout["Shared layout<br/>navigation frame<br/>[Layout.tsx]"]
  node_home["Landing experience<br/>home page<br/>[Index.tsx]"]
  node_auth_pages["Sign-in and sign-up<br/>auth pages<br/>[SignIn.tsx]"]
  node_protected_route["Protected routes<br/>route guard<br/>[ProtectedRoute.tsx]"]
  node_account["Account workflow<br/>account page<br/>[Account.tsx]"]
  node_weather_page["Weather experience<br/>weather page<br/>[Weather.tsx]"]
  node_soil_page["Soil data experience<br/>soil page<br/>[SoilData.tsx]"]
  node_recommendation["Recommendation stage<br/>recommendation page<br/>[Recommendation.tsx]"]
  node_results["Results experience<br/>results page<br/>[Results.tsx]"]
  node_contact["Contact submission<br/>contact page<br/>[Contact.tsx]"]
end

subgraph group_data["Client Data Boundaries"]
  node_auth_context["Auth state<br/>React context<br/>[AuthContext.tsx]"]
  node_user_service["User persistence<br/>Firebase service<br/>[userService.ts]"]
  node_location_input["Location input<br/>reusable input<br/>[LocationInput.tsx]"]
  node_weather_api["Weather API client<br/>API adapter<br/>[weatherApi.ts]"]
  node_soil_store["Soil data state<br/>client store<br/>[soilDataStore.ts]"]
  node_results_data["Results data abstraction<br/>React hook<br/>[useResultsData.tsx]"]
  node_report_generator["Report export<br/>report generator<br/>[reportGenerator.ts]"]
end

subgraph group_external["External Services"]
  node_firebase[("Firebase identity<br/>identity boundary<br/>[firebase.tsx]")]
  node_ml_backend{{"Claimed ML/backend<br/>external capability"}}
end

node_vite -->|"serves"| node_main
node_main -->|"mounts"| node_app
node_app -->|"uses"| node_layout
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_auth_pages
node_app -->|"guards"| node_protected_route
node_protected_route -->|"allows"| node_account
node_app -->|"routes to"| node_weather_page
node_app -->|"routes to"| node_soil_page
node_app -->|"routes to"| node_recommendation
node_app -->|"routes to"| node_results
node_app -->|"routes to"| node_contact
node_auth_pages -->|"authenticates through"| node_auth_context
node_protected_route -->|"checks"| node_auth_context
node_auth_context -->|"uses"| node_firebase
node_account -->|"persists profile"| node_user_service
node_user_service -->|"stores through"| node_firebase
node_account -->|"collects location"| node_location_input
node_weather_page -->|"accepts location"| node_location_input
node_weather_page -->|"fetches weather"| node_weather_api
node_soil_page -->|"consumes"| node_soil_store
node_recommendation -->|"uses location"| node_location_input
node_recommendation -->|"uses soil data"| node_soil_store
node_recommendation -->|"uses weather"| node_weather_api
node_recommendation -.->|"future integration"| node_ml_backend
node_results -->|"consumes"| node_results_data
node_results -->|"exports"| node_report_generator

click node_vite "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/vite.config.ts"
click node_main "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/main.tsx"
click node_app "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/App.tsx"
click node_layout "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/components/layout/Layout.tsx"
click node_home "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Index.tsx"
click node_auth_pages "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Auth/SignIn.tsx"
click node_protected_route "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/components/auth/ProtectedRoute.tsx"
click node_account "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Account.tsx"
click node_weather_page "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Weather.tsx"
click node_soil_page "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/SoilData.tsx"
click node_recommendation "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Recommendation.tsx"
click node_results "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Results.tsx"
click node_contact "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Contact.tsx"
click node_auth_context "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/context/AuthContext.tsx"
click node_firebase "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/firebase.tsx"
click node_user_service "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/services/firebase/userService.ts"
click node_location_input "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/components/location/LocationInput.tsx"
click node_weather_api "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/utils/weatherApi.ts"
click node_soil_store "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/store/soilDataStore.ts"
click node_results_data "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/hooks/useResultsData.tsx"
click node_report_generator "https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/utils/reportGenerator.ts"

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_vite,node_main toneBlue
class node_app,node_layout,node_home,node_auth_pages,node_protected_route,node_account,node_weather_page,node_soil_page,node_recommendation,node_results,node_contact toneAmber
class node_auth_context,node_user_service,node_location_input,node_weather_api,node_soil_store,node_results_data,node_report_generator toneMint
class node_firebase,node_ml_backend toneRose
```

## Components

### Browser Runtime

- [Vite runtime](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/vite.config.ts): build runtime · `vite.config.ts`
- [Browser entry](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/main.tsx): React entry · `src/main.tsx`

### Application Experience

- [App router shell](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/App.tsx): route composition · `src/App.tsx`
- [Shared layout](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/components/layout/Layout.tsx): navigation frame · Navbar and footer surround routed views. · `src/components/layout/Layout.tsx`
- [Landing experience](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Index.tsx): home page · Composes hero and feature sections. · `src/pages/Index.tsx`
- [Sign-in and sign-up](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Auth/SignIn.tsx): auth pages · `src/pages/Auth/SignIn.tsx`
- [Protected routes](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/components/auth/ProtectedRoute.tsx): route guard · `src/components/auth/ProtectedRoute.tsx`
- [Account workflow](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Account.tsx): account page · Uses the account form for profile, farm, location, and preferences. · `src/pages/Account.tsx`
- [Weather experience](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Weather.tsx): weather page · `src/pages/Weather.tsx`
- [Soil data experience](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/SoilData.tsx): soil page · `src/pages/SoilData.tsx`
- [Recommendation stage](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Recommendation.tsx): recommendation page · `src/pages/Recommendation.tsx`
- [Results experience](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Results.tsx): results page · `src/pages/Results.tsx`
- [Contact submission](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/pages/Contact.tsx): contact page · `src/pages/Contact.tsx`

### Client Data Boundaries

- [Auth state](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/context/AuthContext.tsx): React context · `src/context/AuthContext.tsx`
- [User persistence](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/services/firebase/userService.ts): Firebase service · `src/services/firebase/userService.ts`
- [Location input](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/components/location/LocationInput.tsx): reusable input · `src/components/location/LocationInput.tsx`
- [Weather API client](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/utils/weatherApi.ts): API adapter · Reads environment-configured weather access. · `src/utils/weatherApi.ts`
- [Soil data state](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/store/soilDataStore.ts): client store · `src/store/soilDataStore.ts`
- [Results data abstraction](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/hooks/useResultsData.tsx): React hook · `src/hooks/useResultsData.tsx`
- [Report export](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/utils/reportGenerator.ts): report generator · `src/utils/reportGenerator.ts`

### External Services

Implemented and claimed service boundaries.

- [Firebase identity](https://github.com/kds2383/earth-bloom-precision-agri/blob/main/src/firebase.tsx): identity boundary · `src/firebase.tsx`
- **Claimed ML/backend**: external capability · README-described prediction, orchestration, and MongoDB services have no checked-in source.

## Connections

- Vite runtime → Browser entry: serves
- Browser entry → App router shell: mounts
- App router shell → Shared layout: uses
- App router shell → Landing experience: routes to
- App router shell → Sign-in and sign-up: routes to
- App router shell → Protected routes: guards
- Protected routes → Account workflow: allows
- App router shell → Weather experience: routes to
- App router shell → Soil data experience: routes to
- App router shell → Recommendation stage: routes to
- App router shell → Results experience: routes to
- App router shell → Contact submission: routes to
- Sign-in and sign-up → Auth state: authenticates through
- Protected routes → Auth state: checks
- Auth state → Firebase identity: uses
- Account workflow → User persistence: persists profile
- User persistence → Firebase identity: stores through
- Account workflow → Location input: collects location
- Weather experience → Location input: accepts location
- Weather experience → Weather API client: fetches weather
- Soil data experience → Soil data state: consumes
- Recommendation stage → Location input: uses location
- Recommendation stage → Soil data state: uses soil data
- Recommendation stage → Weather API client: uses weather
- Recommendation stage → Claimed ML/backend: future integration
- Results experience → Results data abstraction: consumes
- Results experience → Report export: exports
