# samuelyuma/automotive-marketplace-api architecture

> Architecture diagram of the GitHub repository samuelyuma/automotive-marketplace-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samuelyuma/automotive-marketplace-api
- Repository: https://github.com/samuelyuma/automotive-marketplace-api

## Overview

Automotive Marketplace API serves public HTTP workflows for category management, vehicle listing lifecycle, browsing, filtering, search, and suggestions. Requests enter through Elysia controllers, which validate and translate inputs, invoke application services, and return presented responses. Services use PostgreSQL repositories for domain data and cache ports for selected reads; the server also exposes health checks and optional Upstash rate limiting. The graph preserves the documented filter and suggestion capabilities, though their source was not excerpted. Edges are limited to relationships visible in excerpts, SOURCE INDEX references, or the README.

Main entry points: [`src/main/server.ts`](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/main/server.ts) (App and routes), [`src/interface/controllers/category.controller.ts`](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/interface/controllers/category.controller.ts) (Category routes), [`src/interface/controllers/listing.controller.ts`](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/interface/controllers/listing.controller.ts) (Listing routes), [`src/infrastructure/postgres/client.ts`](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/infrastructure/postgres/client.ts) (Postgres access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_server["App and routes<br/>[server.ts]"]
  node_category_api["Category routes"]
  node_listing_api["Listing routes"]
  node_search_api["Search routes"]
  node_filter_api["Filter routes"]
  node_health_api["Health routes"]
  node_http_helpers["HTTP validation and responses"]
  node_presenters["Response presenters"]
  node_middleware["Request middleware"]
end

subgraph group_app["Application"]
  node_category_service["Category service"]
  node_listing_service["Listing service<br/>[listing.service.ts]"]
  node_search_service["Search service"]
  node_filter_service["Filter service<br/>[filter.service.ts]"]
  node_domain["Marketplace domain"]
end

subgraph group_data["Persistence"]
  node_category_repo["Category repository"]
  node_listing_repo["Listing repository"]
  node_search_repo["Search repository"]
  node_filter_repo["Filter repository"]
  node_postgres_client["Postgres access<br/>[client.ts]"]
end

subgraph group_runtime["Runtime services"]
  node_cache_port["Cache contract<br/>[cache.port.ts]"]
  node_cache_impl["Redis cache backends<br/>[redis-backend.ts]"]
  node_config["Runtime configuration<br/>[env.ts]"]
  node_logging["Logging and tracing<br/>[logger.ts]"]
end

node_clients(("API clients"))
node_postgres[("PostgreSQL")]
node_redis[("Redis / Upstash")]

node_clients -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_category_api
node_server -->|"mounts routes"| node_listing_api
node_server -->|"mounts routes"| node_search_api
node_server -->|"mounts routes"| node_filter_api
node_server -->|"mounts routes"| node_health_api
node_server -->|"registers"| node_middleware
node_server -->|"reads settings"| node_config
node_server -->|"checks backend"| node_cache_impl
node_category_api -->|"calls"| node_category_service
node_category_api -->|"browses listings"| node_search_service
node_listing_api -->|"manages listings"| node_listing_service
node_listing_api -->|"browses listings"| node_search_service
node_search_api -->|"searches and suggests"| node_search_service
node_filter_api -->|"requests filters"| node_filter_service
node_category_api -->|"uses"| node_http_helpers
node_listing_api -->|"uses"| node_http_helpers
node_category_api -->|"formats results"| node_presenters
node_listing_api -->|"formats results"| node_presenters
node_category_service -->|"uses repository"| node_category_repo
node_listing_service -->|"uses repository"| node_listing_repo
node_search_service -->|"uses repository"| node_search_repo
node_filter_service -->|"uses repository"| node_filter_repo
node_filter_service -->|"loads categories"| node_category_repo
node_listing_service -->|"checks category"| node_category_repo
node_category_repo -->|"executes queries"| node_postgres_client
node_listing_repo -->|"executes queries"| node_postgres_client
node_search_repo -->|"executes queries"| node_postgres_client
node_filter_repo -->|"executes queries"| node_postgres_client
node_postgres_client -->|"queries"| node_postgres
node_category_service -.->|"uses types"| node_domain
node_listing_service -->|"uses types"| node_domain
node_search_service -->|"uses types"| node_domain
node_category_api -->|"caches reads"| node_cache_port
node_listing_api -->|"caches reads"| node_cache_port
node_cache_impl -.->|"implements contract"| node_cache_port
node_cache_impl -->|"uses backend"| node_redis
node_server -->|"configures logger"| node_logging
node_postgres_client -->|"logs queries"| node_logging
node_config -->|"sets log level"| node_logging

click node_server "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/main/server.ts"
click node_category_api "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/interface/controllers/category.controller.ts"
click node_listing_api "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/interface/controllers/listing.controller.ts"
click node_search_api "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/interface/controllers/listing-search.controller.ts"
click node_filter_api "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/interface/controllers/filter.controller.ts"
click node_health_api "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/interface/controllers/health.controller.ts"
click node_http_helpers "https://github.com/samuelyuma/automotive-marketplace-api/tree/main/src/interface/http"
click node_presenters "https://github.com/samuelyuma/automotive-marketplace-api/tree/main/src/interface/presenters"
click node_middleware "https://github.com/samuelyuma/automotive-marketplace-api/tree/main/src/interface/middleware"
click node_category_service "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/application/service/category.service.ts"
click node_listing_service "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/application/service/listing.service.ts"
click node_search_service "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/application/service/listing-search.service.ts"
click node_filter_service "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/application/service/filter.service.ts"
click node_domain "https://github.com/samuelyuma/automotive-marketplace-api/tree/main/src/domain/entities"
click node_category_repo "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/repository/postgres/category.repository.ts"
click node_listing_repo "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/repository/postgres/listing.repository.ts"
click node_search_repo "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/repository/postgres/listing-search.repository.ts"
click node_filter_repo "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/repository/postgres/filter.repository.ts"
click node_postgres_client "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/infrastructure/postgres/client.ts"
click node_cache_port "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/application/ports/cache.port.ts"
click node_cache_impl "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/infrastructure/cache/redis-backend.ts"
click node_config "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/main/config/env.ts"
click node_logging "https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/infrastructure/logging/logger.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_server,node_category_api,node_listing_api,node_search_api,node_filter_api,node_health_api,node_http_helpers,node_presenters,node_middleware,node_clients toneBlue
class node_category_service,node_listing_service,node_search_service,node_filter_service,node_domain,node_postgres,node_redis toneAmber
class node_category_repo,node_listing_repo,node_search_repo,node_filter_repo,node_postgres_client toneMint
class node_cache_port,node_cache_impl,node_config,node_logging toneRose
```

## Components

### HTTP API

- [App and routes](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/main/server.ts): `src/main/server.ts`
- [Category routes](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/interface/controllers/category.controller.ts): `src/interface/controllers/category.controller.ts`
- [Listing routes](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/interface/controllers/listing.controller.ts): `src/interface/controllers/listing.controller.ts`
- [Search routes](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/interface/controllers/listing-search.controller.ts): `src/interface/controllers/listing-search.controller.ts`
- [Filter routes](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/interface/controllers/filter.controller.ts): `src/interface/controllers/filter.controller.ts`
- [Health routes](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/interface/controllers/health.controller.ts): `src/interface/controllers/health.controller.ts`
- [HTTP validation and responses](https://github.com/samuelyuma/automotive-marketplace-api/tree/main/src/interface/http): `src/interface/http`
- [Response presenters](https://github.com/samuelyuma/automotive-marketplace-api/tree/main/src/interface/presenters): `src/interface/presenters`
- [Request middleware](https://github.com/samuelyuma/automotive-marketplace-api/tree/main/src/interface/middleware): `src/interface/middleware`

### Application

- [Category service](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/application/service/category.service.ts): `src/application/service/category.service.ts`
- [Listing service](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/application/service/listing.service.ts): `src/application/service/listing.service.ts`
- [Search service](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/application/service/listing-search.service.ts): `src/application/service/listing-search.service.ts`
- [Filter service](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/application/service/filter.service.ts): `src/application/service/filter.service.ts`
- [Marketplace domain](https://github.com/samuelyuma/automotive-marketplace-api/tree/main/src/domain/entities): `src/domain/entities`

### Persistence

- [Category repository](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/repository/postgres/category.repository.ts): `src/repository/postgres/category.repository.ts`
- [Listing repository](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/repository/postgres/listing.repository.ts): `src/repository/postgres/listing.repository.ts`
- [Search repository](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/repository/postgres/listing-search.repository.ts): `src/repository/postgres/listing-search.repository.ts`
- [Filter repository](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/repository/postgres/filter.repository.ts): `src/repository/postgres/filter.repository.ts`
- [Postgres access](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/infrastructure/postgres/client.ts): `src/infrastructure/postgres/client.ts`

### Runtime services

- [Cache contract](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/application/ports/cache.port.ts): `src/application/ports/cache.port.ts`
- [Redis cache backends](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/infrastructure/cache/redis-backend.ts): `src/infrastructure/cache/redis-backend.ts`
- [Runtime configuration](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/main/config/env.ts): `src/main/config/env.ts`
- [Logging and tracing](https://github.com/samuelyuma/automotive-marketplace-api/blob/main/src/infrastructure/logging/logger.ts): `src/infrastructure/logging/logger.ts`

### Other components

- **API clients**
- **PostgreSQL**
- **Redis / Upstash**

## Connections

- API clients → App and routes: sends requests (evidence: `README.md`)
- App and routes → Category routes: mounts routes (evidence: `src/main/server.ts`)
- App and routes → Listing routes: mounts routes (evidence: `src/main/server.ts`)
- App and routes → Search routes: mounts routes (evidence: `src/main/server.ts`)
- App and routes → Filter routes: mounts routes (evidence: `src/main/server.ts`)
- App and routes → Health routes: mounts routes (evidence: `src/main/server.ts`)
- App and routes → Request middleware: registers (evidence: `src/main/server.ts`)
- App and routes → Runtime configuration: reads settings (evidence: `src/main/server.ts`)
- App and routes → Redis cache backends: checks backend (evidence: `src/main/server.ts`)
- Category routes → Category service: calls (evidence: `src/interface/controllers/category.controller.ts`)
- Category routes → Search service: browses listings (evidence: `src/interface/controllers/category.controller.ts`)
- Listing routes → Listing service: manages listings (evidence: `src/interface/controllers/listing.controller.ts`)
- Listing routes → Search service: browses listings (evidence: `src/interface/controllers/listing.controller.ts`)
- Search routes → Search service: searches and suggests (evidence: `src/interface/controllers/listing-search.controller.ts`)
- Filter routes → Filter service: requests filters (evidence: `src/interface/controllers/filter.controller.ts`)
- Category routes → HTTP validation and responses: uses (evidence: `src/interface/controllers/category.controller.ts`)
- Listing routes → HTTP validation and responses: uses (evidence: `src/interface/controllers/listing.controller.ts`)
- Category routes → Response presenters: formats results (evidence: `src/interface/controllers/category.controller.ts`)
- Listing routes → Response presenters: formats results (evidence: `src/interface/controllers/listing.controller.ts`)
- Category service → Category repository: uses repository (evidence: `src/main/container.ts`)
- Listing service → Listing repository: uses repository (evidence: `src/main/container.ts`)
- Search service → Search repository: uses repository (evidence: `src/main/container.ts`)
- Filter service → Filter repository: uses repository (evidence: `src/main/container.ts`)
- Filter service → Category repository: loads categories (evidence: `src/application/service/filter.service.ts`)
- Listing service → Category repository: checks category (evidence: `src/application/service/listing.service.ts`)
- Category repository → Postgres access: executes queries (evidence: `src/repository/postgres/category.repository.ts`)
- Listing repository → Postgres access: executes queries (evidence: `src/repository/postgres/listing.repository.ts`)
- Search repository → Postgres access: executes queries (evidence: `src/repository/postgres/listing-search.repository.ts`)
- Filter repository → Postgres access: executes queries (evidence: `src/repository/postgres/filter.repository.ts`)
- Postgres access → PostgreSQL: queries (evidence: `README.md`)
- Category service → Marketplace domain: uses types
- Listing service → Marketplace domain: uses types (evidence: `src/application/service/listing.service.ts`)
- Search service → Marketplace domain: uses types
- Category routes → Cache contract: caches reads (evidence: `src/interface/controllers/category.controller.ts`)
- Listing routes → Cache contract: caches reads (evidence: `src/interface/controllers/listing.controller.ts`)
- Redis cache backends → Cache contract: implements contract
- Redis cache backends → Redis / Upstash: uses backend
- App and routes → Logging and tracing: configures logger (evidence: `src/main/server.ts`)
- Postgres access → Logging and tracing: logs queries (evidence: `src/infrastructure/postgres/client.ts`)
- Runtime configuration → Logging and tracing: sets log level (evidence: `src/infrastructure/logging/logger.ts`)
