# lahrim/pays-api architecture

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

- Interactive diagram: https://gitdiagram.com/lahrim/pays-api
- Repository: https://github.com/lahrim/pays-api

## Overview

This is a country-information API. A client requests a country list, random country, or a lookup filtered by codes, language, phone, currency, or French/English names and regions; the API queries MySQL and returns JSON. Express also serves the static public directory. The route handlers and database connection are evidenced in sampled source; the README documents the full lookup families, but their individual handlers are represented together.

Main entry points: [`routes/index.js`](https://github.com/lahrim/pays-api/blob/main/routes/index.js) (Country routes), [`app.js`](https://github.com/lahrim/pays-api/blob/main/app.js) (Express app), [`config/config.js`](https://github.com/lahrim/pays-api/blob/main/config/config.js) (MySQL connection), [`public`](https://github.com/lahrim/pays-api/tree/main/public) (Static assets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["HTTP runtime"]
  node_express["Express app<br/>[app.js]"]
  node_static["Static assets"]
end

subgraph group_lookup["Country lookup"]
  node_routes["Country routes<br/>[index.js]"]
  node_filters["Lookup families<br/>[index.js]"]
  node_json["JSON results<br/>[index.js]"]
end

subgraph group_storage["Data access"]
  node_connection["MySQL connection<br/>[config.js]"]
  node_mysql[("Countries database")]
end

node_client(("API client"))

node_client -->|"sends request"| node_express
node_express -->|"dispatches routes"| node_routes
node_express -->|"serves files"| node_static
node_routes -->|"matches lookup"| node_filters
node_routes -->|"queries countries"| node_connection
node_connection -->|"connects to"| node_mysql
node_routes -->|"returns JSON"| node_json
node_json -->|"sends response"| node_client

click node_express "https://github.com/lahrim/pays-api/blob/main/app.js"
click node_static "https://github.com/lahrim/pays-api/tree/main/public"
click node_routes "https://github.com/lahrim/pays-api/blob/main/routes/index.js"
click node_filters "https://github.com/lahrim/pays-api/blob/main/routes/index.js"
click node_json "https://github.com/lahrim/pays-api/blob/main/routes/index.js"
click node_connection "https://github.com/lahrim/pays-api/blob/main/config/config.js"

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_express,node_static,node_client toneBlue
class node_routes,node_filters,node_json toneAmber
class node_connection,node_mysql toneMint
```

## Components

### HTTP runtime

- [Express app](https://github.com/lahrim/pays-api/blob/main/app.js): `app.js`
- [Static assets](https://github.com/lahrim/pays-api/tree/main/public): `public`

### Country lookup

- [Country routes](https://github.com/lahrim/pays-api/blob/main/routes/index.js): `routes/index.js`
- [Lookup families](https://github.com/lahrim/pays-api/blob/main/routes/index.js): `routes/index.js`
- [JSON results](https://github.com/lahrim/pays-api/blob/main/routes/index.js): `routes/index.js`

### Data access

- [MySQL connection](https://github.com/lahrim/pays-api/blob/main/config/config.js): `config/config.js`
- **Countries database**

### Other components

- **API client**

## Connections

- API client → Express app: sends request
- Express app → Country routes: dispatches routes
- Express app → Static assets: serves files
- Country routes → Lookup families: matches lookup
- Country routes → MySQL connection: queries countries
- MySQL connection → Countries database: connects to
- Country routes → JSON results: returns JSON
- JSON results → API client: sends response
