# sridhar-y-g/geopredict architecture

> Architecture diagram of the GitHub repository sridhar-y-g/geopredict, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sridhar-y-g/geopredict
- Repository: https://github.com/sridhar-y-g/geopredict

## Overview

1. **Overall shape**
   This repository is split into a **React frontend** and a **Python backend**. The architecture is a classic client–server setup: the browser UI handles user interaction and visualization, while the backend owns authentication, data access, and integration with external data sources relevant to landslide early warning.

2. **Frontend boundary**
   The `frontend/` app is built with **Vite + React** and styled with **Tailwind/PostCSS**. It is the presentation layer only: it renders pages, manages navigation, and calls backend APIs. Key app entry points are `src/main.jsx` and `src/App.jsx`.

3. **User-facing screens**
   The main UI surface is organized into pages for **Landing**, **Home**, **Login**, **Register**, **Dashboard**, **Profile**, and **Admin**. This suggests two major user flows: public access/marketing and authenticated operational access.

4. **Client-side state and access control**
   `AuthContext.jsx` centralizes authentication state on the frontend, and `ProtectedRoute.jsx` gates restricted pages. This means the frontend enforces route-level access before the user reaches dashboards, profile data, or admin functions.

5. **Backend service boundary**
   The backend is organized as a Python service with distinct modules: `main.py` as the entry point, `auth.py` for identity flows, `profile.py` for user-specific data, `admin.py` for elevated operations, and `security.py` for credential/token handling. This reads like a REST API layered by concern rather than a monolith with one large handler.

6. **Data and persistence**
   `database.py` and `models.py` define the persistence layer and domain schema. The backend is the only component that should talk directly to the database, which keeps the frontend isolated from storage details and preserves a clean API boundary.

7. **Authentication and authorization flow**
   Login/register requests originate in the frontend, pass to the backend auth module, are validated through security utilities, and then persist or read user records via the database layer. The presence of both `ProtectedRoute` on the client and backend security code implies defense in depth for authenticated and role-based access.

8. **External data integration**
   The repo includes `NASA_INTEGRATION_MANUAL.md` and `backend/test_weather.py`, which strongly indicates that the backend integrates with **external environmental/weather/NASA data sources**. In the landslide-warning context, these inputs are part of the risk-signal pipeline rather than the UI itself.

9. **Operational and deployment support**
   `backend/start_backend.ps1` suggests Windows-based local startup or deployment support for the API service. On the frontend side, the presence of `package.json`, ESLint, and Tailwind config indicates a standard JavaScript build workflow for development and production bundling.

10. **Documentation vs runtime**
   `Landslide_Market_and_Competitor_Analysis.md` and the NASA manual are supporting documents, not runtime components. They provide domain and integration context, while the executable architecture is centered on the React UI, Python API, database layer, and external data feeds.

11. **What to show in an architecture diagram**
   A good diagram would show:
   - Browser users entering the **React app**
   - The app using **auth context / protected routes**
   - Requests flowing to the **Python backend API**
   - Backend modules split into **auth / profile / admin / security**
   - Backend reading/writing the **database**
   - Backend calling **external weather/NASA services**
   - Dashboard/admin screens consuming the resulting data for landslide risk monitoring

12. **Important nuance**
   The repository, as shown, emphasizes the **application platform and data integration layer** more than the predictive model itself. If you are diagramming the full solution, treat the landslide intelligence/prediction capability as either an external service or a not-yet-exposed backend subsystem unless additional model code exists elsewhere.

Main entry points: [`frontend/src/App.jsx`](https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/App.jsx) (Shell), [`backend/main.py`](https://github.com/sridhar-y-g/geopredict/blob/main/backend/main.py) (API entry), [`backend/auth.py`](https://github.com/sridhar-y-g/geopredict/blob/main/backend/auth.py) (Auth API), [`backend/database.py`](https://github.com/sridhar-y-g/geopredict/blob/main/backend/database.py) (Database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_main["App boot<br/>Vite/React entry<br/>[main.jsx]"]
  node_frontend_app["Shell<br/>React app<br/>[App.jsx]"]
  node_auth_context(("Auth state<br/>client auth<br/>[AuthContext.jsx]"))
  node_protected_route{{"Guard<br/>[ProtectedRoute.jsx]"}}
  node_landing_page["Landing<br/>public page<br/>[Landing.jsx]"]
  node_home_page["Home<br/>public page<br/>[Home.jsx]"]
  node_login_page["Login<br/>auth page<br/>[Login.jsx]"]
  node_register_page["Register<br/>auth page<br/>[Register.jsx]"]
  node_dashboard_page["Dashboard<br/>ops page<br/>[Dashboard.jsx]"]
  node_profile_page["Profile<br/>user page<br/>[Profile.jsx]"]
  node_admin_page["Admin<br/>ops page<br/>[Admin.jsx]"]
end

subgraph group_backend["Backend"]
  node_backend_main["API entry<br/>Python service<br/>[main.py]"]
  node_auth_api["Auth API<br/>api module<br/>[auth.py]"]
  node_profile_api["Profile API<br/>api module<br/>[profile.py]"]
  node_admin_api["Admin API<br/>api module<br/>[admin.py]"]
  node_security{{"Security<br/>auth utils<br/>[security.py]"}}
  node_database[("Database<br/>persistence<br/>[database.py]")]
  node_models["Models<br/>schema<br/>[models.py]"]
  node_external_data(("Weather/NASA<br/>external source<br/>[test_weather.py]"))
end

node_frontend_main -->|"bootstraps"| node_frontend_app
node_frontend_app -->|"provides"| node_auth_context
node_frontend_app -->|"uses"| node_protected_route
node_frontend_app -->|"routes"| node_landing_page
node_frontend_app -->|"routes"| node_home_page
node_frontend_app -->|"routes"| node_login_page
node_frontend_app -->|"routes"| node_register_page
node_frontend_app -->|"routes"| node_dashboard_page
node_frontend_app -->|"routes"| node_profile_page
node_frontend_app -->|"routes"| node_admin_page
node_login_page -->|"calls"| node_auth_api
node_register_page -->|"calls"| node_auth_api
node_dashboard_page -->|"calls"| node_backend_main
node_profile_page -->|"calls"| node_profile_api
node_admin_page -->|"calls"| node_admin_api
node_backend_main -->|"dispatches"| node_auth_api
node_backend_main -->|"dispatches"| node_profile_api
node_backend_main -->|"dispatches"| node_admin_api
node_auth_api -->|"verifies"| node_security
node_auth_api -->|"reads/writes"| node_database
node_profile_api -->|"reads"| node_database
node_admin_api -->|"reads/writes"| node_database
node_database -->|"maps to"| node_models
node_backend_main -.->|"integrates"| node_external_data
node_dashboard_page -.->|"consumes"| node_external_data

click node_frontend_main "https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/main.jsx"
click node_frontend_app "https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/App.jsx"
click node_auth_context "https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/context/AuthContext.jsx"
click node_protected_route "https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/components/ProtectedRoute.jsx"
click node_landing_page "https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Landing.jsx"
click node_home_page "https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Home.jsx"
click node_login_page "https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Login.jsx"
click node_register_page "https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Register.jsx"
click node_dashboard_page "https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Dashboard.jsx"
click node_profile_page "https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Profile.jsx"
click node_admin_page "https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Admin.jsx"
click node_backend_main "https://github.com/sridhar-y-g/geopredict/blob/main/backend/main.py"
click node_auth_api "https://github.com/sridhar-y-g/geopredict/blob/main/backend/auth.py"
click node_profile_api "https://github.com/sridhar-y-g/geopredict/blob/main/backend/profile.py"
click node_admin_api "https://github.com/sridhar-y-g/geopredict/blob/main/backend/admin.py"
click node_security "https://github.com/sridhar-y-g/geopredict/blob/main/backend/security.py"
click node_database "https://github.com/sridhar-y-g/geopredict/blob/main/backend/database.py"
click node_models "https://github.com/sridhar-y-g/geopredict/blob/main/backend/models.py"
click node_external_data "https://github.com/sridhar-y-g/geopredict/blob/main/backend/test_weather.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_frontend_main,node_frontend_app,node_auth_context,node_protected_route,node_landing_page,node_home_page,node_login_page,node_register_page,node_dashboard_page,node_profile_page,node_admin_page toneBlue
class node_backend_main,node_auth_api,node_profile_api,node_admin_api,node_security,node_database,node_models,node_external_data toneAmber
```

## Components

### Frontend

React UI and client-side route protection

- [App boot](https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/main.jsx): Vite/React entry · Starts the browser app and mounts the UI · `frontend/src/main.jsx`
- [Shell](https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/App.jsx): React app · Top-level routing and page composition · `frontend/src/App.jsx`
- [Auth state](https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/context/AuthContext.jsx): client auth · Holds login state and session context · `frontend/src/context/AuthContext.jsx`
- [Guard](https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/components/ProtectedRoute.jsx): route guard · Blocks access to restricted pages · `frontend/src/components/ProtectedRoute.jsx`
- [Landing](https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Landing.jsx): public page · Public entry and marketing surface · `frontend/src/pages/Landing.jsx`
- [Home](https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Home.jsx): public page · General application landing area · `frontend/src/pages/Home.jsx`
- [Login](https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Login.jsx): auth page · User sign-in screen · `frontend/src/pages/Login.jsx`
- [Register](https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Register.jsx): auth page · User account creation screen · `frontend/src/pages/Register.jsx`
- [Dashboard](https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Dashboard.jsx): ops page · Authenticated monitoring and data view · `frontend/src/pages/Dashboard.jsx`
- [Profile](https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Profile.jsx): user page · Authenticated personal data view · `frontend/src/pages/Profile.jsx`
- [Admin](https://github.com/sridhar-y-g/geopredict/blob/main/frontend/src/pages/Admin.jsx): ops page · Privileged administrative interface · `frontend/src/pages/Admin.jsx`

### Backend

Python API, persistence, and integrations

- [API entry](https://github.com/sridhar-y-g/geopredict/blob/main/backend/main.py): Python service · Backend service startup and routing entrypoint · `backend/main.py`
- [Auth API](https://github.com/sridhar-y-g/geopredict/blob/main/backend/auth.py): api module · Login and registration flows · `backend/auth.py`
- [Profile API](https://github.com/sridhar-y-g/geopredict/blob/main/backend/profile.py): api module · User profile data access · `backend/profile.py`
- [Admin API](https://github.com/sridhar-y-g/geopredict/blob/main/backend/admin.py): api module · Privileged backend operations · `backend/admin.py`
- [Security](https://github.com/sridhar-y-g/geopredict/blob/main/backend/security.py): auth utils · Token and credential handling · `backend/security.py`
- [Database](https://github.com/sridhar-y-g/geopredict/blob/main/backend/database.py): persistence · Storage access and database connection layer · `backend/database.py`
- [Models](https://github.com/sridhar-y-g/geopredict/blob/main/backend/models.py): schema · Domain entities and persistence models · `backend/models.py`
- [Weather/NASA](https://github.com/sridhar-y-g/geopredict/blob/main/backend/test_weather.py): external source · External environmental data feeds used for risk context · `backend/test_weather.py`

## Connections

- App boot → Shell: bootstraps · Entry point mounts the app shell
- Shell → Auth state: provides · App wraps routes with auth state
- Shell → Guard: uses · Protected screens are gated before render
- Shell → Landing: routes · Public route to landing page
- Shell → Home: routes · Public route to home page
- Shell → Login: routes · Authentication route
- Shell → Register: routes · Account creation route
- Shell → Dashboard: routes · Protected operational view
- Shell → Profile: routes · Protected user view
- Shell → Admin: routes · Protected admin view
- Login → Auth API: calls · Submits sign-in requests
- Register → Auth API: calls · Submits registration requests
- Dashboard → API entry: calls · Fetches operational data from backend
- Profile → Profile API: calls · Loads user profile data
- Admin → Admin API: calls · Performs elevated actions
- API entry → Auth API: dispatches · Routes auth-related requests
- API entry → Profile API: dispatches · Routes profile requests
- API entry → Admin API: dispatches · Routes admin requests
- Auth API → Security: verifies · Credentials and tokens are validated
- Auth API → Database: reads/writes · Stores and retrieves user records
- Profile API → Database: reads · Loads persisted profile data
- Admin API → Database: reads/writes · Admin workflows touch storage
- Database → Models: maps to · Persistence layer uses domain schema
- API entry → Weather/NASA: integrates · Ingests external weather/NASA context
- Dashboard → Weather/NASA: consumes · Displays risk-relevant data sourced from backend
