How villanuevayanmar/pig-ledger works
Pig Ledger is a mobile-first piggery accounting and farm-management application. Its principal workflow is recording farm activity and financial transactions, then reviewing summaries and reports; offline storage and sync support working across connectivity changes. The tree also shows batch, feeding, health, customer, and supplier management capabilities. Evidence is limited: the README establishes the product and technology, while sampled source confirms selected storage, calculations, and sync behavior; many page-to-component links were not shown, so they are omitted.
Main entry points: local-store.ts Offline ledger · route.ts Sync endpoint · data.ts Farm data access · totals.ts Financial totals
Components 25
Farm Operations
- Batch management
PigLedger/components/BatchClient.tsx - Fattening
PigLedger/components/FatteningClient.tsx - Farm operations
PigLedger/components/OperationsClient.tsx - Herd monitoring
PigLedger/components/MonitoringClient.tsx - Business records
PigLedger/components/BusinessClient.tsx
Accounting & Reports
- Expense tracking
PigLedger/components/ExpensesClient.tsx - Sales tracking
PigLedger/components/SalesClient.tsx - Transactions view
PigLedger/app/transactions/page.tsx - Reports
PigLedger/app/reports/page.tsx - Farm dashboard
PigLedger/components/HomeClient.tsx - Financial totals
PigLedger/lib/totals.ts - Ledger calculations
PigLedger/lib/ledger-math.mjs - Formatting utilities
PigLedger/lib/format.ts
Offline & Sync
- Sync endpoint
PigLedger/app/api/sync/route.ts - Offline ledger
PigLedger/lib/local-store.ts - Pending record merge
PigLedger/lib/pending-records.mjs - Legacy migration
PigLedger/lib/legacy-migration.mjs - Stable identifiers
PigLedger/lib/idempotency.mjs - Browser Supabase client
PigLedger/lib/supabase/client.ts - Farm data access
PigLedger/lib/data.ts
Application Platform
- Farm settings
PigLedger/components/SettingsClient.tsx - Authentication
PigLedger/components/AuthForm.tsx - Server actions
PigLedger/app/actions.ts
Other components
- Farm user
- Supabase Auth & PostgreSQL
Connections 10
- Offline ledger → Legacy migration: checks migration
PigLedger/lib/local-store.ts - Offline ledger → Pending record merge: merges pending
PigLedger/lib/local-store.ts - Offline ledger → Stable identifiers: stabilizes IDs
PigLedger/lib/local-store.ts - Offline ledger → Browser Supabase client: gets session
PigLedger/lib/local-store.ts - Sync endpoint → Farm data access: ensures farm
PigLedger/app/api/sync/route.ts - Sync endpoint → Stable identifiers: stabilizes IDs
PigLedger/app/api/sync/route.ts - Sync endpoint → Supabase Auth & PostgreSQL: authenticates and writes
PigLedger/app/api/sync/route.ts - Farm data access → Financial totals: computes totals
PigLedger/lib/data.ts - Financial totals → Ledger calculations: delegates calculations
PigLedger/lib/totals.ts - Farm data access → Formatting utilities: uses numeric helpers
PigLedger/lib/data.ts