A small, TypeScript React frontend for the Inventory API. This app is built with Vite and provides a lightweight UI to list, create, edit and delete Entity records from the backend API.
- List, create, edit and delete entities (connected to the Inventory API)
- Dashboard cards (total items, low‑stock by type, inventory value)
- Add / Edit modals that accept prices in pt‑BR format (thousand separator + comma decimal)
- Unit tests with Vitest and e2e testing with Cypress
- Vite dev server and production preview support
| Field | Type | Required | Notes |
|---|---|---|---|
id |
int | auto | Primary key |
type |
string | yes | Entity type (e.g. "SUV", "Hatch-back") |
name |
string | no | Descriptive name (e.g. "VW Golf") |
description |
string | no | Details (year, color, transmission) |
price |
number | no | Unit price (frontend normalises server unit_price) |
created_at |
string | auto | Timestamp |
- Node.js (18+ recommended)
- npm or yarn
- Backend API running (see the Inventory API README) and reachable via environment configuration
- Install dependencies
npm ci- Create a
.env(optional) or rely on defaultVITE_API_BASE_URL.
Example .env:
VITE_API_BASE_URL=http://localhost:8000/api
- Run dev server
npm run devnpm run dev— start Vite dev servernpm run build— build production assets intodist/npm run preview— locally preview production build (default port 5173)npm test— run unit tests (Vitest)npx cypress open— open Cypress GUInpx cypress run --spec "cypress/e2e/**/*.cy.ts"— run e2e tests headless
- E2E tests expect the frontend to be served (dev or preview) and intercept requests to the API using wildcard patterns (e.g.
**/entities) so tests work with proxied APIs or different hostnames. - The repository contains a GitHub Actions workflow that runs unit tests, builds the app and runs headless Cypress in CI. The workflow pins the preview server to port
5173and uses await-onscript to ensure the server is ready.
The UI formats prices using pt-BR rules (thousand separator . and decimal ,) for display. Inputs accept numbers with . or , and are parsed to numeric values before sending to the API.
- Low-stock is calculated at the
typelevel: the UI aggregates quantities grouped bytype(andnamefor per-item aggregation) and marks atypeas low when the type total is less than or equal to the configured threshold (default5). - The dashboard
View Allmodal lists all items belonging to the low types (grouped by type+name) and shows a per-item quantity.
- If e2e tests time out, ensure the frontend is served at the expected port (5173) and that the backend API is reachable if not mocked.
- If TypeScript build errors appear, run
npm cito ensure packages are installed and check for local changes.
Fork, create a feature branch, add tests and open a pull request. Keep changes small and focused.
Created to pair with the Inventory API (Django + Django Ninja).
