How ukutia/qualitrack works
1. System purpose and scope
- Qualitrack is an MVP for managing and analyzing evidences for Chilean CNA institutional accreditation.
- The repository is intentionally narrow in scope: one campus, up to three programs, and only Criterio 9.
- The architecture centers on a single authenticated administrator who uploads, imports, classifies, and reviews evidences.
2. Top-level structure
- The repo is split into three main runtime units:
- frontend/: React SPA
- backend/: Node.js + Express API
- docker-compose.yml: local orchestration for database, API, and client
- The app is designed to run either fully containerized or locally without Docker.
3. Frontend boundary
- The frontend is a Vite-powered React single-page app using Tailwind, TanStack Query, and React Router.
- It is organized around route-level pages such as dashboard, documents, upload, cloud connect, login, and criteria structure.
- Shared UI/state pieces include:
- AuthContext for session/auth state
- ProtectedRoute to guard authenticated routes
- useApi and lib/api as the API access boundary
- queryClient for server-state caching and refetching
4. Backend boundary
- The backend is an Express API split into controllers, services, middleware, and route registration.
- server.js and app.js form the HTTP bootstrap layer.
- routes/index.js aggregates feature routes, which then dispatch into controllers:
- auth
- documents
- classification
- compliance
- criteria
- cloud
- This structure keeps HTTP concerns separate from domain logic.
5. Persistence and data model
- Prisma is the ORM layer, with PostgreSQL 16 as the primary database.
- prisma/schema.prisma defines the app’s persisted entities, and seed.js initializes the MVP baseline.
- On startup, the backend syncs the schema, seeds:
- the admin user
- Criterio 9 data
- the official report structure
- This means the app assumes a controlled, pre-seeded accreditation context rather than a general multi-tenant system.
6. Document ingestion flow
- Evidence upload starts in the frontend upload page and reaches the backend through authenticated API calls.
- multer handles multipart file upload in middleware.
- Uploaded files are validated for format/size and then stored via storage.service.js.
- The repository explicitly treats storage as an abstraction layer, so the current local-volume approach can be replaced later by S3/GCS without changing the rest of the app.
7. Text extraction and classification flow
- After ingestion, documents can be processed through:
- textExtraction.service.js for content extraction
- classifier.service.js for assigning evidence to the criterion/subcriterion
- The classifier is a deterministic keyword-based mock, not a real AI call.
- This is an important architectural seam: the app is built so an LLM integration can be swapped in later without changing controllers or UI contracts.
8. Compliance computation
- compliance.service.js encapsulates the logic that turns evidence sets into compliance status.
- The compliance result is per subcriterion and follows the repository’s documented rules:
- Suficiente
- Parcial
- Insuficiente
- There is a backend test file dedicated to these rules, which makes compliance logic a distinct domain boundary rather than a UI concern.
9. Cloud integration
- cloud.controller.js and googleDrive.service.js implement Google Drive OAuth and file browsing/import.
- This is the only external service integration in the MVP.
- The app is designed to degrade gracefully: without credentials, the rest of the system still works and the UI exposes setup guidance.
10. Authentication and request protection
- JWT-based auth is handled on the backend with auth.controller.js and middleware/auth.js.
- The frontend login flow stores auth state in context and routes protected views through ProtectedRoute.
- This creates a clear trust boundary: unauthenticated users can reach login, but document management and cloud operations are gated.
11. Error handling and operational concerns
- middleware/errorHandler.js provides centralized API error translation.
- Environment configuration is isolated in config/env.js, and Prisma access is centralized in config/prisma.js.
- These modules indicate a clean separation between application logic and runtime configuration.
12. Deployment and infrastructure
- docker-compose.yml is the main deployment unit for local/staging-like use.
- The system includes:
- PostgreSQL database
- backend API
- frontend SPA
- A backend Docker entrypoint initializes schema and seed data automatically, which is important for understanding startup order.
13. What to show in an architecture diagram
- Main clients: browser user → frontend SPA → backend API.
- Main backend dependencies: backend → PostgreSQL, backend → local file storage, backend → Google Drive API.
- Main internal subsystems: auth, document management, classification, compliance, criteria/versioned structure, cloud import.
- Cross-cutting layers: JWT auth, file upload middleware, centralized error handling, Prisma persistence, seeded baseline data.
14. Key architectural constraint
- This is not a general-purpose content platform; it is a tightly bounded MVP with one admin role and one criterion domain.
- That constraint explains why the services are narrow, the data model is seeded, and the classifier is intentionally mock-based.
Main entry points: App.jsx SPA · docker-compose.yml Compose stack · services Domain services · controllers Controllers
Components 20
Client app
React SPA and its route-level UI/state boundary
- SPA · Single-page client for login, upload, documents, criteria, and cloud setup
frontend/src/App.jsx - Auth state · Client session and login state
frontend/src/context/AuthContext.jsx - Route guard · Blocks authenticated views until session is present
frontend/src/components/ProtectedRoute.jsx - API client · Frontend request boundary and API helpers
frontend/src/lib/api.js - Query cache · Server-state caching and refetch coordination
frontend/src/lib/queryClient.js - Pages · Dashboard, documents, upload, login, cloud connect, and criteria structure screens
frontend/src/pages
Backend API
Express HTTP layer, domain services, and middleware
- HTTP server · Backend entrypoint and app bootstrap
backend/src/server.js - Routes · Aggregates feature routes into the API surface
backend/src/routes/index.js - Controllers · Auth, documents, classification, compliance, criteria, and cloud endpoints
backend/src/controllers - Domain services · Storage, text extraction, classification, compliance, and Drive integration
backend/src/services - Middleware · JWT auth, uploads, and centralized error handling
backend/src/middleware - Env config · Environment loading and deployment settings
backend/src/config/env.js - Prisma config · Centralized Prisma access to PostgreSQL
backend/src/config/prisma.js
Data layer
Persistent models, seeded baseline data, and storage targets
- Schema · Persisted entities for the MVP accreditation domain
backend/prisma/schema.prisma - Seed data · Admin user, Criterio 9 baseline, and report structure initialization
backend/prisma/seed.js - PostgreSQL · Primary relational store for application state
- File storage · Pluggable evidence file storage abstraction
backend/src/services/storage.service.js - Google Drive · OAuth-backed evidence import and browsing
backend/src/services/googleDrive.service.js
Local runtime
Container orchestration and startup wiring
- Compose stack · Local orchestration for frontend, backend, and database
docker-compose.yml
Other components
- Administrator · Single authenticated operator of the MVP
Connections 22
- Administrator → SPA: uses · Admin works through the SPA
- SPA → Auth state: state · Login/session state flows through context
- SPA → Route guard: guards · Authenticated views are wrapped by route protection
- SPA → API client: calls · Pages reach backend APIs through the client boundary
- SPA → Query cache: caches · Server state is coordinated through query caching
- SPA → Pages: renders · Route-level screens make up the UI surface
- Pages → API client: requests · Screens trigger authenticated backend operations
- HTTP server → Routes: mounts · Bootstrap layer registers the route tree
- Routes → Controllers: dispatches · Feature endpoints map to HTTP handlers
- Controllers → Middleware: uses · Handlers rely on auth, upload, and error handling layers
- Controllers → Domain services: delegates · Controllers keep domain logic in services
- Domain services → Prisma config: persists via · Domain logic reads and writes through Prisma
- Prisma config → Schema: maps to · Prisma client reflects the defined schema
- Schema → PostgreSQL: stored in · App state is persisted in PostgreSQL
- Seed data → PostgreSQL: initializes · Seed script loads the controlled MVP baseline
- Domain services → File storage: stores files · Evidence files are written through the storage abstraction
- Domain services → Google Drive: imports from · Cloud import and browsing integrate with Google Drive
- Middleware → Env config: reads · Runtime behavior is driven by environment configuration
- Compose stack → HTTP server: starts · Compose brings up the backend service
- Compose stack → SPA: starts · Compose brings up the SPA service
- Compose stack → PostgreSQL: provisions · Compose includes the database service
- Compose stack → Seed data: boots with · Startup includes schema sync and baseline seed