How ansari-devhub/farmledger works
FarmLedger is a multi-tenant Django REST API for tracking farm activity from farm and season setup through planting, expenses, labour, harvest, sale, and payment. The principal workflow is owner-authenticated API requests routed to domain viewsets, with planting as the ledger spine and analytics aggregating costs and revenue. The graph includes the documented authentication, ownership, API documentation, and shared-model capabilities. Relationships are limited to the router excerpt, sampled source, SOURCE INDEX references, and README; unsampled wiring is not assumed.
Main entry points: api_router.py API routing · operations/models.py Plantings and expenses · views.py Farm and crop analytics · farms/models.py Farms and seasons
Components 19
Access and API
- API routing
config/api_router.py - JWT authentication
apps/users/views.py - User accounts
apps/users/models.py - Ownership checks
apps/core/permissions.py - OpenAPI schema
config/settings/base.py - Shared model base
apps/core/models.py
Farm Structure
- Farms and seasons
apps/farms/models.py - Crop reference
apps/farms/models.py - Farm endpoints
apps/farms/views.py
Planting Operations
- Plantings and expenses
apps/operations/models.py - Planting endpoints
apps/operations/views.py
Labour
- Workers and logs
apps/labour/models.py - Labour endpoints
apps/labour/views.py
Harvest and Sales
- Harvests and sales
apps/commerce/models.py - Commerce endpoints
apps/commerce/views.py - Farm and crop analytics
apps/commerce/views.py
Other components
- Farm owner
- PostgreSQL
- Redis cache
Connections 30
- Farm owner → API routing: sends requests
- API routing → JWT authentication: routes auth
config/api_router.py - API routing → Farm endpoints: routes farm APIs
config/api_router.py - API routing → Planting endpoints: routes planting APIs
config/api_router.py - API routing → Labour endpoints: routes labour APIs
config/api_router.py - API routing → Commerce endpoints: routes commerce APIs
config/api_router.py - API routing → Farm and crop analytics: routes summaries
config/api_router.py - JWT authentication → User accounts: registers accounts
- Farm endpoints → Farms and seasons: queries farms
apps/farms/views.py - Farm endpoints → Ownership checks: checks ownership
apps/farms/views.py - Planting endpoints → Plantings and expenses: queries plantings
apps/operations/views.py - Planting endpoints → Ownership checks: checks ownership
apps/operations/views.py - Labour endpoints → Workers and logs: queries logs
apps/labour/views.py - Labour endpoints → Plantings and expenses: scopes planting
apps/labour/views.py - Commerce endpoints → Harvests and sales: queries sales
apps/commerce/views.py - Commerce endpoints → Plantings and expenses: scopes harvests
apps/commerce/views.py - Commerce endpoints → Farms and seasons: scopes buyers
apps/commerce/views.py - Farm and crop analytics → Plantings and expenses: aggregates expenses
apps/commerce/views.py - Farm and crop analytics → Workers and logs: aggregates labour
apps/commerce/views.py - Farm and crop analytics → Harvests and sales: aggregates revenue
apps/commerce/views.py - Farm and crop analytics → Redis cache: caches summaries
apps/commerce/views.py - Farms and seasons → Shared model base: inherits timestamps
apps/farms/models.py - Plantings and expenses → Shared model base: inherits timestamps
apps/operations/models.py - Workers and logs → Shared model base: inherits timestamps
apps/labour/models.py - Harvests and sales → Shared model base: inherits timestamps
apps/commerce/models.py - Farms and seasons → PostgreSQL: persists records
- Plantings and expenses → PostgreSQL: persists records
- Workers and logs → PostgreSQL: persists records
- Harvests and sales → PostgreSQL: persists records
- API routing → OpenAPI schema: documents API