Skip to content

Print-TesteServer/teste

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Factory Production Optimizer (Full Stack Test)

Industrial raw-material inventory management and production planning to maximize total revenue from the available stock.

🇧🇷 Este projeto implementa o teste prático descrito no desafio de gerenciamento de insumos e otimização de produção industrial, usando Java (Spring Boot), Vue.js e banco relacional (H2).

Tech stack

  • Backend: Java 17, Spring Boot 3, Spring Web, Spring Data JPA
  • Frontend: Vue 3 + Vite + Vue Router
  • Database: H2 (relational, in-memory by default)
  • Containers: Docker + docker-compose (optional)

Domain model

  • Raw material (insumo)
    • Code
    • Name
    • Stock quantity (e.g. 500 g, 10 units) — stored as BigDecimal
  • Product
    • Code
    • Name
    • Price (sale value)
    • Composition (bill of materials): list of RawMaterial + quantityPerUnit required to produce 1 unit

These structures are implemented in the backend as JPA entities (RawMaterial, Product, ProductComponent).

Features

  • Raw materials CRUD: create, update, list, delete
  • Products CRUD: create, update, list, delete (with bill of materials / composition)
  • Production planning: suggests the production quantities that maximize total sales value based on current stock
  • i18n: Portuguese + English (Vue i18n)

Project structure

  • backend/ Spring Boot API
  • frontend/ Vue app
  • docker-compose.yml optional full-stack run

How to run locally (dev)

Backend

Prerequisites:

  • JDK 17 (not only a JRE) configured via JAVA_HOME

From backend/:

./mvnw test
./mvnw spring-boot:run

On Windows (PowerShell):

.\mvnw.cmd test
.\mvnw.cmd spring-boot:run
  • API base URL: http://localhost:8080/api
  • H2 console (dev): http://localhost:8080/h2-console (if enabled)

Frontend

Prerequisites:

  • Node.js 18+ and npm

From frontend/:

npm install
npm run dev
  • App URL (dev): http://localhost:5173

Make sure the backend is running on http://localhost:8080 so the Vue app can call the API.

Run with Docker

From repository root:

docker compose up --build
  • Make sure Docker Desktop is running (Linux containers).
  • Frontend (Vue app via Nginx): http://localhost:8081
  • Backend (Spring Boot API): http://localhost:8080/api

After the containers are up, open http://localhost:8081 in your browser to use the application. The frontend sends /api requests to the backend through the internal Docker network (see frontend/nginx.conf).

Usage (high level)

  • 1. Configure raw materials: create raw materials with stock quantity (e.g. 500 g, 10 units).
  • 2. Configure products: create products, set sale price and define the bill of materials (which raw materials and how much each one consumes per unit).
  • 3. Run the production plan: go to the production planning screen and request a plan. The backend calculates the combination of product quantities that maximizes total revenue without exceeding current stock and resolving conflicts when products compete for the same raw materials.
  • 4. Review and adjust: use the suggested quantities as a reference to drive real production decisions or to simulate scenarios.

Production planning algorithm (overview)

  • The backend loads:
    • all raw materials and their current stock;
    • all products and their composition (consumption of each raw material per unit).
  • It then builds an in-memory model and runs a depth-first search with pruning to explore possible production quantities per product.
  • For each combination, it:
    • ensures no raw material stock becomes negative;
    • computes the total sales value (sum of unitPrice × quantity for all products);
    • keeps the plan that maximizes total value.
  • Dedicated unit tests validate that:
    • more profitable products are chosen first when they compete for the same material;
    • the algorithm improves over a naïve greedy-by-price approach when that would not give the best total;
    • independent products (that do not share materials) are produced up to their maximum possible quantities.

Main endpoints (REST API)

  • GET /api/raw-materials

  • POST /api/raw-materials

  • PUT /api/raw-materials/{id}

  • DELETE /api/raw-materials/{id}

  • GET /api/products

  • POST /api/products

  • PUT /api/products/{id}

  • DELETE /api/products/{id}

  • GET /api/production-plan

Tests

  • Backend unit tests (Maven, Linux/macOS): ./mvnw test
  • Backend unit tests (Maven, Windows PowerShell): .\mvnw.cmd test
    • includes unit tests for:
      • ProductionPlanningService (production plan optimization);
      • ProductService (validation and mapping of products + composition);
      • RawMaterialService (CRUD and integrity rules).
  • Frontend unit tests (Vitest, from frontend/): npm test
    • covers:
      • navigation + language switch (NavBar);
      • listing and editing raw materials (RawMaterialListView);
      • displaying products and their components (ProductListView).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors