# jorgesaurio/mercado-publico-kit architecture

> Architecture diagram of the GitHub repository jorgesaurio/mercado-publico-kit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jorgesaurio/mercado-publico-kit
- Repository: https://github.com/jorgesaurio/mercado-publico-kit

## Overview

Mercado Público Kit provides a web/mobile procurement browser, a ticket-protecting REST backend, and a reusable TypeScript SDK for ChileCompra’s public API. Users search listings, orders, suppliers, and buyers; open record details; and can save favorites locally. The backend validates and routes requests through cached data services to either the real SDK client or mock data. The graph preserves the documented OpenAPI and offline/favorites capabilities. Some wiring and page implementations were not excerpted, so uncertain links are omitted; edges cite only shown or indexed evidence.

Main entry points: [`apps/web/src/App.tsx`](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/App.tsx) (App routing), [`apps/web/src/api.ts`](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/api.ts) (Web API client), [`packages/sdk/src/client.ts`](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/packages/sdk/src/client.ts) (Mercado Público client), [`apps/api/src/index.ts`](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/index.ts) (Backend startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["App routing<br/>[App.tsx]"]
  node_home["Home search<br/>[Inicio.tsx]"]
  node_tenders["Tender search<br/>[Licitaciones.tsx]"]
  node_tender_detail["Tender details"]
  node_orders["Order search<br/>[Ordenes.tsx]"]
  node_order_detail["Order details<br/>[OrdenDetalle.tsx]"]
  node_suppliers["Supplier lookup<br/>[Proveedores.tsx]"]
  node_buyers["Buyer search<br/>[Compradores.tsx]"]
  node_favorites_page["Favorites view<br/>[Favoritos.tsx]"]
  node_web_api["Web API client<br/>[api.ts]"]
  node_ui_helpers["UI components<br/>[components.tsx]"]
  node_favorites_store[("Favorites storage<br/>[favoritos.ts]")]
  node_format["Display formatting<br/>[formato.ts]"]
end

subgraph group_backend["Backend API"]
  node_backend_api["REST routes<br/>[app.ts]"]
  node_service["Query services<br/>[servicio.ts]"]
  node_cache[("TTL cache<br/>[cache.ts]")]
  node_data_source["Data source contract<br/>[fuente.ts]"]
  node_api_start["Backend startup<br/>[index.ts]"]
  node_mock_source[("Mock data<br/>[mock.ts]")]
  node_openapi["OpenAPI specification<br/>[openapi.ts]"]
end

subgraph group_sdk["SDK and source"]
  node_sdk_client["Mercado Público client<br/>[client.ts]"]
  node_sdk_errors["SDK errors<br/>[errors.ts]"]
  node_sdk_utils["SDK utilities<br/>[utils.ts]"]
  node_sdk_constants["API constants<br/>[constants.ts]"]
end

node_user(("Web user"))
node_official_api{{"ChileCompra API"}}

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_tenders
node_app -->|"routes to"| node_tender_detail
node_app -->|"routes to"| node_orders
node_app -->|"routes to"| node_order_detail
node_app -->|"routes to"| node_suppliers
node_app -->|"routes to"| node_buyers
node_app -->|"routes to"| node_favorites_page
node_app -->|"reads status"| node_web_api
node_home -->|"requests data"| node_web_api
node_tenders -->|"requests data"| node_web_api
node_tender_detail -->|"requests detail"| node_web_api
node_orders -->|"requests data"| node_web_api
node_order_detail -->|"requests detail"| node_web_api
node_suppliers -->|"requests data"| node_web_api
node_buyers -->|"requests data"| node_web_api
node_favorites_page -->|"reads favorites"| node_favorites_store
node_tender_detail -->|"renders with"| node_ui_helpers
node_order_detail -->|"renders with"| node_ui_helpers
node_ui_helpers -->|"updates favorites"| node_favorites_store
node_ui_helpers -->|"formats dates"| node_format
node_web_api -->|"HTTP requests"| node_backend_api
node_backend_api -->|"dispatches queries"| node_service
node_backend_api -->|"serves specification"| node_openapi
node_service -->|"reads and writes"| node_cache
node_service -->|"queries source"| node_data_source
node_api_start -->|"starts routes"| node_backend_api
node_api_start -->|"constructs service"| node_service
node_api_start -->|"selects mock"| node_mock_source
node_api_start -->|"configures client"| node_sdk_client
node_sdk_client -->|"calls endpoints"| node_official_api
node_sdk_client -->|"uses errors"| node_sdk_errors
node_sdk_client -->|"uses utilities"| node_sdk_utils
node_sdk_client -->|"uses constants"| node_sdk_constants

click node_app "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/App.tsx"
click node_home "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/Inicio.tsx"
click node_tenders "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/Licitaciones.tsx"
click node_tender_detail "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/LicitacionDetalle.tsx"
click node_orders "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/Ordenes.tsx"
click node_order_detail "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/OrdenDetalle.tsx"
click node_suppliers "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/Proveedores.tsx"
click node_buyers "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/Compradores.tsx"
click node_favorites_page "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/Favoritos.tsx"
click node_web_api "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/api.ts"
click node_ui_helpers "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/components.tsx"
click node_favorites_store "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/favoritos.ts"
click node_format "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/formato.ts"
click node_backend_api "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/app.ts"
click node_service "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/servicio.ts"
click node_cache "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/cache.ts"
click node_data_source "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/fuente.ts"
click node_api_start "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/index.ts"
click node_mock_source "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/mock.ts"
click node_openapi "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/openapi.ts"
click node_sdk_client "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/packages/sdk/src/client.ts"
click node_sdk_errors "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/packages/sdk/src/errors.ts"
click node_sdk_utils "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/packages/sdk/src/utils.ts"
click node_sdk_constants "https://github.com/jorgesaurio/mercado-publico-kit/blob/main/packages/sdk/src/constants.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_home,node_tenders,node_tender_detail,node_orders,node_order_detail,node_suppliers,node_buyers,node_favorites_page,node_web_api,node_ui_helpers,node_favorites_store,node_format,node_user toneBlue
class node_backend_api,node_service,node_cache,node_data_source,node_api_start,node_mock_source,node_openapi toneAmber
class node_sdk_client,node_sdk_errors,node_sdk_utils,node_sdk_constants,node_official_api toneMint
```

## Components

### Web application

- [App routing](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Home search](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/Inicio.tsx): `apps/web/src/pages/Inicio.tsx`
- [Tender search](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/Licitaciones.tsx): `apps/web/src/pages/Licitaciones.tsx`
- [Tender details](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/LicitacionDetalle.tsx): `apps/web/src/pages/LicitacionDetalle.tsx`
- [Order search](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/Ordenes.tsx): `apps/web/src/pages/Ordenes.tsx`
- [Order details](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/OrdenDetalle.tsx): `apps/web/src/pages/OrdenDetalle.tsx`
- [Supplier lookup](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/Proveedores.tsx): `apps/web/src/pages/Proveedores.tsx`
- [Buyer search](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/Compradores.tsx): `apps/web/src/pages/Compradores.tsx`
- [Favorites view](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/pages/Favoritos.tsx): `apps/web/src/pages/Favoritos.tsx`
- [Web API client](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/api.ts): `apps/web/src/api.ts`
- [UI components](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/components.tsx): `apps/web/src/components.tsx`
- [Favorites storage](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/favoritos.ts): `apps/web/src/favoritos.ts`
- [Display formatting](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/web/src/formato.ts): `apps/web/src/formato.ts`

### Backend API

- [REST routes](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/app.ts): `apps/api/src/app.ts`
- [Query services](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/servicio.ts): `apps/api/src/servicio.ts`
- [TTL cache](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/cache.ts): `apps/api/src/cache.ts`
- [Data source contract](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/fuente.ts): `apps/api/src/fuente.ts`
- [Backend startup](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/index.ts): `apps/api/src/index.ts`
- [Mock data](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/mock.ts): `apps/api/src/mock.ts`
- [OpenAPI specification](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/apps/api/src/openapi.ts): `apps/api/src/openapi.ts`

### SDK and source

- [Mercado Público client](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/packages/sdk/src/client.ts): `packages/sdk/src/client.ts`
- [SDK errors](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/packages/sdk/src/errors.ts): `packages/sdk/src/errors.ts`
- [SDK utilities](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/packages/sdk/src/utils.ts): `packages/sdk/src/utils.ts`
- [API constants](https://github.com/jorgesaurio/mercado-publico-kit/blob/main/packages/sdk/src/constants.ts): `packages/sdk/src/constants.ts`

### Other components

- **Web user**
- **ChileCompra API**

## Connections

- Web user → App routing: uses (evidence: `README.md`)
- App routing → Home search: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Tender search: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Tender details: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Order search: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Order details: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Supplier lookup: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Buyer search: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Favorites view: routes to (evidence: `apps/web/src/App.tsx`)
- App routing → Web API client: reads status (evidence: `apps/web/src/App.tsx`)
- Home search → Web API client: requests data (evidence: `apps/web/src/pages/Inicio.tsx`)
- Tender search → Web API client: requests data (evidence: `apps/web/src/pages/Licitaciones.tsx`)
- Tender details → Web API client: requests detail (evidence: `apps/web/src/pages/LicitacionDetalle.tsx`)
- Order search → Web API client: requests data (evidence: `apps/web/src/pages/Ordenes.tsx`)
- Order details → Web API client: requests detail (evidence: `apps/web/src/pages/OrdenDetalle.tsx`)
- Supplier lookup → Web API client: requests data (evidence: `apps/web/src/pages/Proveedores.tsx`)
- Buyer search → Web API client: requests data (evidence: `apps/web/src/pages/Compradores.tsx`)
- Favorites view → Favorites storage: reads favorites (evidence: `apps/web/src/pages/Favoritos.tsx`)
- Tender details → UI components: renders with (evidence: `apps/web/src/pages/LicitacionDetalle.tsx`)
- Order details → UI components: renders with (evidence: `apps/web/src/pages/OrdenDetalle.tsx`)
- UI components → Favorites storage: updates favorites (evidence: `apps/web/src/components.tsx`)
- UI components → Display formatting: formats dates (evidence: `apps/web/src/components.tsx`)
- Web API client → REST routes: HTTP requests (evidence: `apps/web/src/api.ts`)
- REST routes → Query services: dispatches queries (evidence: `apps/api/src/app.ts`)
- REST routes → OpenAPI specification: serves specification (evidence: `apps/api/src/app.ts`)
- Query services → TTL cache: reads and writes (evidence: `apps/api/src/servicio.ts`)
- Query services → Data source contract: queries source (evidence: `apps/api/src/servicio.ts`)
- Backend startup → REST routes: starts routes (evidence: `apps/api/src/index.ts`)
- Backend startup → Query services: constructs service (evidence: `apps/api/src/index.ts`)
- Backend startup → Mock data: selects mock (evidence: `apps/api/src/index.ts`)
- Backend startup → Mercado Público client: configures client (evidence: `apps/api/src/index.ts`)
- Mercado Público client → ChileCompra API: calls endpoints (evidence: `README.md`)
- Mercado Público client → SDK errors: uses errors (evidence: `packages/sdk/src/client.ts`)
- Mercado Público client → SDK utilities: uses utilities (evidence: `packages/sdk/src/client.ts`)
- Mercado Público client → API constants: uses constants (evidence: `packages/sdk/src/client.ts`)
