Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/LMendoza70/SSA/llms.txt

Use this file to discover all available pages before exploring further.

Every technology in this platform was selected with a 10-year maintainability horizon as the primary criterion, not short-term convenience or novelty. The Jurisdicción Sanitaria de Huejutla de Reyes requires a system that future contributors — who may not have been part of the original build — can understand, extend, and confidently deploy. That means favouring well-documented, widely-adopted tools with strong TypeScript support, active communities, and clear upgrade paths over clever or experimental alternatives. Every dependency must justify its presence; anything that adds complexity without adding long-term value is a liability.

Frontend

The frontend is a single-page application built with React and TypeScript, bundled by Vite. Each library was chosen because it solves a specific problem cleanly and integrates well with the rest of the stack.
LibraryVersionPurpose
React18+UI component framework
TypeScript5+Type safety (strict mode)
Vite5+Build tool and dev server
Material UI5+Component library and design system
React Router6+Client-side routing
TanStack Query5+Server state management and caching
React Hook Form7+Form state management
Zod3+Schema validation (shared with backend)
Axios1+HTTP client with interceptors
Tiptap2+Rich text editor for CMS content
Only functional components and hooks are used in the React layer. Class components are not permitted anywhere in the codebase.

Backend

The backend is a NestJS application structured as a modular monolith. It is designed to be extracted into microservices in the future if the operational load ever demands it, but it runs as a single deployable unit today.
LibraryVersionPurpose
NestJS10+Modular Node.js framework
TypeScript5+Type safety (strict mode)
Prisma5+ORM and database migration
class-validatorDTO validation
class-transformerRequest/response transformation
Passport.jsAuthentication strategy
bcrypt/Argon2Password hashing
MulterFile upload handling
Swagger/OpenAPIAuto-generated API documentation

Database & Infrastructure

The persistence layer is PostgreSQL, extended with pgvector to support the AI chatbot’s semantic search capability. Redis is optionally available for caching and session offloading at higher traffic volumes.
TechnologyPurpose
PostgreSQL 14+Primary relational database
pgvectorVector embeddings for chatbot RAG
Redis (optional)Caching and session storage
All database tables follow a consistent base schema including id, createdAt, updatedAt, deletedAt, createdBy, and updatedBy columns. Soft delete (deletedAt) is preferred over hard deletion across all entities.

Authentication & Storage

Authentication is handled entirely on the backend using JWT access tokens paired with HttpOnly cookie-based refresh tokens. Passwords are hashed with Argon2. File storage begins on the local filesystem but the architecture abstracts all file access behind a StorageProvider interface — meaning the platform can migrate to Amazon S3, Azure Blob Storage, or Google Cloud Storage without touching any business logic.

Why These Choices?

NestJS brings built-in module boundaries, constructor-based dependency injection, decorator-driven routing, and first-class TypeScript support straight out of the box. For a long-lived application with multiple modules and multiple contributors, this structure prevents the “framework-less Express spaghetti” pattern that makes codebases hard to navigate after the first year. Its conventions align directly with the Clean Architecture and SOLID principles this project enforces.
Prisma provides a significantly better developer experience: its schema file is the single source of truth for the database structure, its generated client is fully type-safe at the query level, and its migration tooling is more reliable than TypeORM’s in production scenarios. Introspection, seeding, and rollback workflows are all first-class features. For a team that may not include a dedicated DBA, Prisma reduces the risk of schema drift.
Material UI is a complete component library with built-in accessibility support (ARIA attributes, keyboard navigation, contrast compliance), a comprehensive theming API, and a very large ecosystem of examples and community knowledge. It eliminates the need to build common UI patterns — tables, dialogs, form fields, navigation drawers — from scratch, which directly serves the goal of reducing frontend development time while keeping the result WCAG-compliant.
Server state — loading flags, error states, background refetching, cache invalidation — is notoriously tedious to manage with raw useEffect and useState. TanStack Query handles all of it declaratively. Every data-fetching concern that previously required manual lifecycle management becomes a single useQuery or useMutation call. This reduces component complexity, eliminates entire categories of race-condition bugs, and makes the data layer easy to reason about at a glance.
Zod schemas can be defined once and reused on both the frontend (React Hook Form integration) and the backend (NestJS pipes). This means the same validation rules that reject a malformed request on the server are also used to validate the form before it is ever submitted, without duplicating the logic. Type inference from Zod schemas also eliminates the need to manually write matching TypeScript interfaces for request and response shapes.

Coding Conventions

Naming rules, file structure, TypeScript standards, and Git commit format.

Testing Strategy

Unit and integration testing with Jest and Vitest.

Architecture Overview

Modular monolith structure, layers, and design principles.

API Conventions

REST endpoint patterns, versioning, and Swagger documentation.

Build docs developers (and LLMs) love