# bekkamhari/sheep-farm-app architecture

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

- Interactive diagram: https://gitdiagram.com/bekkamhari/sheep-farm-app
- Repository: https://github.com/bekkamhari/sheep-farm-app

## Overview

Sheep Farm is a web dashboard for managing sheep and goats. The visible workflow is login, then load animal and feed data, add animals, and request health records; backend routes handle API operations against PostgreSQL-backed models. The README provides no further product detail, so feed-scheduling behavior and other backend capabilities are represented only where the source index supports them. Several backend files were not excerpted, so uncertain internal calls are omitted.

Main entry points: [`sheep-farm-ts/backend/src/index.ts`](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/index.ts) (API server), [`sheep-farm-ts/backend/src/models/index.ts`](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/index.ts) (Database setup), [`sheep-farm-ts/frontend/src/api.js`](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/frontend/src/api.js) (API client), [`sheep-farm-ts/backend/src/routes/auth.ts`](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/routes/auth.ts) (Login route)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Farm dashboard"]
  node_app["Dashboard app<br/>[App.js]"]
  node_login["Login form<br/>[Login.js]"]
  node_animalview["Animal dashboard<br/>[AnimalList.js]"]
  node_clientapi["API client<br/>[api.js]"]
end

subgraph group_backend["Backend API"]
  node_server["API server<br/>[index.ts]"]
  node_config["App config<br/>[config.ts]"]
  node_authroute["Login route<br/>[auth.ts]"]
  node_authmw["Token middleware<br/>[auth.ts]"]
  node_animalroute["Animal routes<br/>[animals.ts]"]
  node_healthroute["Health routes<br/>[health.ts]"]
  node_feedroute["Feed routes<br/>[feed.ts]"]
  node_scheduler["Feed scheduler<br/>[feedScheduler.ts]"]
end

subgraph group_domain["Farm records"]
  node_animal["Animal records<br/>[animal.ts]"]
  node_health["Health records<br/>[healthRecord.ts]"]
  node_feed["Feed schedules<br/>[feedSchedule.ts]"]
  node_user["User records<br/>[user.ts]"]
  node_role["Role records<br/>[role.ts]"]
end

subgraph group_platform["Persistence"]
  node_dbsetup["Database setup<br/>[index.ts]"]
  node_postgres[("PostgreSQL")]
end

node_farmer(("Farm user"))

node_farmer -->|"uses"| node_app
node_app -->|"shows when logged out"| node_login
node_app -->|"shows when logged in"| node_animalview
node_login -->|"submits credentials"| node_clientapi
node_animalview -->|"requests farm data"| node_clientapi
node_clientapi -->|"posts login"| node_authroute
node_clientapi -->|"requests animals"| node_animalroute
node_clientapi -->|"requests health"| node_healthroute
node_clientapi -->|"requests schedules"| node_feedroute
node_server -->|"loads"| node_config
node_server -->|"initializes"| node_dbsetup
node_server -->|"registers"| node_authroute
node_server -->|"registers"| node_animalroute
node_server -->|"registers"| node_healthroute
node_server -->|"registers"| node_feedroute
node_server -->|"imports"| node_authmw
node_server -->|"imports"| node_scheduler
node_authroute -->|"looks up users"| node_user
node_authroute -->|"loads role"| node_role
node_animalroute -->|"handles animal data"| node_animal
node_healthroute -->|"handles health data"| node_health
node_feedroute -->|"handles schedules"| node_feed
node_scheduler -->|"uses schedules"| node_feed
node_dbsetup -->|"reads settings"| node_config
node_dbsetup -->|"registers model"| node_animal
node_dbsetup -->|"registers model"| node_health
node_dbsetup -->|"registers model"| node_feed
node_dbsetup -->|"registers model"| node_user
node_dbsetup -->|"registers model"| node_role
node_dbsetup -->|"connects to"| node_postgres
node_animal -->|"has many"| node_health
node_user -->|"belongs to"| node_role

click node_app "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/frontend/src/App.js"
click node_login "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/frontend/src/components/Login.js"
click node_animalview "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/frontend/src/components/AnimalList.js"
click node_clientapi "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/frontend/src/api.js"
click node_server "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/index.ts"
click node_config "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/config.ts"
click node_authroute "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/routes/auth.ts"
click node_authmw "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/middleware/auth.ts"
click node_animalroute "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/routes/animals.ts"
click node_healthroute "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/routes/health.ts"
click node_feedroute "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/routes/feed.ts"
click node_scheduler "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/services/feedScheduler.ts"
click node_animal "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/animal.ts"
click node_health "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/healthRecord.ts"
click node_feed "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/feedSchedule.ts"
click node_user "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/user.ts"
click node_role "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/role.ts"
click node_dbsetup "https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/index.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_app,node_login,node_animalview,node_clientapi,node_farmer toneBlue
class node_server,node_config,node_authroute,node_authmw,node_animalroute,node_healthroute,node_feedroute,node_scheduler toneAmber
class node_animal,node_health,node_feed,node_user,node_role toneMint
class node_dbsetup,node_postgres toneRose
```

## Components

### Farm dashboard

- [Dashboard app](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/frontend/src/App.js): `sheep-farm-ts/frontend/src/App.js`
- [Login form](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/frontend/src/components/Login.js): `sheep-farm-ts/frontend/src/components/Login.js`
- [Animal dashboard](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/frontend/src/components/AnimalList.js): `sheep-farm-ts/frontend/src/components/AnimalList.js`
- [API client](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/frontend/src/api.js): `sheep-farm-ts/frontend/src/api.js`

### Backend API

- [API server](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/index.ts): `sheep-farm-ts/backend/src/index.ts`
- [App config](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/config.ts): `sheep-farm-ts/backend/src/config.ts`
- [Login route](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/routes/auth.ts): `sheep-farm-ts/backend/src/routes/auth.ts`
- [Token middleware](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/middleware/auth.ts): `sheep-farm-ts/backend/src/middleware/auth.ts`
- [Animal routes](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/routes/animals.ts): `sheep-farm-ts/backend/src/routes/animals.ts`
- [Health routes](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/routes/health.ts): `sheep-farm-ts/backend/src/routes/health.ts`
- [Feed routes](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/routes/feed.ts): `sheep-farm-ts/backend/src/routes/feed.ts`
- [Feed scheduler](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/services/feedScheduler.ts): `sheep-farm-ts/backend/src/services/feedScheduler.ts`

### Farm records

- [Animal records](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/animal.ts): `sheep-farm-ts/backend/src/models/animal.ts`
- [Health records](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/healthRecord.ts): `sheep-farm-ts/backend/src/models/healthRecord.ts`
- [Feed schedules](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/feedSchedule.ts): `sheep-farm-ts/backend/src/models/feedSchedule.ts`
- [User records](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/user.ts): `sheep-farm-ts/backend/src/models/user.ts`
- [Role records](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/role.ts): `sheep-farm-ts/backend/src/models/role.ts`

### Persistence

- [Database setup](https://github.com/bekkamhari/sheep-farm-app/blob/main/sheep-farm-ts/backend/src/models/index.ts): `sheep-farm-ts/backend/src/models/index.ts`
- **PostgreSQL**

### Other components

- **Farm user**

## Connections

- Farm user → Dashboard app: uses
- Dashboard app → Login form: shows when logged out (evidence: `sheep-farm-ts/frontend/src/App.js`)
- Dashboard app → Animal dashboard: shows when logged in (evidence: `sheep-farm-ts/frontend/src/App.js`)
- Login form → API client: submits credentials (evidence: `sheep-farm-ts/frontend/src/components/Login.js`)
- Animal dashboard → API client: requests farm data (evidence: `sheep-farm-ts/frontend/src/components/AnimalList.js`)
- API client → Login route: posts login (evidence: `sheep-farm-ts/frontend/src/api.js`)
- API client → Animal routes: requests animals (evidence: `sheep-farm-ts/frontend/src/api.js`)
- API client → Health routes: requests health (evidence: `sheep-farm-ts/frontend/src/api.js`)
- API client → Feed routes: requests schedules (evidence: `sheep-farm-ts/frontend/src/api.js`)
- API server → App config: loads (evidence: `sheep-farm-ts/backend/src/index.ts`)
- API server → Database setup: initializes (evidence: `sheep-farm-ts/backend/src/index.ts`)
- API server → Login route: registers (evidence: `sheep-farm-ts/backend/src/index.ts`)
- API server → Animal routes: registers (evidence: `sheep-farm-ts/backend/src/index.ts`)
- API server → Health routes: registers (evidence: `sheep-farm-ts/backend/src/index.ts`)
- API server → Feed routes: registers (evidence: `sheep-farm-ts/backend/src/index.ts`)
- API server → Token middleware: imports (evidence: `sheep-farm-ts/backend/src/index.ts`)
- API server → Feed scheduler: imports (evidence: `sheep-farm-ts/backend/src/index.ts`)
- Login route → User records: looks up users (evidence: `sheep-farm-ts/backend/src/routes/auth.ts`)
- Login route → Role records: loads role (evidence: `sheep-farm-ts/backend/src/routes/auth.ts`)
- Animal routes → Animal records: handles animal data (evidence: `sheep-farm-ts/backend/src/routes/animals.ts`)
- Health routes → Health records: handles health data (evidence: `sheep-farm-ts/backend/src/routes/health.ts`)
- Feed routes → Feed schedules: handles schedules (evidence: `sheep-farm-ts/backend/src/routes/feed.ts`)
- Feed scheduler → Feed schedules: uses schedules (evidence: `sheep-farm-ts/backend/src/services/feedScheduler.ts`)
- Database setup → App config: reads settings (evidence: `sheep-farm-ts/backend/src/models/index.ts`)
- Database setup → Animal records: registers model (evidence: `sheep-farm-ts/backend/src/models/index.ts`)
- Database setup → Health records: registers model (evidence: `sheep-farm-ts/backend/src/models/index.ts`)
- Database setup → Feed schedules: registers model (evidence: `sheep-farm-ts/backend/src/models/index.ts`)
- Database setup → User records: registers model (evidence: `sheep-farm-ts/backend/src/models/index.ts`)
- Database setup → Role records: registers model (evidence: `sheep-farm-ts/backend/src/models/index.ts`)
- Database setup → PostgreSQL: connects to (evidence: `sheep-farm-ts/backend/src/models/index.ts`)
- Animal records → Health records: has many (evidence: `sheep-farm-ts/backend/src/models/animal.ts`)
- User records → Role records: belongs to (evidence: `sheep-farm-ts/backend/src/models/user.ts`)
