How ajkizzy/nordic-atlas-dpp-prototype works
1. This repository is split into two main runtime boundaries: a NestJS API in api/ and a React/Vite frontend in web/. The app is containerized with Docker and started via docker compose up --build, with the frontend served through Nginx in production and the API exposed on port 3000.
2. The backend is the system of record. It uses NestJS modules and controllers for domain areas like auth, users, products, batches, passport, evidence, and audit. Prisma is the ORM layer (api/src/prisma, api/prisma/schema.prisma) and migrations show the database evolves around batch/product passport data, audit logging, and evidence records.
3. The core business object appears to be the batch/product passport. batches is the central domain module and includes a co2-calculator.ts, which suggests environmental impact values are computed or aggregated there. products and users likely support the batch/passport administration and lookup flows around that core entity.
4. Public access is token-based. The README’s /resolve/[batchPublicToken] route maps to the public passport flow: a QR code or token is resolved by the frontend, then the API returns the public passport view for that batch. This is the main anonymous read path and the primary “scan → resolve → view passport” data flow.
5. Authenticated access is role-based. The backend has a dedicated auth module with JWT support, plus jwt.guard.ts, roles.decorator.ts, and roles.guard.ts. That implies the API enforces authorization centrally, with different data exposure for admin, B2B, internal, and regulator roles rather than a single universal passport response.
6. The frontend mirrors those visibility tiers in its component structure. There are separate passport renderers for PassportPublic, PassportB2B, PassportInternal, and PassportRegulator, plus RoleSwitcher and FieldVisibilityBadge. This suggests the UI progressively reveals more fields as role context changes, instead of using distinct applications.
7. The admin experience is isolated from the public passport flow. AdminDashboard.tsx and the README’s /admin path indicate a privileged operational surface for managing batches/tokens and inspecting data. The frontend likely logs in via /login, stores the JWT, and then calls authenticated API endpoints through web/src/api/client.ts.
8. Traceability and compliance are first-class subsystems. The audit module, together with migrations adding “audit_log_before_after,” indicates the backend records who changed what and captures previous/new values. The evidence module and its migration indicate supporting documentation or proof artifacts are attached to passport data, which is important for supply-chain claims.
9. The backend startup/initialization path includes seeding. api/prisma/seed.ts and the README’s mention of startup logs printing batch tokens show seeded demo data is part of the expected architecture. That makes the repo a proof-of-concept with deterministic sample entities and public tokens for testing.
10. From a deployment perspective, the frontend is a static SPA built with Vite and Tailwind/PostCSS, while the API is a Node service built with NestJS/TypeScript. The Nginx config in web/nginx.conf suggests the compiled SPA is served as static content, and the API is consumed over HTTP from the browser using the shared client in web/src/api/client.ts.
11. The key architectural boundary is therefore: browser UI on one side, authenticated REST-style API on the other, with Prisma-backed persistence beneath the API. The UI handles presentation and role-specific rendering; the API owns authorization, business rules, calculations, auditability, and data persistence.
12. For a diagram, the most important flows to show are: QR/token resolution to public passport; user login to JWT issuance; JWT-protected admin/B2B/internal/regulator reads; batch changes writing audit entries and possibly evidence records; and Prisma migrations/seed establishing the database state used by all of the above.
Main entry points: app.module.ts App module · App.tsx SPA shell · prisma.module.ts Prisma · batches.module.ts Batches
Components 22
Infrastructure
Containerized build and runtime entrypoints
API
NestJS backend system of record
- API bootstrap · Starts the NestJS application and wiring
api/src/main.ts - App module · Composes backend feature modules
api/src/app.module.ts - Auth · JWT login and role enforcement
api/src/auth/auth.module.ts - Batches · Core batch and passport business logic
api/src/batches/batches.module.ts - Products · Product lookup and administration support
api/src/products/products.module.ts - Users · User management and identity records
api/src/users/users.module.ts - Passport · Token-based public passport resolution
api/src/passport/passport.module.ts - Audit · Change history and before/after logging
api/src/audit/audit.module.ts - Evidence · Supporting documents and proof records
api/src/evidence/evidence.module.ts - Prisma · Database access layer used by backend modules
api/src/prisma/prisma.module.ts - Schema · Prisma data model and migrations
api/prisma/schema.prisma - Seed data · Loads demo users, batches, and tokens
api/prisma/seed.ts
Web
React/Vite frontend
- SPA shell · Client-side router and page composition
web/src/App.tsx - API client · Shared browser client for backend calls
web/src/api/client.ts - Login · User login entry for JWT access
web/src/pages/LoginPage.tsx - Resolve · Scans or resolves public batch tokens
web/src/pages/ResolvePage.tsx - Admin dashboard · Privileged management view for batches and data
web/src/components/AdminDashboard.tsx - Passport views · Role-specific passport renderers for public, B2B, internal, and regulator access
web/src/components/PassportPublic.tsx - Role UI · Switches and badges for role-based field exposure
web/src/components/RoleSwitcher.tsx
Connections 31
- Compose → API image: builds · Compose builds the backend image
- Compose → Web image: builds · Compose builds the frontend image
- API image → API bootstrap: runs · Container starts the NestJS entrypoint
- Web image → SPA shell: serves · Compiled SPA is served by Nginx
- API bootstrap → App module: loads · Bootstraps the root Nest module
- App module → Auth: includes · Wires authentication and authorization
- App module → Batches: includes · Wires core batch domain
- App module → Products: includes · Wires product support domain
- App module → Users: includes · Wires user management domain
- App module → Passport: includes · Wires public passport access
- App module → Audit: includes · Wires audit logging domain
- App module → Evidence: includes · Wires evidence records domain
- App module → Prisma: shares db · Provides database access to all feature modules
- Batches → Prisma: persists via · Batch logic reads and writes through Prisma
- Products → Prisma: persists via · Product data flows through Prisma
- Users → Prisma: persists via · User data flows through Prisma
- Passport → Batches: resolves · Public passport view is derived from batch data
- Audit → Prisma: records via · Audit entries are stored in the database
- Evidence → Prisma: stores via · Evidence artifacts are persisted
- Prisma → Schema: uses · ORM is backed by Prisma schema and migrations
- Seed data → Schema: seeds · Seed data initializes the modeled tables
- SPA shell → API client: calls · Frontend uses a shared HTTP client
- SPA shell → Login: routes · Login flow is part of the SPA
- SPA shell → Resolve: routes · Public token resolution flow is part of the SPA
- SPA shell → Admin dashboard: routes · Admin surface is part of the SPA
- SPA shell → Passport views: renders · SPA displays role-specific passport variants
- SPA shell → Role UI: controls · UI exposes role switching and field visibility cues
- Login → API client: authenticates · Login exchanges credentials for JWT-backed access
- Resolve → Passport views: loads · Token resolution feeds the public passport view
- Admin dashboard → API client: admin api · Privileged management actions call the API
- Passport views → Role UI: adapts · Rendered passport fields vary by role context