How nemryz/identity-generator works
Purpose and Runtime
identity-generator is a Python 3.10+ command-line application for generating locale-consistent fictional identity profiles, optionally provisioning temporary email inboxes, persisting profiles locally, and exporting them. It runs synchronously as a single process; no server or database is required.
Core runtime dependencies include Faker for localized data, Requests for email-provider HTTP calls, Colorama for terminal output, and Pyperclip for clipboard export. Container execution is defined by Dockerfile.
CLI Orchestration
main.py is the executable entry point. It parses command-line modes—single or batch generation, history lookup, inbox reads, email usage reporting, locale listing, and exports—then coordinates generation, persistence, output, and optional delay.
applog.py initializes shared file/stderr logging. The CLI establishes UTF-8 output and is the boundary between user-facing terminal behavior and domain modules.
Paths: main.py, applog.py, Dockerfile.
Identity Generation
generator.py constructs the canonical identity dictionary. It selects or accepts a Faker locale, generates regional personal fields, derives age/country/usernames/nicknames, creates IDs and timestamps, and produces secure passwords. It also applies locale-aware document providers where Faker supports them and supplies plausible passport formats otherwise.
Generation consumes committed address data for supported locales to keep city, postcode, street naming, and address format internally consistent; other locales fall back to Faker.
Paths: generator.py, data/addresses/en_US.json, data/addresses/es_ES.json.
Address Dataset Boundary
The committed JSON files under data/addresses/ are runtime data assets, containing population-weighted cities, postcodes, street names, and attribution for eleven locales. They make address generation deterministic with respect to local data availability and avoid runtime geographic API calls.
tools/build_datasets.py is an offline maintenance pipeline, not normal application flow. It refreshes these assets from GeoNames and OpenStreetMap through public Overpass mirrors, with cached downloads and retry behavior.
Paths: data/addresses/, tools/build_datasets.py, data/addresses/pt_BR.json.
Email Provisioning and Inbox Reads
email_api.py enriches a generated identity with email address, provider, and optional inbox token. Provider selection is a resilience chain: configured custom catch-all domains, tempmail.lol, mail.tm, then an offline disposable-domain fallback. HTTP calls have bounded timeouts and usage counters prevent known provider limits from being exceeded.
Inbox reads use the persisted provider/token and therefore are separate from identity generation. Custom-domain addresses are deliverable but cannot be read through an API. External boundaries are public tempmail.lol and mail.tm APIs; no credentials are required.
Paths: email_api.py, domains.example.json.
Local Persistence and Concurrency
history.py owns local JSON persistence for generated profiles. The CLI appends one profile or a batch, retrieves recent entries, looks up profiles by UUID for inbox checks, and locates reusable inboxes. Writes use an exclusive lock and atomic replace to protect concurrent CLI processes and interrupted writes; corrupt files are backed up before recovery.
Email provider usage is also persisted locally by the email subsystem. These mutable runtime artifacts are intentionally gitignored.
Paths: history.py, email_api.py, .gitignore.
Output and Data Flow
Normal flow is: CLI arguments → generator.py → email_api.py (unless offline/reused as applicable) → history.py append → terminal rendering and optional export. Batch mode creates multiple profiles, commits them in one history operation, and exports CSV rows.
exporter.py is the final delivery boundary: per-identity JSON files, batch identities.csv without inbox tokens, or formatted clipboard text. Clipboard export depends on host desktop support and is unavailable in typical containers.
Paths: exporter.py, main.py, history.py.
Main entry points: main.py CLI orchestrator · email_api.py Email subsystem · generator.py Identity generator · build_datasets.py Dataset builder
Components 15
CLI Runtime
- CLI orchestrator · Parses modes and coordinates synchronous profile workflows.
main.py - Shared logging
applog.py - Container runtime
Dockerfile - Export delivery · Produces identity JSON, batch CSV without tokens, or clipboard text.
exporter.py - Terminal and clipboard
Identity Generation
- Identity generator · Builds canonical locale-consistent identity dictionaries.
generator.py - Faker providers · Supplies localized personal and document data.
- Address datasets · Locale city, postcode, street, and format data for deterministic supported addresses.
Email Provisioning
- Email subsystem · Provisions addresses, tracks provider usage, and reads token-backed inboxes.
email_api.py - Custom domains
domains.example.json - Temporary mail APIs · tempmail.lol and mail.tm are tried after custom catch-all domains.
Local Data
- History persistence · Atomically appends, retrieves, and recovers local profile history.
history.py - Mutable local artifacts · Profile history and provider usage counters persist outside version control.
.gitignore
Offline Maintenance
- Dataset builder · Refreshes address assets with cached, retried public-source downloads.
tools/build_datasets.py - GeoNames and Overpass
Connections 16
- CLI orchestrator → Shared logging: initializes
- CLI orchestrator → Identity generator: generates profiles
- Identity generator → Faker providers: localized fields
- Identity generator → Address datasets: supported locale addresses
- CLI orchestrator → Email subsystem: optional provision or inbox read
- Email subsystem → Custom domains: loads catch-all domains
- Email subsystem → Temporary mail APIs: provisions and reads inboxes
- Email subsystem → Mutable local artifacts: persists usage counters
- CLI orchestrator → History persistence: append, lookup, reuse
- History persistence → Mutable local artifacts: atomic locked persistence
- CLI orchestrator → Export delivery: exports generated or retrieved profiles
- CLI orchestrator → Terminal and clipboard: renders results
- Export delivery → Terminal and clipboard: clipboard and formatted output
- Dataset builder → GeoNames and Overpass: downloads source data
- Dataset builder → Address datasets: refreshes
- Container runtime → CLI orchestrator: runs