# anas20023/farmora_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/anas20023/farmora_frontend
- Repository: https://github.com/anas20023/farmora_frontend

## Overview

Farmora is a Next.js smart-agriculture marketplace frontend. Its visible user workflow covers account registration or login, authentication through Better Auth, and viewing a profile; the home page currently renders navigation rather than marketplace functionality. The profile route fetches a server-side session, serializes profile data, and renders a client profile view, with a preview fallback when no session is available. The excerpts show the auth service configured for PostgreSQL and Google sign-in. Marketplace capabilities beyond the displayed pages are not evidenced in the supplied files.

Main entry points: [`src/lib/auth-client.ts`](https://github.com/anas20023/farmora_frontend/blob/master/src/lib/auth-client.ts) (Auth client), [`src/app/profile/page.tsx`](https://github.com/anas20023/farmora_frontend/blob/master/src/app/profile/page.tsx) (Profile route), [`src/lib/auth.ts`](https://github.com/anas20023/farmora_frontend/blob/master/src/lib/auth.ts) (Auth service), [`src/app/profile/ProfileClient.tsx`](https://github.com/anas20023/farmora_frontend/blob/master/src/app/profile/ProfileClient.tsx) (Profile view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_home["Home page<br/>[page.tsx]"]
  node_navbar["Navigation<br/>[Navbar.tsx]"]
  node_login["Login<br/>[page.tsx]"]
  node_register["Registration<br/>[page.tsx]"]
end

subgraph group_identity["Identity and sessions"]
  node_auth_ui["Auth client<br/>[auth-client.ts]"]
  node_auth_service["Auth service<br/>[auth.ts]"]
  node_auth_api["Auth API route<br/>[route.ts]"]
end

subgraph group_profile["Profile"]
  node_profile_route["Profile route<br/>[page.tsx]"]
  node_profile_view["Profile view<br/>[ProfileClient.tsx]"]
  node_profile_types["Profile data types<br/>[profile.ts]"]
end

node_visitor(("Visitor"))
node_postgres[("PostgreSQL")]
node_google["Google sign-in"]

node_visitor -.->|"opens"| node_login
node_visitor -.->|"opens"| node_register
node_visitor -.->|"opens"| node_home
node_home -->|"renders"| node_navbar
node_login -->|"authenticates"| node_auth_ui
node_register -->|"creates account"| node_auth_ui
node_navbar -->|"reads session"| node_auth_ui
node_profile_route -->|"fetches session"| node_auth_service
node_profile_route -->|"renders"| node_navbar
node_profile_route -->|"passes profile"| node_profile_view
node_profile_route -->|"types profile"| node_profile_types
node_profile_view -->|"uses types"| node_profile_types
node_profile_view -->|"uses client"| node_auth_ui
node_auth_api -->|"dispatches to"| node_auth_service
node_auth_service -->|"reads and writes"| node_postgres
node_auth_service -->|"configures provider"| node_google
node_auth_ui -.->|"sends auth requests"| node_auth_api

click node_home "https://github.com/anas20023/farmora_frontend/blob/master/src/app/(home)/page.tsx"
click node_navbar "https://github.com/anas20023/farmora_frontend/blob/master/src/components/Navbar.tsx"
click node_login "https://github.com/anas20023/farmora_frontend/blob/master/src/app/login/page.tsx"
click node_register "https://github.com/anas20023/farmora_frontend/blob/master/src/app/register/page.tsx"
click node_profile_route "https://github.com/anas20023/farmora_frontend/blob/master/src/app/profile/page.tsx"
click node_profile_view "https://github.com/anas20023/farmora_frontend/blob/master/src/app/profile/ProfileClient.tsx"
click node_profile_types "https://github.com/anas20023/farmora_frontend/blob/master/src/types/profile.ts"
click node_auth_ui "https://github.com/anas20023/farmora_frontend/blob/master/src/lib/auth-client.ts"
click node_auth_service "https://github.com/anas20023/farmora_frontend/blob/master/src/lib/auth.ts"
click node_auth_api "https://github.com/anas20023/farmora_frontend/blob/master/src/app/api/auth/%5B...all%5D/route.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_home,node_navbar,node_login,node_register toneBlue
class node_auth_ui,node_auth_service,node_auth_api,node_postgres toneAmber
class node_profile_route,node_profile_view,node_profile_types toneMint
class node_visitor,node_google toneIndigo
```

## Components

### Web experience

- [Home page](https://github.com/anas20023/farmora_frontend/blob/master/src/app/(home)/page.tsx): `src/app/(home)/page.tsx`
- [Navigation](https://github.com/anas20023/farmora_frontend/blob/master/src/components/Navbar.tsx): `src/components/Navbar.tsx`
- [Login](https://github.com/anas20023/farmora_frontend/blob/master/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Registration](https://github.com/anas20023/farmora_frontend/blob/master/src/app/register/page.tsx): `src/app/register/page.tsx`

### Identity and sessions

- [Auth client](https://github.com/anas20023/farmora_frontend/blob/master/src/lib/auth-client.ts): `src/lib/auth-client.ts`
- [Auth service](https://github.com/anas20023/farmora_frontend/blob/master/src/lib/auth.ts): `src/lib/auth.ts`
- [Auth API route](https://github.com/anas20023/farmora_frontend/blob/master/src/app/api/auth/%5B...all%5D/route.ts): `src/app/api/auth/[...all]/route.ts`

### Profile

- [Profile route](https://github.com/anas20023/farmora_frontend/blob/master/src/app/profile/page.tsx): `src/app/profile/page.tsx`
- [Profile view](https://github.com/anas20023/farmora_frontend/blob/master/src/app/profile/ProfileClient.tsx): `src/app/profile/ProfileClient.tsx`
- [Profile data types](https://github.com/anas20023/farmora_frontend/blob/master/src/types/profile.ts): `src/types/profile.ts`

### Other components

- **Visitor**
- **PostgreSQL**
- **Google sign-in**

## Connections

- Visitor → Login: opens
- Visitor → Registration: opens
- Visitor → Home page: opens
- Home page → Navigation: renders (evidence: `src/app/(home)/page.tsx`)
- Login → Auth client: authenticates (evidence: `src/app/login/page.tsx`)
- Registration → Auth client: creates account (evidence: `src/app/register/page.tsx`)
- Navigation → Auth client: reads session (evidence: `src/components/Navbar.tsx`)
- Profile route → Auth service: fetches session (evidence: `src/app/profile/page.tsx`)
- Profile route → Navigation: renders (evidence: `src/app/profile/page.tsx`)
- Profile route → Profile view: passes profile (evidence: `src/app/profile/page.tsx`)
- Profile route → Profile data types: types profile (evidence: `src/app/profile/page.tsx`)
- Profile view → Profile data types: uses types (evidence: `src/app/profile/ProfileClient.tsx`)
- Profile view → Auth client: uses client (evidence: `src/app/profile/ProfileClient.tsx`)
- Auth API route → Auth service: dispatches to (evidence: `src/app/api/auth/[...all]/route.ts`)
- Auth service → PostgreSQL: reads and writes (evidence: `src/lib/auth.ts`)
- Auth service → Google sign-in: configures provider (evidence: `src/lib/auth.ts`)
- Auth client → Auth API route: sends auth requests
