# mdsameerdev/geoip-api-php architecture

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

- Interactive diagram: https://gitdiagram.com/mdsameerdev/geoip-api-php
- Repository: https://github.com/mdsameerdev/geoip-api-php

## Overview

This repository is a PHP library for looking up geolocation and network attributes from MaxMind’s legacy .dat databases. The principal documented workflow is a PHP caller opening a database, querying an IP address for country information, receiving the result, and closing the handle. Examples and source filenames indicate additional city, region, domain, ASN, organization, and network-speed lookups; their internal routing is not shown in the sampled excerpts. The timezone and region-name modules provide separate geographic reference data. Edges are limited to the README’s explicit usage flow; unsampled implementation details are not asserted.

Main entry points: [`src/geoip.inc`](https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc) (Database API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lookup["Legacy lookups"]
  node_api["Database API<br/>[geoip.inc]"]
  node_country["Country lookup<br/>[geoip.inc]"]
  node_city["City and region<br/>[geoipcity.inc]"]
  node_domain["Domain lookup<br/>[geoip.inc]"]
  node_asn["ASN lookup<br/>[geoip.inc]"]
  node_org["Organization lookup<br/>[geoip.inc]"]
  node_netspeed["Network speed<br/>[geoip.inc]"]
end

subgraph group_geo["Geographic reference"]
  node_regions["Region names"]
  node_timezone["Timezone mapping<br/>[timezone.php]"]
end

node_caller(("PHP caller"))
node_database[("Legacy .dat database")]
node_result["Lookup result"]

node_caller -->|"opens database"| node_api
node_api -->|"reads"| node_database
node_caller -->|"queries IP"| node_country
node_country -->|"returns country"| node_result

click node_api "https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc"
click node_country "https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc"
click node_city "https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoipcity.inc"
click node_domain "https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc"
click node_asn "https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc"
click node_org "https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc"
click node_netspeed "https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc"
click node_regions "https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoipregionvars.php"
click node_timezone "https://github.com/mdsameerdev/geoip-api-php/blob/master/src/timezone.php"

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_api,node_country,node_city,node_domain,node_asn,node_org,node_netspeed toneBlue
class node_regions,node_timezone,node_database toneAmber
class node_caller,node_result toneIndigo
```

## Components

### Legacy lookups

- [Database API](https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc): `src/geoip.inc`
- [Country lookup](https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc): `src/geoip.inc`
- [City and region](https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoipcity.inc): `src/geoipcity.inc`
- [Domain lookup](https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc): `src/geoip.inc`
- [ASN lookup](https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc): `src/geoip.inc`
- [Organization lookup](https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc): `src/geoip.inc`
- [Network speed](https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoip.inc): `src/geoip.inc`

### Geographic reference

- [Region names](https://github.com/mdsameerdev/geoip-api-php/blob/master/src/geoipregionvars.php): `src/geoipregionvars.php`
- [Timezone mapping](https://github.com/mdsameerdev/geoip-api-php/blob/master/src/timezone.php): `src/timezone.php`

### Other components

- **PHP caller**
- **Legacy .dat database**
- **Lookup result**

## Connections

- PHP caller → Database API: opens database (evidence: `README.md`)
- Database API → Legacy .dat database: reads (evidence: `README.md`)
- PHP caller → Country lookup: queries IP (evidence: `README.md`)
- Country lookup → Lookup result: returns country (evidence: `README.md`)
