How edilson-nantes/brain-agriculture works
Brain Agriculture API is a NestJS service for managing farmers, their farms, and farm harvests, with a dashboard for aggregate analysis. The main workflow is an HTTP request handled by a domain controller, delegated to a service for validation and persistence, and returned as domain data. Farmer-to-farm and farm-to-harvest relationships are represented in the entities; creating farms and harvests also checks the parent record. PostgreSQL is configured through TypeORM. Some module wiring and dashboard routes are supported by the README or source index rather than sampled implementation excerpts.
Main entry points: app.module.ts Nest application · farm.service.ts Farm service · harvest.service.ts Harvest service · farmer.controller.ts Farmer API
Components 20
Application runtime
- Nest application
src/app.module.ts - PostgreSQL
Farmers and farms
- Farmer API
src/farmer/farmer.controller.ts - Farmer service
src/farmer/farmer.service.ts - Farmer record
src/farmer/entities/farmer.entity.ts - Farmer validation
src/farmer/validators - Farmer DTOs
src/farmer/dtos - Farm API
src/farm/farm.controller.ts - Farm service
src/farm/farm.service.ts - Farm record
src/farm/entities/farm.entity.ts - Farm area checks
src/farm/validators - Farm DTOs
src/farm/dtos
Harvest management
- Harvest API
src/harvest/harvest.controller.ts - Harvest service
src/harvest/harvest.service.ts - Harvest record
src/harvest/entities/harvest.entity.ts - Harvest area checks
src/harvest/validators - Harvest DTOs
src/harvest/dtos
Dashboard analytics
- Dashboard API
src/dashboard/dashboard.controller.ts - Dashboard queries
src/dashboard/dashboard.service.ts
Other components
- API client
Connections 28
- API client → Nest application: sends requests
README.md - Nest application → PostgreSQL: configures TypeORM
src/app.module.ts - Nest application → Farmer API: registers module
src/app.module.ts - Nest application → Farm API: registers module
src/app.module.ts - Nest application → Harvest API: registers module
src/app.module.ts - Nest application → Dashboard API: registers module
src/app.module.ts - API client → Farmer API: calls endpoints
README.md - Farmer API → Farmer service: delegates requests
src/farmer/farmer.controller.ts - Farmer service → Farmer record: persists records
src/farmer/farmer.service.ts - Farmer service → Farmer validation: validates identifier
src/farmer/farmer.service.ts - Farmer API → Farmer DTOs: accepts and returns
src/farmer/farmer.controller.ts - API client → Farm API: calls endpoints
README.md - Farm API → Farm service: delegates requests
src/farm/farm.controller.ts - Farm service → Farm record: persists records
src/farm/farm.service.ts - Farm service → Farmer service: checks farmer
src/farm/farm.service.ts - Farm service → Farm area checks: checks land area
src/farm/farm.service.ts - Farm API → Farm DTOs: accepts and returns
src/farm/farm.controller.ts - API client → Harvest API: calls endpoints
README.md - Harvest API → Harvest service: delegates requests
src/harvest/harvest.controller.ts - Harvest service → Harvest record: persists records
src/harvest/harvest.service.ts - Harvest service → Farm service: checks parent farm
src/harvest/harvest.service.ts - Harvest service → Harvest area checks: checks cultivated area
src/harvest/harvest.service.ts - Harvest API → Harvest DTOs: accepts and returns
src/harvest/harvest.controller.ts - API client → Dashboard API: requests summary
README.md - Dashboard API → Dashboard queries: delegates query
src/dashboard/dashboard.controller.ts - Dashboard queries → Farm record: aggregates farm data
src/dashboard/dashboard.service.ts - Farmer record → Farm record: relates to farms
src/farmer/entities/farmer.entity.ts - Farm record → Harvest record: relates to harvests
src/farm/entities/farm.entity.ts