How derektsc/oficina-tech-challenge works
Oficina API is a Rails backend for repair-shop service orders. The main workflow is operator authentication and order creation, followed by diagnosis, budget approval or rejection, execution, completion and delivery; clients can check status, while an external system can submit budget decisions. The API also exposes an ordered operational queue, catalog and customer administration, and execution-time metrics. The README documents email notifications and PostgreSQL. Some use-case internals and controller wiring were not excerpted, so those links rely on documented behavior rather than claims about unseen implementation.
Main entry points: service_orders_controller.rb Admin endpoints · service_order.rb Service orders · schema.rb PostgreSQL · auth_controller.rb Login endpoint
Components 24
HTTP interface
- Admin endpoints
app/controllers/api/v1/admin/service_orders_controller.rb - Public endpoints
app/controllers/api/v1/public/service_orders_controller.rb - Budget webhook
app/controllers/api/v1/integrations/budget_notifications_controller.rb - Catalog admin
app/controllers/api/v1/admin/catalog_services_controller.rb - Parts admin
app/controllers/api/v1/admin/parts_controller.rb - Customer admin
app/controllers/api/v1/admin/customers_controller.rb - Vehicle admin
app/controllers/api/v1/admin/vehicles_controller.rb - Order serializer
app/serializers/service_order_serializer.rb
Order workflow
- Create order
app/lib/use_cases/service_orders/create.rb - Order transitions
app/lib/use_cases/service_orders/start_diagnosis.rb - Budget decisions
app/lib/use_cases/service_orders/apply_external_budget_decision.rb - Operational queue
app/lib/use_cases/service_orders/list_operational.rb - Execution metrics
app/lib/use_cases/service_orders/average_execution_time.rb
Domain and persistence
- Service orders
app/models/service_order.rb - Status rules
app/lib/domain/service_orders/status.rb - Stock control
app/lib/domain/inventory/stock_control.rb - PostgreSQL
db/schema.rb
Identity and notifications
- Login endpoint
app/controllers/api/v1/auth_controller.rb - JWT codec
app/lib/json_web_token.rb - Users
app/models/user.rb - Status email
app/mailers/service_order_mailer.rb
Other components
- Operator
- Customer
- External system
Connections 23
- Operator → Login endpoint: requests token
README.md - Login endpoint → Users: authenticates
app/controllers/api/v1/auth_controller.rb - Login endpoint → JWT codec: encodes token
app/controllers/api/v1/auth_controller.rb - Operator → Admin endpoints: manages orders
README.md - Customer → Public endpoints: checks status
README.md - External system → Budget webhook: sends decision
README.md - Admin endpoints → Create order: creates order
app/controllers/api/v1/admin/service_orders_controller.rb - Admin endpoints → Order transitions: advances order
app/controllers/api/v1/admin/service_orders_controller.rb - Admin endpoints → Operational queue: lists queue
app/controllers/api/v1/admin/service_orders_controller.rb - Admin endpoints → Execution metrics: requests metrics
- Public endpoints → Budget decisions: decides budget
README.md - Budget webhook → Budget decisions: applies decision
README.md - Admin endpoints → Order serializer: serializes response
app/controllers/api/v1/admin/service_orders_controller.rb - Service orders → Status rules: checks transitions
app/models/service_order.rb - Create order → Service orders: creates records
- Order transitions → Service orders: updates order
- Budget decisions → Stock control: checks stock
- Service orders → PostgreSQL: persists data
README.md - Catalog admin → PostgreSQL: manages catalog
- Parts admin → PostgreSQL: manages parts
- Customer admin → PostgreSQL: manages customers
- Vehicle admin → PostgreSQL: manages vehicles
- Service orders → Status email: notifies status
README.md