A full-stack system for inventory management.
The backend is built with Spring Boot 3 and JPA, while the frontend uses React 19 + Vite with TypeScript and Tailwind CSS.
- Real persistence of products via JPA/H2 (inventory is no longer lost on restart).
- Metrics service and product service to separate business logic from the controller.
- Error handling and loading states in frontend HTTP calls.
- API base URL configurable through environment variables.
- Differentiated product types (Product vs NewProduct) for stronger type safety in TypeScript.
- Additional endpoint
GET /products/{id}to query a specific product.
breaktoy-backend/ # REST API in Spring Boot
breaktoy-frontend/ # Web interface in React
- Java 21
- Node.js ≥ 18
- Maven Wrapper and npm (included in the repo)
cd breaktoy-backend
# in-memory H2 database
./mvnw spring-boot:run
# run tests
./mvnw testcd breaktoy-frontend
npm install
# start in development mode
npm run dev
# run tests
npm testVITE_API_BASE_URL=http://localhost:9090You can also define additional profiles:
.env.development.env.production
spring.datasource.url=jdbc:h2:mem:inventory
spring.jpa.hibernate.ddl-auto=updateAdjust the URL if you want to use a different database.
| Method | Path | Description |
|---|---|---|
| GET | /products |
Lists products with filters and pagination |
| GET | /products/{id} |
Retrieves a specific product |
| POST | /products |
Creates a product |
| PUT | /products/{id} |
Updates a product |
| DELETE | /products/{id} |
Deletes a product |
| PATCH | /products/{id}/toggle-stock |
Toggles stock status |
| GET | /products/metrics |
Global and per-category metrics |
- ProductService: CRUD operations, filtering, sorting, and pagination.
- InventoryMetricsService: aggregated and category-based metrics.
- Validation: Jakarta Validation enforces rules for name, category, price, quantity, and dates.
- Hooks
useProductsanduseMetricsencapsulate fetching logic. - Loading (
isLoading) and error (error) states for each operation. - Reusable components:
SearchBar,ProductsList,ProductForm,MetricsTable,MetricsGraphics. - Styling preserved with Tailwind; no visual redesign applied.
- Backend:
ProductControllerTestand service-level tests. - Frontend:
npm testcovers main components and hooks.
- Create a branch from
main. - Apply your changes.
- Run tests (
./mvnw testandnpm test). - Open a Pull Request describing the changes.
This project is distributed under the terms of the MIT License (or the applicable license).