How kcrsromero-cmyk/contrato-cla works
Purpose and entry points
Contrato-Claro is a civic transparency platform for exploring and analyzing Colombian SECOP II procurement data. It is a React/Vite client backed by a TypeScript API service. Frontend bootstraps at frontend/src/main.tsx into frontend/src/App.tsx; the backend HTTP process starts at backend/src/server.ts. Containers are defined by docker-compose.yml, frontend/Dockerfile, and backend/Dockerfile.
Frontend application shell and state
The client organizes dashboard, contract exploration, metrics, territorial filtering, and account UX within the application shell. Authentication state is held centrally and exposed to UI flows such as login, profiles, onboarding, and favorites.
• frontend/src/components/AppLayout.tsx
• frontend/src/context/AuthContext.tsx
• frontend/src/components/Dashboard.tsx
Procurement exploration and analytics UI
Feature views consume contract-oriented hooks and render summary metrics, monthly comparisons, contract detail/search, and integrity-analysis tabs. Client utilities adapt source contract records and calculate presentation-level metrics; IndexedDB supports local caching.
• frontend/src/components/ContratosView.tsx
• frontend/src/components/MetricasView.tsx
• frontend/src/hooks/useContratos.ts
• frontend/src/services/db.ts
API boundary and external data source
The backend procurement module is the boundary between the application and Socrata’s Datos Abiertos Colombia SECOP II dataset (jbjy-vk9h.json). Its provider abstraction allows application services to depend on ContractProvider, while the Socrata adapter implements remote retrieval. The resulting API serves frontend dashboard, filtering, contract, and favorite workflows.
• backend/src/modules/procurement/domain/ContractProvider.ts
• backend/src/modules/procurement/infrastructure/SocrataContractProvider.ts
• backend/src/modules/procurement/application/ProcurementService.ts
• backend/src/modules/procurement/presentation/routes.ts
Identity and authorization
Identity is modularized around a provider interface and authenticated-user domain model. Supabase is the implemented external identity provider; JWT validation and authentication middleware protect server routes, while controllers expose identity endpoints.
• backend/src/modules/identity/infrastructure/SupabaseIdentityProvider.ts
• backend/src/modules/identity/infrastructure/JWTValidator.ts
• backend/src/modules/identity/presentation/AuthMiddleware.ts
• backend/src/modules/identity/presentation/routes.ts
Persistent data, cache, and background refresh
Prisma owns relational persistence for users, procurement records/favorites, and territorial reference data, with schema evolution captured in migrations. Redis is an infrastructure cache adapter. A refresh worker provides asynchronous procurement-data synchronization rather than coupling refresh work to request handling.
• backend/prisma/schema.prisma
• backend/src/infrastructure/db/prisma.ts
• backend/src/infrastructure/redis/RedisCacheAdapter.ts
• backend/src/infrastructure/jobs/refreshWorker.ts
Integrity, audit, and operational boundaries
The backend audit module records or mediates auditable request/application activity. Procurement domain logic includes similarity analysis; frontend metrics views surface repeated-object, lexical-similarity, financial, and deadline signals. Logging is centralized as infrastructure.
• backend/src/modules/audit/application/AuditService.ts
• backend/src/modules/audit/presentation/AuditMiddleware.ts
• backend/src/modules/procurement/domain/SimilarityDomainService.ts
• backend/src/infrastructure/logger.ts
Runtime and deployment model
Frontend runs as a browser SPA built with React, TypeScript, and Vite, with service-worker assets under frontend/public/sw.js. Backend is a Node/TypeScript service using Prisma, Redis, Supabase authentication, and Socrata SODA. Docker Compose coordinates the deployable frontend/backend environment; required secrets and service endpoints are represented by .env.example.
Main entry points: server.ts HTTP server · ProcurementService.ts Procurement service · App.tsx Application shell · useContratos.ts Contract data hook
Components 21
Browser client
React/Vite procurement exploration SPA.
- Client bootstrap
frontend/src/main.tsx - Application shell · Hosts dashboard, exploration, metrics, and account flows.
frontend/src/App.tsx - Authentication state
frontend/src/context/AuthContext.tsx - Dashboard
frontend/src/components/Dashboard.tsx - Contracts and metrics UI · Search, details, comparisons, and integrity signals.
frontend/src/components/ContratosView.tsx - Contract data hook
frontend/src/hooks/useContratos.ts - IndexedDB cache
frontend/src/services/db.ts
API service
Node/TypeScript application modules and HTTP boundary.
- HTTP server
backend/src/server.ts - Procurement API · Serves dashboard, filters, contracts, and favorites.
backend/src/modules/procurement/presentation/routes.ts - Procurement service
backend/src/modules/procurement/application/ProcurementService.ts - Integrity analysis · Computes procurement similarity signals.
backend/src/modules/procurement/domain/SimilarityDomainService.ts - Identity API
backend/src/modules/identity/presentation/routes.ts - JWT auth middleware
backend/src/modules/identity/presentation/AuthMiddleware.ts - Audit service
backend/src/modules/audit/application/AuditService.ts
Data and integrations
Persistence, cache, external providers, and refresh work.
- Contract provider
backend/src/modules/procurement/domain/ContractProvider.ts - Socrata adapter
backend/src/modules/procurement/infrastructure/SocrataContractProvider.ts - Supabase identity
backend/src/modules/identity/infrastructure/SupabaseIdentityProvider.ts - Prisma persistence · Stores users, procurement data, favorites, and territorial references.
backend/src/infrastructure/db/prisma.ts - Redis cache
backend/src/infrastructure/redis/RedisCacheAdapter.ts - Procurement refresh worker · Synchronizes procurement data asynchronously.
backend/src/infrastructure/jobs/refreshWorker.ts
Connections 22
- Client bootstrap → Application shell: mounts
- Application shell → Authentication state: uses
- Application shell → Dashboard: renders
- Application shell → Contracts and metrics UI: renders
- Contracts and metrics UI → Contract data hook: loads contracts
- Contract data hook → IndexedDB cache: caches locally
- Contract data hook → HTTP server: API requests
- HTTP server → JWT auth middleware: protects requests
- HTTP server → Procurement API: serves
- HTTP server → Identity API: serves
- JWT auth middleware → Supabase identity: validates identity
- Procurement API → Procurement service: invokes
- Procurement service → Contract provider: depends on
- Contract provider → Socrata adapter: implemented by
- Procurement service → Integrity analysis: analyzes
- Procurement service → Prisma persistence: reads and writes
- Procurement service → Redis cache: caches
- HTTP server → Audit service: audits activity
- Procurement refresh worker → Socrata adapter: retrieves updates
- Procurement refresh worker → Prisma persistence: synchronizes
- Docker Compose → Client bootstrap: runs frontend
- Docker Compose → HTTP server: runs backend