# mrjackwills/adsbdb architecture

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

- Interactive diagram: https://gitdiagram.com/mrjackwills/adsbdb
- Repository: https://github.com/mrjackwills/adsbdb

## Overview

ADSBDB is a public aircraft, airline, and flight-route API. Clients call routed GET endpoints for aircraft, callsign/route, airline, statistics, and Mode S/N-number conversions; the API validates requests, queries PostgreSQL with Redis caching and rate limiting, and returns shaped JSON. Optional scraping can fill missing route or photo data. Authorized PATCH endpoints update aircraft and route records. The source excerpts show key routing, persistence, scraping, and authentication links; some subsystem details are documented capabilities or indexed modules rather than fully sampled implementations.

Main entry points: [`src/api/router_get.rs`](https://github.com/mrjackwills/adsbdb/blob/main/src/api/router_get.rs) (GET handlers), [`src/api/router_patch.rs`](https://github.com/mrjackwills/adsbdb/blob/main/src/api/router_patch.rs) (PATCH handlers), [`src/db/postgres/mod.rs`](https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/mod.rs) (PostgreSQL), [`src/db/postgres/model_aircraft.rs`](https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/model_aircraft.rs) (Aircraft lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_routes["Route dispatch<br/>[mod.rs]"]
  node_get["GET handlers<br/>[router_get.rs]"]
  node_patch["PATCH handlers<br/>[router_patch.rs]"]
end

subgraph group_domain["Lookup and conversion"]
  node_validate["Input validation<br/>[input.rs]"]
  node_format["Response mapping<br/>[response.rs]"]
  node_aircraft["Aircraft lookup<br/>[model_aircraft.rs]"]
  node_airline["Airline lookup<br/>[model_airline.rs]"]
  node_airport["Airport lookup<br/>[model_airport.rs]"]
  node_routesdata["Flight routes"]
  node_conversion["Registration conversion<br/>[n_number.rs]"]
end

subgraph group_storage["Persistence and cache"]
  node_stats["Request statistics"]
  node_postgres[("PostgreSQL<br/>[mod.rs]")]
  node_redis[("Redis cache<br/>[mod.rs]")]
end

subgraph group_support["Enrichment and controls"]
  node_limiter["Rate limiting<br/>[ratelimit.rs]"]
  node_scraper["Data scraper<br/>[mod.rs]"]
  node_auth["Update authorization<br/>[argon.rs]"]
  node_config["Runtime configuration<br/>[parse_env.rs]"]
end

node_client(("API client"))
node_json(("JSON consumer"))

node_client -->|"sends request"| node_routes
node_routes -->|"dispatches GET"| node_get
node_routes -->|"dispatches PATCH"| node_patch
node_get -->|"validates input"| node_validate
node_get -->|"looks up"| node_aircraft
node_get -->|"looks up"| node_routesdata
node_get -->|"requests enrichment"| node_scraper
node_get -->|"builds response"| node_format
node_get -.->|"uses cache"| node_redis
node_get -.->|"rate limits"| node_limiter
node_get -.->|"converts identifiers"| node_conversion
node_get -.->|"records requests"| node_stats
node_get -.->|"looks up"| node_airline
node_patch -->|"verifies credentials"| node_auth
node_patch -.->|"updates aircraft"| node_aircraft
node_patch -.->|"updates route"| node_routesdata
node_patch -->|"validates airports"| node_airport
node_aircraft -.->|"queries and writes"| node_postgres
node_airline -.->|"queries"| node_postgres
node_airport -.->|"queries"| node_postgres
node_routesdata -->|"queries and writes"| node_postgres
node_stats -.->|"seeds statistics"| node_postgres
node_get -->|"returns JSON"| node_json
node_patch -->|"returns status"| node_json
node_config -.->|"configures hash"| node_auth
node_scraper -->|"persists routes"| node_routesdata
node_scraper -.->|"enriches photos"| node_aircraft
node_redis -->|"stores limits"| node_limiter

click node_routes "https://github.com/mrjackwills/adsbdb/blob/main/src/api/mod.rs"
click node_get "https://github.com/mrjackwills/adsbdb/blob/main/src/api/router_get.rs"
click node_patch "https://github.com/mrjackwills/adsbdb/blob/main/src/api/router_patch.rs"
click node_validate "https://github.com/mrjackwills/adsbdb/blob/main/src/api/input.rs"
click node_format "https://github.com/mrjackwills/adsbdb/blob/main/src/api/response.rs"
click node_aircraft "https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/model_aircraft.rs"
click node_airline "https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/model_airline.rs"
click node_airport "https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/model_airport.rs"
click node_routesdata "https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/model_flightroute.rs"
click node_conversion "https://github.com/mrjackwills/adsbdb/blob/main/src/n_number.rs"
click node_stats "https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/model_incoming_request.rs"
click node_postgres "https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/mod.rs"
click node_redis "https://github.com/mrjackwills/adsbdb/blob/main/src/db/redis/mod.rs"
click node_limiter "https://github.com/mrjackwills/adsbdb/blob/main/src/db/redis/ratelimit.rs"
click node_scraper "https://github.com/mrjackwills/adsbdb/blob/main/src/scraper/mod.rs"
click node_auth "https://github.com/mrjackwills/adsbdb/blob/main/src/argon.rs"
click node_config "https://github.com/mrjackwills/adsbdb/blob/main/src/parse_env.rs"

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_routes,node_get,node_patch,node_client toneBlue
class node_validate,node_format,node_aircraft,node_airline,node_airport,node_routesdata,node_conversion toneAmber
class node_stats,node_postgres,node_redis toneMint
class node_limiter,node_scraper,node_auth,node_config toneRose
class node_json toneIndigo
```

## Components

### HTTP API

- [Route dispatch](https://github.com/mrjackwills/adsbdb/blob/main/src/api/mod.rs): `src/api/mod.rs`
- [GET handlers](https://github.com/mrjackwills/adsbdb/blob/main/src/api/router_get.rs): `src/api/router_get.rs`
- [PATCH handlers](https://github.com/mrjackwills/adsbdb/blob/main/src/api/router_patch.rs): `src/api/router_patch.rs`

### Lookup and conversion

- [Input validation](https://github.com/mrjackwills/adsbdb/blob/main/src/api/input.rs): `src/api/input.rs`
- [Response mapping](https://github.com/mrjackwills/adsbdb/blob/main/src/api/response.rs): `src/api/response.rs`
- [Aircraft lookup](https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/model_aircraft.rs): `src/db/postgres/model_aircraft.rs`
- [Airline lookup](https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/model_airline.rs): `src/db/postgres/model_airline.rs`
- [Airport lookup](https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/model_airport.rs): `src/db/postgres/model_airport.rs`
- [Flight routes](https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/model_flightroute.rs): `src/db/postgres/model_flightroute.rs`
- [Registration conversion](https://github.com/mrjackwills/adsbdb/blob/main/src/n_number.rs): `src/n_number.rs`

### Persistence and cache

- [Request statistics](https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/model_incoming_request.rs): `src/db/postgres/model_incoming_request.rs`
- [PostgreSQL](https://github.com/mrjackwills/adsbdb/blob/main/src/db/postgres/mod.rs): `src/db/postgres/mod.rs`
- [Redis cache](https://github.com/mrjackwills/adsbdb/blob/main/src/db/redis/mod.rs): `src/db/redis/mod.rs`

### Enrichment and controls

- [Rate limiting](https://github.com/mrjackwills/adsbdb/blob/main/src/db/redis/ratelimit.rs): `src/db/redis/ratelimit.rs`
- [Data scraper](https://github.com/mrjackwills/adsbdb/blob/main/src/scraper/mod.rs): `src/scraper/mod.rs`
- [Update authorization](https://github.com/mrjackwills/adsbdb/blob/main/src/argon.rs): `src/argon.rs`
- [Runtime configuration](https://github.com/mrjackwills/adsbdb/blob/main/src/parse_env.rs): `src/parse_env.rs`

### Other components

- **API client**
- **JSON consumer**

## Connections

- API client → Route dispatch: sends request (evidence: `README.md`)
- Route dispatch → GET handlers: dispatches GET (evidence: `src/api/mod.rs`)
- Route dispatch → PATCH handlers: dispatches PATCH (evidence: `src/api/mod.rs`)
- GET handlers → Input validation: validates input (evidence: `src/api/router_get.rs`)
- GET handlers → Aircraft lookup: looks up (evidence: `src/api/router_get.rs`)
- GET handlers → Flight routes: looks up (evidence: `src/api/router_get.rs`)
- GET handlers → Data scraper: requests enrichment (evidence: `src/api/router_get.rs`)
- GET handlers → Response mapping: builds response (evidence: `src/api/router_get.rs`)
- GET handlers → Redis cache: uses cache (evidence: `src/api/router_get.rs`)
- GET handlers → Rate limiting: rate limits
- GET handlers → Registration conversion: converts identifiers
- GET handlers → Request statistics: records requests
- GET handlers → Airline lookup: looks up
- PATCH handlers → Update authorization: verifies credentials (evidence: `src/api/router_patch.rs`)
- PATCH handlers → Aircraft lookup: updates aircraft
- PATCH handlers → Flight routes: updates route
- PATCH handlers → Airport lookup: validates airports (evidence: `src/api/router_patch.rs`)
- Aircraft lookup → PostgreSQL: queries and writes (evidence: `src/db/postgres/mod.rs`)
- Airline lookup → PostgreSQL: queries (evidence: `src/db/postgres/mod.rs`)
- Airport lookup → PostgreSQL: queries (evidence: `src/db/postgres/mod.rs`)
- Flight routes → PostgreSQL: queries and writes (evidence: `src/db/postgres/model_flightroute.rs`)
- Request statistics → PostgreSQL: seeds statistics (evidence: `src/db/postgres/mod.rs`)
- GET handlers → JSON consumer: returns JSON (evidence: `README.md`)
- PATCH handlers → JSON consumer: returns status (evidence: `README.md`)
- Runtime configuration → Update authorization: configures hash (evidence: `src/parse_env.rs`)
- Data scraper → Flight routes: persists routes (evidence: `src/db/postgres/model_flightroute.rs`)
- Data scraper → Aircraft lookup: enriches photos
- Redis cache → Rate limiting: stores limits (evidence: `src/db/redis/mod.rs`)
