# aom19/agri-front architecture

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

- Interactive diagram: https://gitdiagram.com/aom19/agri-front
- Repository: https://github.com/aom19/agri-front

## Overview

Agri Front is a Romanian-language agricultural management frontend. The main workflow is that authenticated users navigate permission-gated modules, whose pages use query hooks and API clients to manage farm data and display results. The graph includes documented dashboard, field operations, fleet/resources, crops, reports, weather, notifications, and administration capabilities. Some page-to-hook wiring is supported by the SOURCE INDEX; unsampled integrations are not expanded into asserted calls.

Main entry points: [`src/routes/components/PrivateRoutes.tsx`](https://github.com/aom19/agri-front/blob/main/src/routes/components/PrivateRoutes.tsx) (Protected routes), [`src/api/axios.ts`](https://github.com/aom19/agri-front/blob/main/src/api/axios.ts) (HTTP client), [`src/store/auth.store.ts`](https://github.com/aom19/agri-front/blob/main/src/store/auth.store.ts) (Auth state), [`src/hooks/useAuth.ts`](https://github.com/aom19/agri-front/blob/main/src/hooks/useAuth.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and navigation"]
  node_routes["Protected routes<br/>[PrivateRoutes.tsx]"]
  node_layout["Dashboard layout"]
  node_auth["Authentication<br/>[useAuth.ts]"]
  node_permissions["Permission checks<br/>[usePermissions.ts]"]
  node_admin["Users and access admin"]
  node_profile["Profile and settings<br/>[ProfilePage.tsx]"]
end

subgraph group_farm["Farm operations"]
  node_fieldops["Field operations"]
  node_fieldhook["Field operation data"]
  node_fieldapi["Field operation API"]
  node_crops["Crops management<br/>[CropsPage.tsx]"]
  node_cropreq["Crop data queries<br/>[useCrops.ts]"]
  node_cropapi["Crop API<br/>[crops.api.ts]"]
  node_fleet["Fleet and assignments"]
  node_resources["Resources and stocks<br/>[ResourcesPage.tsx]"]
  node_stock["Stock management<br/>[StocksPage.tsx]"]
  node_templates["Operation templates"]
end

subgraph group_insight["Insights and weather"]
  node_dashboard["Dashboard"]
  node_reports["Reports<br/>[ReportsPage.tsx]"]
  node_weather["Weather map<br/>[WeatherMapPage.tsx]"]
end

subgraph group_platform["Data and state"]
  node_authstore["Auth state<br/>[auth.store.ts]"]
  node_notifications["Notifications"]
  node_http["HTTP client<br/>[axios.ts]"]
  node_authapi["Auth endpoints<br/>[auth.api.ts]"]
  node_cropstore["Farm data API<br/>[crops.api.ts]"]
  node_notistore["Notification state"]
end

node_user(("Farm user"))
node_backend["Agri backend"]

node_user -->|"navigates"| node_routes
node_routes -->|"renders within"| node_layout
node_routes -->|"routes to"| node_dashboard
node_routes -->|"routes to"| node_profile
node_routes -->|"routes to"| node_admin
node_routes -->|"routes to"| node_weather
node_routes -->|"routes to"| node_fieldops
node_routes -->|"guards with"| node_permissions
node_user -->|"signs in"| node_auth
node_auth -->|"calls"| node_authapi
node_auth -->|"sets tokens"| node_authstore
node_permissions -->|"reads session"| node_authstore
node_permissions -.->|"queries through"| node_http
node_fieldops -->|"uses data"| node_fieldhook
node_fieldhook -->|"calls"| node_fieldapi
node_fieldhook -->|"checks session"| node_authstore
node_cropreq -->|"calls"| node_cropapi
node_cropapi -->|"uses client"| node_http
node_crops -->|"uses queries"| node_cropreq
node_cropstore -->|"uses client"| node_http
node_fleet -.->|"manages fleet"| node_backend
node_resources -.->|"manages resources"| node_backend
node_stock -.->|"manages stock"| node_backend
node_templates -.->|"manages templates"| node_backend
node_reports -.->|"requests reports"| node_backend
node_weather -.->|"requests forecasts"| node_backend
node_notifications -.->|"receives updates"| node_backend
node_http -.->|"sends requests"| node_backend
node_http -->|"refreshes tokens"| node_authstore
node_http -->|"signals expiry"| node_notistore

click node_routes "https://github.com/aom19/agri-front/blob/main/src/routes/components/PrivateRoutes.tsx"
click node_layout "https://github.com/aom19/agri-front/blob/main/src/layouts/DashboardLayout.tsx"
click node_auth "https://github.com/aom19/agri-front/blob/main/src/hooks/useAuth.ts"
click node_authstore "https://github.com/aom19/agri-front/blob/main/src/store/auth.store.ts"
click node_permissions "https://github.com/aom19/agri-front/blob/main/src/hooks/usePermissions.ts"
click node_dashboard "https://github.com/aom19/agri-front/tree/main/src/pages/dashboard"
click node_fieldops "https://github.com/aom19/agri-front/tree/main/src/pages/field-operations"
click node_fieldhook "https://github.com/aom19/agri-front/blob/main/src/hooks/useFieldOperations.ts"
click node_fieldapi "https://github.com/aom19/agri-front/blob/main/src/api/fieldOperation.api.ts"
click node_crops "https://github.com/aom19/agri-front/blob/main/src/pages/crops/CropsPage.tsx"
click node_cropreq "https://github.com/aom19/agri-front/blob/main/src/hooks/useCrops.ts"
click node_cropapi "https://github.com/aom19/agri-front/blob/main/src/api/crops.api.ts"
click node_fleet "https://github.com/aom19/agri-front/blob/main/src/pages/assignments/AssignmentsPage.tsx"
click node_resources "https://github.com/aom19/agri-front/blob/main/src/pages/resources/ResourcesPage.tsx"
click node_stock "https://github.com/aom19/agri-front/blob/main/src/pages/stocks/StocksPage.tsx"
click node_templates "https://github.com/aom19/agri-front/blob/main/src/pages/operations/OperationTemplatesPage.tsx"
click node_admin "https://github.com/aom19/agri-front/tree/main/src/pages/admin"
click node_profile "https://github.com/aom19/agri-front/blob/main/src/pages/profile/ProfilePage.tsx"
click node_reports "https://github.com/aom19/agri-front/blob/main/src/pages/reports/ReportsPage.tsx"
click node_weather "https://github.com/aom19/agri-front/blob/main/src/pages/weather/WeatherMapPage.tsx"
click node_notifications "https://github.com/aom19/agri-front/blob/main/src/pages/notifications/NotificationsPage.tsx"
click node_http "https://github.com/aom19/agri-front/blob/main/src/api/axios.ts"
click node_authapi "https://github.com/aom19/agri-front/blob/main/src/api/auth.api.ts"
click node_cropstore "https://github.com/aom19/agri-front/blob/main/src/api/crops.api.ts"
click node_notistore "https://github.com/aom19/agri-front/blob/main/src/store/notification.store.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_routes,node_layout,node_auth,node_permissions,node_admin,node_profile,node_user toneBlue
class node_fieldops,node_fieldhook,node_fieldapi,node_crops,node_cropreq,node_cropapi,node_fleet,node_resources,node_stock,node_templates toneAmber
class node_dashboard,node_reports,node_weather toneMint
class node_authstore,node_notifications,node_http,node_authapi,node_cropstore,node_notistore toneRose
class node_backend toneIndigo
```

## Components

### Access and navigation

- [Protected routes](https://github.com/aom19/agri-front/blob/main/src/routes/components/PrivateRoutes.tsx): `src/routes/components/PrivateRoutes.tsx`
- [Dashboard layout](https://github.com/aom19/agri-front/blob/main/src/layouts/DashboardLayout.tsx): `src/layouts/DashboardLayout.tsx`
- [Authentication](https://github.com/aom19/agri-front/blob/main/src/hooks/useAuth.ts): `src/hooks/useAuth.ts`
- [Permission checks](https://github.com/aom19/agri-front/blob/main/src/hooks/usePermissions.ts): `src/hooks/usePermissions.ts`
- [Users and access admin](https://github.com/aom19/agri-front/tree/main/src/pages/admin): `src/pages/admin`
- [Profile and settings](https://github.com/aom19/agri-front/blob/main/src/pages/profile/ProfilePage.tsx): `src/pages/profile/ProfilePage.tsx`

### Farm operations

- [Field operations](https://github.com/aom19/agri-front/tree/main/src/pages/field-operations): `src/pages/field-operations`
- [Field operation data](https://github.com/aom19/agri-front/blob/main/src/hooks/useFieldOperations.ts): `src/hooks/useFieldOperations.ts`
- [Field operation API](https://github.com/aom19/agri-front/blob/main/src/api/fieldOperation.api.ts): `src/api/fieldOperation.api.ts`
- [Crops management](https://github.com/aom19/agri-front/blob/main/src/pages/crops/CropsPage.tsx): `src/pages/crops/CropsPage.tsx`
- [Crop data queries](https://github.com/aom19/agri-front/blob/main/src/hooks/useCrops.ts): `src/hooks/useCrops.ts`
- [Crop API](https://github.com/aom19/agri-front/blob/main/src/api/crops.api.ts): `src/api/crops.api.ts`
- [Fleet and assignments](https://github.com/aom19/agri-front/blob/main/src/pages/assignments/AssignmentsPage.tsx): `src/pages/assignments/AssignmentsPage.tsx`
- [Resources and stocks](https://github.com/aom19/agri-front/blob/main/src/pages/resources/ResourcesPage.tsx): `src/pages/resources/ResourcesPage.tsx`
- [Stock management](https://github.com/aom19/agri-front/blob/main/src/pages/stocks/StocksPage.tsx): `src/pages/stocks/StocksPage.tsx`
- [Operation templates](https://github.com/aom19/agri-front/blob/main/src/pages/operations/OperationTemplatesPage.tsx): `src/pages/operations/OperationTemplatesPage.tsx`

### Insights and weather

- [Dashboard](https://github.com/aom19/agri-front/tree/main/src/pages/dashboard): `src/pages/dashboard`
- [Reports](https://github.com/aom19/agri-front/blob/main/src/pages/reports/ReportsPage.tsx): `src/pages/reports/ReportsPage.tsx`
- [Weather map](https://github.com/aom19/agri-front/blob/main/src/pages/weather/WeatherMapPage.tsx): `src/pages/weather/WeatherMapPage.tsx`

### Data and state

- [Auth state](https://github.com/aom19/agri-front/blob/main/src/store/auth.store.ts): `src/store/auth.store.ts`
- [Notifications](https://github.com/aom19/agri-front/blob/main/src/pages/notifications/NotificationsPage.tsx): `src/pages/notifications/NotificationsPage.tsx`
- [HTTP client](https://github.com/aom19/agri-front/blob/main/src/api/axios.ts): `src/api/axios.ts`
- [Auth endpoints](https://github.com/aom19/agri-front/blob/main/src/api/auth.api.ts): `src/api/auth.api.ts`
- [Farm data API](https://github.com/aom19/agri-front/blob/main/src/api/crops.api.ts): `src/api/crops.api.ts`
- [Notification state](https://github.com/aom19/agri-front/blob/main/src/store/notification.store.ts): `src/store/notification.store.ts`

### Other components

- **Farm user**
- **Agri backend**

## Connections

- Farm user → Protected routes: navigates (evidence: `src/routes/components/PrivateRoutes.tsx`)
- Protected routes → Dashboard layout: renders within (evidence: `src/routes/components/PrivateRoutes.tsx`)
- Protected routes → Dashboard: routes to (evidence: `src/routes/components/PrivateRoutes.tsx`)
- Protected routes → Profile and settings: routes to (evidence: `src/routes/components/PrivateRoutes.tsx`)
- Protected routes → Users and access admin: routes to (evidence: `src/routes/components/PrivateRoutes.tsx`)
- Protected routes → Weather map: routes to (evidence: `src/routes/components/PrivateRoutes.tsx`)
- Protected routes → Field operations: routes to (evidence: `src/routes/components/PrivateRoutes.tsx`)
- Protected routes → Permission checks: guards with (evidence: `src/routes/components/PrivateRoutes.tsx`)
- Farm user → Authentication: signs in (evidence: `src/hooks/useAuth.ts`)
- Authentication → Auth endpoints: calls (evidence: `src/hooks/useAuth.ts`)
- Authentication → Auth state: sets tokens (evidence: `src/hooks/useAuth.ts`)
- Permission checks → Auth state: reads session (evidence: `src/hooks/usePermissions.ts`)
- Permission checks → HTTP client: queries through
- Field operations → Field operation data: uses data (evidence: `src/pages/field-operations/FieldOperationDetailPage.tsx`)
- Field operation data → Field operation API: calls (evidence: `src/hooks/useFieldOperations.ts`)
- Field operation data → Auth state: checks session (evidence: `src/hooks/useFieldOperations.ts`)
- Crop data queries → Crop API: calls (evidence: `src/hooks/useCrops.ts`)
- Crop API → HTTP client: uses client (evidence: `src/api/crops.api.ts`)
- Crops management → Crop data queries: uses queries (evidence: `src/pages/crops/CropsPage.tsx`)
- Farm data API → HTTP client: uses client (evidence: `src/api/crops.api.ts`)
- Fleet and assignments → Agri backend: manages fleet
- Resources and stocks → Agri backend: manages resources
- Stock management → Agri backend: manages stock
- Operation templates → Agri backend: manages templates
- Reports → Agri backend: requests reports
- Weather map → Agri backend: requests forecasts
- Notifications → Agri backend: receives updates
- HTTP client → Agri backend: sends requests (evidence: `src/api/axios.ts`)
- HTTP client → Auth state: refreshes tokens (evidence: `src/api/axios.ts`)
- HTTP client → Notification state: signals expiry (evidence: `src/api/axios.ts`)
