# anang-programmer/prima architecture

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

- Interactive diagram: https://gitdiagram.com/anang-programmer/prima
- Repository: https://github.com/anang-programmer/prima

## Overview

PRIMA is a mobile-first shrimp-farming management app. Farmers manage ponds and grow-out cycles, record feed, probiotic, sampling and Anco observations, then use recommendations, monitoring and harvest projections to guide operations. Separate branches provide AI consultation, farmer-community features, and reminders with push notifications. The sampled pond page directly uses calculation helpers and Supabase; notification routes document their database and FCM work. Community and several other feature paths are present in the tree but their implementation was not sampled, so their internal wiring is left unspecified.

Main entry points: [`src/app/kolam/[id]/page.tsx`](https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/page.tsx) (Pond And Cycle), [`src/app/api/notifikasi/kirim/route.ts`](https://github.com/anang-programmer/prima/blob/main/src/app/api/notifikasi/kirim/route.ts) (Timer Push Route), [`src/app/api/notifikasi/sosial/route.ts`](https://github.com/anang-programmer/prima/blob/main/src/app/api/notifikasi/sosial/route.ts) (Social Push Route), [`src/app/api/ai-konsultasi/route.ts`](https://github.com/anang-programmer/prima/blob/main/src/app/api/ai-konsultasi/route.ts) (AI Consultation API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pond_ops["Pond Operations"]
  node_dashboard["Pond Dashboard<br/>[page.tsx]"]
  node_pond_detail["Pond And Cycle<br/>[page.tsx]"]
  node_pond_forms["Pond Entry Forms"]
  node_feed_calc["Feed Calculator<br/>[feed-calculator.ts]"]
  node_logbook_ui["Farm Logbook<br/>[LogBookTab.tsx]"]
  node_anco_ui["Anco Records<br/>[AncoModal.tsx]"]
end

subgraph group_insights["Cycle Insights"]
  node_monitoring["Growth Monitoring<br/>[MonitoringTab.tsx]"]
  node_projection["Harvest Projection<br/>[ProjectionTab.tsx]"]
  node_history["Cycle History<br/>[page.tsx]"]
  node_historical_derive["Cycle Data Derivation<br/>[derive.ts]"]
end

subgraph group_community["Farmer Community"]
  node_community_feed["Community Feed<br/>[page.tsx]"]
  node_community_post["Community Post<br/>[page.tsx]"]
end

subgraph group_assist["AI Assistance"]
  node_ai_consult["AI Consultation UI<br/>[ConsultAISheet.tsx]"]
  node_ai_route["AI Consultation API<br/>[route.ts]"]
end

subgraph group_platform["Data And Alerts"]
  node_auth["Sign In And Registration<br/>[page.tsx]"]
  node_supabase_client["Supabase Clients<br/>[client.ts]"]
  node_timer_context["Timer Context<br/>[TimerContext.tsx]"]
  node_timer_api["Timer Push Route<br/>[route.ts]"]
  node_social_api["Social Push Route<br/>[route.ts]"]
  node_notifications_ui["Notifications UI<br/>[page.tsx]"]
  node_fcm_manager["FCM Token Manager"]
end

node_farmer(("Farmer"))
node_ai_providers{{"AI Providers"}}
node_supabase_store[("Supabase")]
node_mobile_bridge{{"Android WebView Bridge"}}
node_fcm{{"Firebase Cloud Messaging"}}
node_cron(("Scheduled Cron"))

node_farmer -->|"signs in"| node_auth
node_farmer -->|"manages ponds"| node_dashboard
node_dashboard -->|"opens pond"| node_pond_detail
node_farmer -->|"enters farm data"| node_pond_forms
node_pond_detail -->|"calculates feed"| node_feed_calc
node_pond_detail -->|"reads and writes"| node_supabase_client
node_pond_detail -->|"requests consultation"| node_ai_route
node_ai_route -->|"sends chat"| node_ai_providers
node_ai_route -->|"returns reply"| node_pond_detail
node_pond_detail -->|"derives cycle data"| node_historical_derive
node_pond_detail -->|"displays monitoring"| node_monitoring
node_pond_detail -->|"displays projections"| node_projection
node_farmer -->|"reviews harvests"| node_history
node_farmer -->|"shares insights"| node_community_feed
node_community_feed -->|"opens post"| node_community_post
node_community_post -.->|"requests social alert"| node_social_api
node_farmer -->|"records farm activity"| node_logbook_ui
node_farmer -->|"records Anco result"| node_anco_ui
node_cron -->|"triggers due checks"| node_timer_api
node_timer_api -->|"queries and updates timers"| node_supabase_store
node_timer_api -->|"loads ponds and tokens"| node_supabase_store
node_timer_api -->|"sends push alerts"| node_fcm
node_timer_api -->|"gets OAuth token"| node_fcm
node_social_api -->|"loads post and tokens"| node_supabase_store
node_social_api -->|"sends social push"| node_fcm
node_social_api -->|"gets OAuth token"| node_fcm
node_timer_context -->|"supports reminders"| node_notifications_ui
node_fcm_manager -->|"requests device token"| node_mobile_bridge
node_fcm_manager -->|"upserts device token"| node_supabase_store
node_auth -->|"authenticates"| node_supabase_client
node_pond_detail -->|"shows cycle measures"| node_monitoring

click node_dashboard "https://github.com/anang-programmer/prima/blob/main/src/app/dashboard/page.tsx"
click node_pond_detail "https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/page.tsx"
click node_pond_forms "https://github.com/anang-programmer/prima/tree/main/src/app/dashboard/_components"
click node_feed_calc "https://github.com/anang-programmer/prima/blob/main/src/lib/feed-calculator.ts"
click node_logbook_ui "https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/_components/LogBookTab.tsx"
click node_anco_ui "https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/_components/AncoModal.tsx"
click node_monitoring "https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/_components/MonitoringTab.tsx"
click node_projection "https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/_components/ProjectionTab.tsx"
click node_history "https://github.com/anang-programmer/prima/blob/main/src/app/riwayat-panen/page.tsx"
click node_community_feed "https://github.com/anang-programmer/prima/blob/main/src/app/komunitas/page.tsx"
click node_community_post "https://github.com/anang-programmer/prima/blob/main/src/app/komunitas/%5Bid%5D/page.tsx"
click node_ai_consult "https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/_components/ConsultAISheet.tsx"
click node_ai_route "https://github.com/anang-programmer/prima/blob/main/src/app/api/ai-konsultasi/route.ts"
click node_auth "https://github.com/anang-programmer/prima/blob/main/src/app/masuk/page.tsx"
click node_supabase_client "https://github.com/anang-programmer/prima/blob/main/src/lib/supabase/client.ts"
click node_timer_context "https://github.com/anang-programmer/prima/blob/main/src/context/TimerContext.tsx"
click node_timer_api "https://github.com/anang-programmer/prima/blob/main/src/app/api/notifikasi/kirim/route.ts"
click node_social_api "https://github.com/anang-programmer/prima/blob/main/src/app/api/notifikasi/sosial/route.ts"
click node_notifications_ui "https://github.com/anang-programmer/prima/blob/main/src/app/notifikasi/page.tsx"
click node_fcm_manager "https://github.com/anang-programmer/prima/blob/main/src/components/FcmTokenManager.tsx"
click node_historical_derive "https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/_lib/derive.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_dashboard,node_pond_detail,node_pond_forms,node_feed_calc,node_logbook_ui,node_anco_ui,node_mobile_bridge toneBlue
class node_monitoring,node_projection,node_history,node_historical_derive,node_supabase_store toneAmber
class node_community_feed,node_community_post toneMint
class node_ai_consult,node_ai_route toneRose
class node_auth,node_supabase_client,node_timer_context,node_timer_api,node_social_api,node_notifications_ui,node_fcm_manager,node_farmer,node_ai_providers,node_fcm,node_cron toneIndigo
```

## Components

### Pond Operations

- [Pond Dashboard](https://github.com/anang-programmer/prima/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`
- [Pond And Cycle](https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/page.tsx): `src/app/kolam/[id]/page.tsx`
- [Pond Entry Forms](https://github.com/anang-programmer/prima/tree/main/src/app/dashboard/_components): `src/app/dashboard/_components`
- [Feed Calculator](https://github.com/anang-programmer/prima/blob/main/src/lib/feed-calculator.ts): `src/lib/feed-calculator.ts`
- [Farm Logbook](https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/_components/LogBookTab.tsx): `src/app/kolam/[id]/_components/LogBookTab.tsx`
- [Anco Records](https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/_components/AncoModal.tsx): `src/app/kolam/[id]/_components/AncoModal.tsx`

### Cycle Insights

- [Growth Monitoring](https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/_components/MonitoringTab.tsx): `src/app/kolam/[id]/_components/MonitoringTab.tsx`
- [Harvest Projection](https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/_components/ProjectionTab.tsx): `src/app/kolam/[id]/_components/ProjectionTab.tsx`
- [Cycle History](https://github.com/anang-programmer/prima/blob/main/src/app/riwayat-panen/page.tsx): `src/app/riwayat-panen/page.tsx`
- [Cycle Data Derivation](https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/_lib/derive.ts): `src/app/kolam/[id]/_lib/derive.ts`

### Farmer Community

- [Community Feed](https://github.com/anang-programmer/prima/blob/main/src/app/komunitas/page.tsx): `src/app/komunitas/page.tsx`
- [Community Post](https://github.com/anang-programmer/prima/blob/main/src/app/komunitas/%5Bid%5D/page.tsx): `src/app/komunitas/[id]/page.tsx`

### AI Assistance

- [AI Consultation UI](https://github.com/anang-programmer/prima/blob/main/src/app/kolam/%5Bid%5D/_components/ConsultAISheet.tsx): `src/app/kolam/[id]/_components/ConsultAISheet.tsx`
- [AI Consultation API](https://github.com/anang-programmer/prima/blob/main/src/app/api/ai-konsultasi/route.ts): `src/app/api/ai-konsultasi/route.ts`

### Data And Alerts

- [Sign In And Registration](https://github.com/anang-programmer/prima/blob/main/src/app/masuk/page.tsx): `src/app/masuk/page.tsx`
- [Supabase Clients](https://github.com/anang-programmer/prima/blob/main/src/lib/supabase/client.ts): `src/lib/supabase/client.ts`
- [Timer Context](https://github.com/anang-programmer/prima/blob/main/src/context/TimerContext.tsx): `src/context/TimerContext.tsx`
- [Timer Push Route](https://github.com/anang-programmer/prima/blob/main/src/app/api/notifikasi/kirim/route.ts): `src/app/api/notifikasi/kirim/route.ts`
- [Social Push Route](https://github.com/anang-programmer/prima/blob/main/src/app/api/notifikasi/sosial/route.ts): `src/app/api/notifikasi/sosial/route.ts`
- [Notifications UI](https://github.com/anang-programmer/prima/blob/main/src/app/notifikasi/page.tsx): `src/app/notifikasi/page.tsx`
- [FCM Token Manager](https://github.com/anang-programmer/prima/blob/main/src/components/FcmTokenManager.tsx): `src/components/FcmTokenManager.tsx`

### Other components

- **Farmer**
- **AI Providers**
- **Supabase**
- **Android WebView Bridge**
- **Firebase Cloud Messaging**
- **Scheduled Cron**

## Connections

- Farmer → Sign In And Registration: signs in
- Farmer → Pond Dashboard: manages ponds
- Pond Dashboard → Pond And Cycle: opens pond
- Farmer → Pond Entry Forms: enters farm data
- Pond And Cycle → Feed Calculator: calculates feed
- Pond And Cycle → Supabase Clients: reads and writes
- Pond And Cycle → AI Consultation API: requests consultation
- AI Consultation API → AI Providers: sends chat
- AI Consultation API → Pond And Cycle: returns reply
- Pond And Cycle → Cycle Data Derivation: derives cycle data
- Pond And Cycle → Growth Monitoring: displays monitoring
- Pond And Cycle → Harvest Projection: displays projections
- Farmer → Cycle History: reviews harvests
- Farmer → Community Feed: shares insights
- Community Feed → Community Post: opens post
- Community Post → Social Push Route: requests social alert
- Farmer → Farm Logbook: records farm activity
- Farmer → Anco Records: records Anco result
- Scheduled Cron → Timer Push Route: triggers due checks
- Timer Push Route → Supabase: queries and updates timers
- Timer Push Route → Supabase: loads ponds and tokens
- Timer Push Route → Firebase Cloud Messaging: sends push alerts
- Timer Push Route → Firebase Cloud Messaging: gets OAuth token
- Social Push Route → Supabase: loads post and tokens
- Social Push Route → Firebase Cloud Messaging: sends social push
- Social Push Route → Firebase Cloud Messaging: gets OAuth token
- Timer Context → Notifications UI: supports reminders
- FCM Token Manager → Android WebView Bridge: requests device token
- FCM Token Manager → Supabase: upserts device token
- Sign In And Registration → Supabase Clients: authenticates
- Pond And Cycle → Growth Monitoring: shows cycle measures
