# jdevilliers/geoip architecture

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

- Interactive diagram: https://gitdiagram.com/jdevilliers/geoip
- Repository: https://github.com/jdevilliers/geoip

## Overview

This is a small Go binding for the GeoIP C library. Callers open or create a database, query IP addresses for country or city records, inspect database metadata, and release the handle. The cgo implementation performs native calls and converts returned city text using a helper in geoip.go; the non-cgo file provides matching stubs that report cgo is required. No README is present, so the map reflects only the shown API and implementation.

Main entry points: [`geoip_cgo.go`](https://github.com/jdevilliers/geoip/blob/master/geoip_cgo.go) (GeoIP binding), [`geoip.go`](https://github.com/jdevilliers/geoip/blob/master/geoip.go) (Record model and conversion)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_caller(("Go caller"))
node_cgo["GeoIP binding<br/>[geoip_cgo.go]"]
node_records["Record model and conversion<br/>[geoip.go]"]
node_nocgo["No-cgo stubs<br/>[geoip_nocgo.go]"]
node_native["GeoIP C library"]

node_cgo -->|"calls"| node_native
node_cgo -->|"converts city text"| node_records

click node_cgo "https://github.com/jdevilliers/geoip/blob/master/geoip_cgo.go"
click node_records "https://github.com/jdevilliers/geoip/blob/master/geoip.go"
click node_nocgo "https://github.com/jdevilliers/geoip/blob/master/geoip_nocgo.go"

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_caller,node_records,node_native toneIndigo
class node_cgo,node_nocgo toneTeal
```

## Components

### Other components

- **Go caller**
- [GeoIP binding](https://github.com/jdevilliers/geoip/blob/master/geoip_cgo.go): `geoip_cgo.go`
- [Record model and conversion](https://github.com/jdevilliers/geoip/blob/master/geoip.go): `geoip.go`
- [No-cgo stubs](https://github.com/jdevilliers/geoip/blob/master/geoip_nocgo.go): `geoip_nocgo.go`
- **GeoIP C library**

## Connections

- GeoIP binding → GeoIP C library: calls (evidence: `geoip_cgo.go`)
- GeoIP binding → Record model and conversion: converts city text (evidence: `geoip_cgo.go`)
