# viknesh74/biosense architecture

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

- Interactive diagram: https://gitdiagram.com/viknesh74/biosense
- Repository: https://github.com/viknesh74/biosense

## Overview

This is a React cattle-care dashboard for farmers and veterinary staff, although the README describes only a generic React/Vite template. The primary workflow is entering the app, selecting a role-specific dashboard, and viewing cattle records alongside collar telemetry and alerts; consultations support a separate farmer–doctor workflow. The graph reflects documented routes and sampled hook/service wiring. Other page capabilities are represented from the route list and source index; their internal behavior was not inspected.

Main entry points: [`src/App.jsx`](https://github.com/viknesh74/biosense/blob/main/src/App.jsx) (Role router), [`src/context/AppContext.jsx`](https://github.com/viknesh74/biosense/blob/main/src/context/AppContext.jsx) (App state), [`src/services/telemetryService.js`](https://github.com/viknesh74/biosense/blob/main/src/services/telemetryService.js) (Telemetry service), [`src/services/firebase.js`](https://github.com/viknesh74/biosense/blob/main/src/services/firebase.js) (Firebase client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App shell"]
  node_entry["React entry<br/>[main.jsx]"]
  node_router["Role router<br/>[App.jsx]"]
end

subgraph group_herd["Herd monitoring"]
  node_farmerdash["Farmer dashboard"]
  node_cattledetails["Cattle details<br/>[CattleDetails.jsx]"]
  node_herdanalytics["Herd analytics<br/>[HerdAnalytics.jsx]"]
  node_healthanalytics["Health analytics"]
  node_gps["GPS tracking<br/>[GPSTracking.jsx]"]
  node_alertsview["Alerts view<br/>[Alerts.jsx]"]
end

subgraph group_care["Care workflows"]
  node_doctor["Doctor dashboard"]
  node_consultview["Consultations<br/>[Consultation.jsx]"]
  node_ai["Cattle care AI<br/>[CattleCareAI.jsx]"]
  node_vetservices["Veterinary services"]
  node_schemes["Government schemes"]
  node_chatbot["Assistant chatbot<br/>[Chatbot.jsx]"]
end

subgraph group_data["State and data"]
  node_context["App state<br/>[AppContext.jsx]"]
  node_cattlehook["Cattle state hook<br/>[useCattle.js]"]
  node_telemetryhook["Telemetry hook<br/>[useTelemetry.js]"]
  node_alerthook["Alerts hook<br/>[useAlerts.js]"]
  node_consult_hook["Consultation hook"]
  node_cattleservice["Cattle records<br/>[cattleService.js]"]
  node_telemetryservice["Telemetry service"]
  node_alertservice["Alert service<br/>[alertService.js]"]
  node_consultservice["Consultation service"]
  node_firebase["Firebase client<br/>[firebase.js]"]
  node_mockdata["Demo data<br/>[mockData.js]"]
end

node_user(("Farmer or vet"))

node_user -->|"opens app"| node_entry
node_entry -->|"provides state"| node_context
node_entry -->|"renders"| node_router
node_router -->|"reads state"| node_context
node_router -->|"routes to"| node_farmerdash
node_router -->|"routes to"| node_cattledetails
node_router -->|"routes to"| node_herdanalytics
node_router -->|"routes to"| node_healthanalytics
node_router -->|"routes to"| node_gps
node_router -->|"routes to"| node_alertsview
node_router -->|"routes to"| node_doctor
node_router -->|"routes to"| node_consultview
node_router -->|"routes to"| node_ai
node_router -->|"routes to"| node_vetservices
node_router -->|"routes to"| node_schemes
node_router -->|"renders"| node_chatbot
node_context -->|"uses"| node_cattlehook
node_context -->|"uses"| node_telemetryhook
node_context -->|"uses"| node_alerthook
node_context -->|"uses"| node_consult_hook
node_cattlehook -->|"loads and updates"| node_cattleservice
node_telemetryhook -->|"uses"| node_telemetryservice
node_alerthook -->|"subscribes and updates"| node_alertservice
node_consult_hook -->|"subscribes and updates"| node_consultservice
node_cattleservice -->|"reads and writes"| node_firebase
node_cattleservice -->|"falls back to"| node_mockdata
node_telemetryservice -->|"uses"| node_firebase
node_telemetryservice -->|"uses fallback"| node_mockdata
node_telemetryservice -->|"raises alerts"| node_alertservice
node_alertservice -->|"subscribes and writes"| node_firebase
node_consultservice -->|"subscribes and writes"| node_firebase

click node_entry "https://github.com/viknesh74/biosense/blob/main/src/main.jsx"
click node_router "https://github.com/viknesh74/biosense/blob/main/src/App.jsx"
click node_context "https://github.com/viknesh74/biosense/blob/main/src/context/AppContext.jsx"
click node_farmerdash "https://github.com/viknesh74/biosense/blob/main/src/pages/FarmerDashboard.jsx"
click node_cattledetails "https://github.com/viknesh74/biosense/blob/main/src/pages/CattleDetails.jsx"
click node_herdanalytics "https://github.com/viknesh74/biosense/blob/main/src/pages/HerdAnalytics.jsx"
click node_healthanalytics "https://github.com/viknesh74/biosense/blob/main/src/pages/HealthAnalytics.jsx"
click node_gps "https://github.com/viknesh74/biosense/blob/main/src/pages/GPSTracking.jsx"
click node_alertsview "https://github.com/viknesh74/biosense/blob/main/src/pages/Alerts.jsx"
click node_doctor "https://github.com/viknesh74/biosense/blob/main/src/pages/DoctorDashboard.jsx"
click node_consultview "https://github.com/viknesh74/biosense/blob/main/src/pages/Consultation.jsx"
click node_ai "https://github.com/viknesh74/biosense/blob/main/src/pages/CattleCareAI.jsx"
click node_vetservices "https://github.com/viknesh74/biosense/blob/main/src/pages/VeterinaryServices.jsx"
click node_schemes "https://github.com/viknesh74/biosense/blob/main/src/pages/GovernmentSchemes.jsx"
click node_chatbot "https://github.com/viknesh74/biosense/blob/main/src/components/Chatbot.jsx"
click node_cattlehook "https://github.com/viknesh74/biosense/blob/main/src/hooks/useCattle.js"
click node_telemetryhook "https://github.com/viknesh74/biosense/blob/main/src/hooks/useTelemetry.js"
click node_alerthook "https://github.com/viknesh74/biosense/blob/main/src/hooks/useAlerts.js"
click node_consult_hook "https://github.com/viknesh74/biosense/blob/main/src/hooks/useConsultations.js"
click node_cattleservice "https://github.com/viknesh74/biosense/blob/main/src/services/cattleService.js"
click node_telemetryservice "https://github.com/viknesh74/biosense/blob/main/src/services/telemetryService.js"
click node_alertservice "https://github.com/viknesh74/biosense/blob/main/src/services/alertService.js"
click node_consultservice "https://github.com/viknesh74/biosense/blob/main/src/services/consultationService.js"
click node_firebase "https://github.com/viknesh74/biosense/blob/main/src/services/firebase.js"
click node_mockdata "https://github.com/viknesh74/biosense/blob/main/src/services/mockData.js"

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_entry,node_router toneBlue
class node_farmerdash,node_cattledetails,node_herdanalytics,node_healthanalytics,node_gps,node_alertsview toneAmber
class node_doctor,node_consultview,node_ai,node_vetservices,node_schemes,node_chatbot toneMint
class node_context,node_cattlehook,node_telemetryhook,node_alerthook,node_consult_hook,node_cattleservice,node_telemetryservice,node_alertservice,node_consultservice,node_firebase,node_mockdata toneRose
class node_user toneIndigo
```

## Components

### App shell

- [React entry](https://github.com/viknesh74/biosense/blob/main/src/main.jsx): `src/main.jsx`
- [Role router](https://github.com/viknesh74/biosense/blob/main/src/App.jsx): `src/App.jsx`

### Herd monitoring

- [Farmer dashboard](https://github.com/viknesh74/biosense/blob/main/src/pages/FarmerDashboard.jsx): `src/pages/FarmerDashboard.jsx`
- [Cattle details](https://github.com/viknesh74/biosense/blob/main/src/pages/CattleDetails.jsx): `src/pages/CattleDetails.jsx`
- [Herd analytics](https://github.com/viknesh74/biosense/blob/main/src/pages/HerdAnalytics.jsx): `src/pages/HerdAnalytics.jsx`
- [Health analytics](https://github.com/viknesh74/biosense/blob/main/src/pages/HealthAnalytics.jsx): `src/pages/HealthAnalytics.jsx`
- [GPS tracking](https://github.com/viknesh74/biosense/blob/main/src/pages/GPSTracking.jsx): `src/pages/GPSTracking.jsx`
- [Alerts view](https://github.com/viknesh74/biosense/blob/main/src/pages/Alerts.jsx): `src/pages/Alerts.jsx`

### Care workflows

- [Doctor dashboard](https://github.com/viknesh74/biosense/blob/main/src/pages/DoctorDashboard.jsx): `src/pages/DoctorDashboard.jsx`
- [Consultations](https://github.com/viknesh74/biosense/blob/main/src/pages/Consultation.jsx): `src/pages/Consultation.jsx`
- [Cattle care AI](https://github.com/viknesh74/biosense/blob/main/src/pages/CattleCareAI.jsx): `src/pages/CattleCareAI.jsx`
- [Veterinary services](https://github.com/viknesh74/biosense/blob/main/src/pages/VeterinaryServices.jsx): `src/pages/VeterinaryServices.jsx`
- [Government schemes](https://github.com/viknesh74/biosense/blob/main/src/pages/GovernmentSchemes.jsx): `src/pages/GovernmentSchemes.jsx`
- [Assistant chatbot](https://github.com/viknesh74/biosense/blob/main/src/components/Chatbot.jsx): `src/components/Chatbot.jsx`

### State and data

- [App state](https://github.com/viknesh74/biosense/blob/main/src/context/AppContext.jsx): `src/context/AppContext.jsx`
- [Cattle state hook](https://github.com/viknesh74/biosense/blob/main/src/hooks/useCattle.js): `src/hooks/useCattle.js`
- [Telemetry hook](https://github.com/viknesh74/biosense/blob/main/src/hooks/useTelemetry.js): `src/hooks/useTelemetry.js`
- [Alerts hook](https://github.com/viknesh74/biosense/blob/main/src/hooks/useAlerts.js): `src/hooks/useAlerts.js`
- [Consultation hook](https://github.com/viknesh74/biosense/blob/main/src/hooks/useConsultations.js): `src/hooks/useConsultations.js`
- [Cattle records](https://github.com/viknesh74/biosense/blob/main/src/services/cattleService.js): `src/services/cattleService.js`
- [Telemetry service](https://github.com/viknesh74/biosense/blob/main/src/services/telemetryService.js): `src/services/telemetryService.js`
- [Alert service](https://github.com/viknesh74/biosense/blob/main/src/services/alertService.js): `src/services/alertService.js`
- [Consultation service](https://github.com/viknesh74/biosense/blob/main/src/services/consultationService.js): `src/services/consultationService.js`
- [Firebase client](https://github.com/viknesh74/biosense/blob/main/src/services/firebase.js): `src/services/firebase.js`
- [Demo data](https://github.com/viknesh74/biosense/blob/main/src/services/mockData.js): `src/services/mockData.js`

### Other components

- **Farmer or vet**

## Connections

- Farmer or vet → React entry: opens app (evidence: `src/main.jsx`)
- React entry → App state: provides state (evidence: `src/main.jsx`)
- React entry → Role router: renders (evidence: `src/main.jsx`)
- Role router → App state: reads state (evidence: `src/App.jsx`)
- Role router → Farmer dashboard: routes to (evidence: `src/App.jsx`)
- Role router → Cattle details: routes to (evidence: `src/App.jsx`)
- Role router → Herd analytics: routes to (evidence: `src/App.jsx`)
- Role router → Health analytics: routes to (evidence: `src/App.jsx`)
- Role router → GPS tracking: routes to (evidence: `src/App.jsx`)
- Role router → Alerts view: routes to (evidence: `src/App.jsx`)
- Role router → Doctor dashboard: routes to (evidence: `src/App.jsx`)
- Role router → Consultations: routes to (evidence: `src/App.jsx`)
- Role router → Cattle care AI: routes to (evidence: `src/App.jsx`)
- Role router → Veterinary services: routes to (evidence: `src/App.jsx`)
- Role router → Government schemes: routes to (evidence: `src/App.jsx`)
- Role router → Assistant chatbot: renders (evidence: `src/App.jsx`)
- App state → Cattle state hook: uses (evidence: `src/context/AppContext.jsx`)
- App state → Telemetry hook: uses (evidence: `src/context/AppContext.jsx`)
- App state → Alerts hook: uses (evidence: `src/context/AppContext.jsx`)
- App state → Consultation hook: uses (evidence: `src/context/AppContext.jsx`)
- Cattle state hook → Cattle records: loads and updates (evidence: `src/hooks/useCattle.js`)
- Telemetry hook → Telemetry service: uses (evidence: `src/hooks/useTelemetry.js`)
- Alerts hook → Alert service: subscribes and updates (evidence: `src/hooks/useAlerts.js`)
- Consultation hook → Consultation service: subscribes and updates (evidence: `src/hooks/useConsultations.js`)
- Cattle records → Firebase client: reads and writes (evidence: `src/services/cattleService.js`)
- Cattle records → Demo data: falls back to (evidence: `src/services/cattleService.js`)
- Telemetry service → Firebase client: uses (evidence: `src/services/telemetryService.js`)
- Telemetry service → Demo data: uses fallback (evidence: `src/services/telemetryService.js`)
- Telemetry service → Alert service: raises alerts (evidence: `src/hooks/useTelemetry.js`)
- Alert service → Firebase client: subscribes and writes (evidence: `src/services/alertService.js`)
- Consultation service → Firebase client: subscribes and writes (evidence: `src/services/consultationService.js`)
