How leafth/maneja-api works
MANEJA API is a Rails/PostgreSQL backend for managing livestock groups, grazing terrain, feed inventory, feeding plans and account access. Its main workflow is authenticated API requests that create or query domain records, with services enforcing operations and serializers shaping JSON responses. Distinct workflows cover occupations and terrain rest, feed movements and requirements, and planning. The README gives no further product detail; unsampled modules are represented only where the tree establishes their subsystem, and edges are limited to relationships visible in excerpts or explicitly documented routes.
Main entry points: routes.rb REST routes · auth Auth endpoints · base_controller.rb Request base · groups_controller.rb Group endpoints
Components 28
API boundary
- REST routes
config/routes.rb - Request base
app/controllers/api/v1/base_controller.rb - JSON serializers
app/serializers
Identity
- Auth endpoints
app/controllers/api/v1/auth - Token and sessions
app/services/auth
Grazing operations
- Group endpoints
app/controllers/api/v1/groups_controller.rb - Group operations
app/services/groups - Group listing
app/queries/groups/query.rb - Terrain endpoints
app/controllers/api/v1/terrains_controller.rb - Terrain operations
app/services/terrains - Terrain listing
app/queries/terrains/query.rb - Occupation endpoints
app/controllers/api/v1/occupations_controller.rb - Occupation lifecycle
app/services/occupations - Rest release job
app/jobs/terrains/release_resting_job.rb
Feed management
- Feed endpoints
app/controllers/api/v1/feeds_controller.rb - Feed operations
app/services/feeds - Feed listing
app/queries/feeds/query.rb - Stock movements
app/controllers/api/v1/feed_movements_controller.rb - Movement records
app/services/feed_movements - Feed requirements
app/controllers/api/v1/feed_requirements_controller.rb - Requirement operations
app/services/feed_requirements - Feeding records
app/controllers/api/v1/feedings_controller.rb - Feeding operations
app/services/feedings - Planning endpoint
app/controllers/api/v1/feed_planning_controller.rb - Feed planner
app/services/feed_planning/calculate.rb
Domain persistence
- User sessions
app/models/session.rb - PostgreSQL records
app/models/application_record.rb
Other components
- API client
Connections 28
- API client → REST routes: sends requests
config/routes.rb - REST routes → Auth endpoints: routes auth
config/routes.rb - REST routes → Group endpoints: routes groups
config/routes.rb - REST routes → Terrain endpoints: routes terrain
config/routes.rb - REST routes → Occupation endpoints: routes occupations
config/routes.rb - REST routes → Feed endpoints: routes feeds
config/routes.rb - REST routes → Stock movements: routes movements
config/routes.rb - REST routes → Feed requirements: routes requirements
config/routes.rb - REST routes → Feeding records: routes feeding
config/routes.rb - REST routes → Planning endpoint: routes planning
config/routes.rb - Auth endpoints → Request base: inherits
app/controllers/api/v1/auth/sessions_controller.rb - Auth endpoints → Token and sessions: authenticates
app/controllers/api/v1/auth/sessions_controller.rb - Request base → Token and sessions: decodes token
app/controllers/api/v1/base_controller.rb - Request base → User sessions: checks session
app/controllers/api/v1/base_controller.rb - Auth endpoints → User sessions: revokes session
app/controllers/api/v1/auth/sessions_controller.rb - Group endpoints → Group operations: calls operations
- Group endpoints → Group listing: lists records
- Terrain endpoints → Terrain operations: calls operations
- Terrain endpoints → Terrain listing: lists records
- Occupation endpoints → Occupation lifecycle: calls lifecycle
- Rest release job → Terrain operations: releases resting
- Feed endpoints → Feed operations: calls operations
- Feed endpoints → Feed listing: lists records
- Stock movements → Movement records: creates history
app/controllers/api/v1/feed_movements_controller.rb - Feed requirements → Requirement operations: calls operations
app/controllers/api/v1/feed_requirements_controller.rb - Feeding records → Feeding operations: records feeding
- Planning endpoint → Feed planner: calculates plan
- JSON serializers → PostgreSQL records: serializes records