Skip to content

Ricyxy/Mvp

Repository files navigation

Limarija Nalozi (MVP)

License

This project is proprietary and UNLICENSED. No permission is granted to use, copy, modify, or distribute any part of it without prior written permission. See LICENSE.

App for creating and tracking production orders across stations:

  • profilisanje
  • sica
  • savijanje
  • utovar

Current stack:

  • Frontend: React 18 + Vite + Tailwind + Radix UI
  • Backend: NestJS + TypeScript
  • ORM/DB: Prisma + PostgreSQL (Docker in local dev)

Main features

  • Auth with roles and httpOnly cookie session (/auth/login, /auth/me, /auth/logout)
  • Order workflow and station status transitions
  • Station inboxes and worksheet flow
  • Local order migration endpoint (/migration/local-orders/import)
  • Custom savijanje templates with advanced options (segments, taper, squeeze, pyramid, alignment)
  • Custom templates are now persisted on backend and shared between users/devices

Repository layout

  • Frontend app: src/
  • Backend app: backend/
  • DB container config: docker-compose.yml
  • Frontend env example: .env.example
  • Backend env example: backend/.env.example

Prerequisites

  • Node.js 18+
  • npm
  • Docker Desktop

Local setup (first time)

  1. Install dependencies
npm install
npm --prefix backend install
  1. Start PostgreSQL
docker compose up -d
  1. Create env files
  • Frontend:
copy .env.example .env
  • Backend:
copy backend/.env.example backend/.env
  1. Prepare database and seed users
npm --prefix backend run prisma:generate
npm --prefix backend run prisma:deploy
npm --prefix backend run prisma:seed

Daily development

Run in separate terminals:

  1. Backend API
npm --prefix backend run start:dev
  1. Frontend
npm run dev

Default local URLs:

  • Frontend: http://localhost:5173
  • Backend: http://localhost:4000
  • Health check: http://localhost:4000/health

Default seeded users (dev)

From backend/prisma/seed.ts:

  • radnica / radnica
  • admin / admin
  • lelo / GlobalTrade (direktor)
  • station users: sica, profilisanje, utovar, ekipa1, ekipa2, ekipa3

Build checks

npm run build
npm --prefix backend run build

Root scripts

  • npm run dev - start frontend
  • npm run build - frontend production build
  • npm run preview - preview frontend build
  • npm run api:dev - start backend dev server
  • npm run api:build - backend build
  • npm run api:prisma:generate - prisma client generate
  • npm run api:prisma:migrate - prisma migrate dev
  • npm run api:prisma:seed - seed dev users

API overview

Auth:

  • POST /auth/login
  • POST /auth/logout
  • GET /auth/me

Orders and workflow:

  • GET /orders
  • GET /orders/:id
  • POST /orders
  • PATCH /orders/:id/stations/:station/status
  • PATCH /orders/:id/sica-items/:itemId/fulfillment
  • GET /stations/:station/inbox

Migration:

  • POST /migration/local-orders/import (admin/direktor)

Custom templates:

  • GET /custom-templates
  • POST /custom-templates
  • DELETE /custom-templates/:type

Custom templates (important)

  • System templates are defined in src/bending/templates.js
  • User templates are created from UI (Novi nalog -> Savijanje -> Custom sabloni -> Novi sablon)
  • User templates are persisted in backend (CustomTemplate table), so other users/devices can see them
  • Frontend keeps a local cache for fast load, then refreshes from API
  • Delete in UI is allowed only for user templates (USER_TEMPLATE_*), not system templates

Environment variables

Frontend (.env):

  • VITE_API_BASE_URL=http://localhost:4000
  • VITE_DATA_SOURCE=api

Backend (backend/.env):

  • PORT=4000
  • DATABASE_URL=postgresql://...
  • JWT_SECRET=...
  • JWT_EXPIRES_IN=8h
  • CORS_ORIGIN=http://localhost:5173

Deployment notes

  • Frontend and backend are separate deployments.
  • Set VITE_API_BASE_URL to your deployed backend URL (not localhost).
  • Set backend CORS_ORIGIN to your frontend URL.
  • If frontend and backend are on different domains, review cookie settings in backend/src/modules/auth/auth.controller.ts (SameSite/Secure).

Troubleshooting

  • ERR_CONNECTION_REFUSED on login:
    • frontend is calling unreachable API URL (often localhost in production)
    • fix VITE_API_BASE_URL and deploy backend
  • Prisma EPERM during prisma:generate on Windows:
    • stop running backend process first, then run prisma:generate again

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors