A modular Vue 3 + TypeScript SPA for the Lilith platform. It provides domain-centric modules (sales, production, purchase, warehouse, etc.), a shared component and service layer, centralized state via Pinia, and deployment through a pre-built static bundle served by Nginx.
- Framework / Tooling: Vue 3 (Composition API,
<script setup>), Vite, TypeScript. - State: Pinia stores (
src/storefor global,src/modules/*/storefor domain stores). - Routing: Vue Router 4; each domain exposes its own
routes.tsaggregated by the root router. - UI Stack: PrimeVue, PrimeFlex, PrimeIcons, plus custom base components under
src/components. - Validation: Yup + custom helper or manual checks with toast feedback (Catalan messages).
- HTTP Layer: Axios wrapped in reusable base + domain services in
src/apiandsrc/modules/*/services. - Reporting: Report service downloads server-generated documents (blob → local download).
- Internationalization: Structure present (
src/i18n), but many strings are still inline Catalan; maintain Catalan for consistency. - Build & Deploy:
vite buildoutputs/distwhich the Docker image copies into an Nginx Alpine container.
├─ src/
│ ├─ api/ # Base service, API clients
│ ├─ assets/ # Static assets (styles, images, JSON geography)
│ ├─ components/ # Base & shared reusable components
│ ├─ i18n/ # Translation sources
│ ├─ modules/ # Domain modules (production, sales, etc.)
│ │ └─ <domain>/
│ │ ├─ routes.ts
│ │ ├─ components/
│ │ ├─ services/
│ │ ├─ store/
│ │ ├─ types/
│ │ └─ views/
│ ├─ store/ # Global (auth, menus, filters, geography)
│ ├─ types/ # Shared types/interfaces
│ ├─ utils/ # Helpers (uuid, date, currency, file download)
│ └─ views/ # Top-level simple pages (Login, Home, etc.)
├─ .nginx/ # Nginx config (SPA fallback)
├─ docker-compose.yml # Container orchestration (expects pre-built dist)
├─ Dockerfile # Static Nginx image (copies dist only)
├─ package.json
├─ vite.config.ts
└─ README.md
Vite exposes variables prefixed with VITE_. Configure them via a local .env (or .env.development, .env.preprod). Example:
VITE_API_APP_NAME=Lilith
Access in code with import.meta.env.VITE_API_BASE_URL.
- Node.js: Recommend LTS (≥ 18) for best compatibility with Vite 4.
- Package Manager: npm (default) or pnpm/yarn (stick to one consistently).
npm installnpm run devDefault dev server: http://localhost:8100
If you need different env values for dev, create .env.development.
npx vue-tsc --noEmit| Command | Purpose | Output Directory | Mode |
|---|---|---|---|
npm run build |
Production build | dist/ |
default (production) |
npm run build-development |
Dev-like build artifact | dist-test/ |
development |
npm run build-preprod |
Pre-production test build | dist-preprod/ |
preprod |
Each mode loads corresponding .env.<mode> if present.
npm run build
npm run previewPreview server (default): http://localhost:4173
The provided Dockerfile expects a pre-built dist folder.
npm run build
docker build -t lilith-frontend .
docker run -p 9000:80 --name lilith-frontend lilith-frontendApp served at http://localhost:9000
docker-compose.yml defines a single service with environment variables. You must build the app first:
npm run build
docker compose up --buildIf you want the image to build the app itself, you would need a multi-stage Dockerfile (not currently implemented).
(Only if you choose to change deployment approach.)
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM nginx:alpine
COPY ./.nginx/nginx.conf /etc/nginx/nginx.conf
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
ENTRYPOINT ["nginx", "-g", "daemon off;"]- Separation by Domain: Each module encapsulates its own UI, store, services, and types to reduce cross-domain coupling.
- Service Abstraction: Components call Pinia store actions; stores call service layer; services isolate HTTP details.
- Reusability: Base input, dropdown, table column components unify styling & patterns.
- State Flow: Global stores provide auth context, navigation menu state, and date/exercise filters consumed by views.
- Validation & UX: Consistent toast-based feedback; Catalan language throughout.
- Create folder
src/modules/<domain>/with subfolders:components/ services/ store/ types/ views/androutes.ts. - Define entity interfaces in
types/. - Implement service class extending the base service.
- Create Pinia store (CRUD actions, re-fetch patterns).
- Add routes in
routes.ts(lazy-loaded views). - Build list & detail views using existing form/dialog patterns.
- Use
getNewUuid()for client-only IDs; convert dates withconvertDateTimeToJSONbefore submit. - Provide Catalan messages & toasts.
- If report needed, extend report enum/constants & follow existing download pattern.
- Register routes with the root (if not auto-imported).
| Script | Description |
|---|---|
npm run dev |
Start Vite dev server. |
npm run build |
Type check + production build. |
npm run build-development |
Build with development mode. |
npm run build-preprod |
Build with preprod mode. |
npm run preview |
Preview production output. |
- Use Composition API with
<script setup>. - Keep business logic in Pinia stores or services; keep components lean.
- Reuse utilities; do not duplicate date/currency formatting.
- Catalan UI text; unify toast messages.
- Round monetary values only at display.
- Null/undefined guard nested access; prefer explicit types.
| Issue | Cause | Fix |
|---|---|---|
| 404 on refresh in production | Missing SPA fallback | Nginx config already uses try_files; ensure deployed config matches repo. |
| Docker build fails (missing dist) | dist not built before docker build |
Run npm run build first or switch to multi-stage Dockerfile. |
| Env var not applied | Missing VITE_ prefix or wrong mode file | Prefix with VITE_; ensure correct .env.<mode> name. |
| Type errors during build | Out-of-sync types or implicit any | Run npx vue-tsc --noEmit locally; fix definitions. |
Periodically run:
npx npm-check-updates -u
npm install(Review breaking changes, especially PrimeVue & Vite major versions.)
- JWT stored in state; ensure any future persistence (localStorage) is done securely.
- Always validate date filters before sending queries reliant on exercise context.
- Create feature branch from
dev. - Ensure
npm run buildpasses and app launches locally. - Update documentation if adding new domain module or utilities.
- Open PR → code review → merge into
dev→ eventual promotion tomain.
(Define project license here if applicable. Add a LICENSE file if missing.)
# Clone & enter
git clone <repo-url>
cd lilith-frontend
# Install & run
npm install
npm run dev
# Visit http://localhost:8100
# Build production
npm run build
# Docker (after build)
docker compose up --buildFor deeper architectural guidance, see .github/copilot_instruction.md.