How rekryt/iplist works
Project Type and Purpose
• This is a full-stack monorepo that combines:
• A backend asynchronous PHP web service (AMPHP + Linux CLI tools) for collecting/updating IP addresses and CIDR zones, exposing a REST-style “format” API.
• A static frontend (Nuxt.js + Vuetify) that builds a documentation/UI site.
• Purpose: load JSON configurations of domains, fetch & compute IP/CIDR lists via DNS/whois/ipcalc tasks, cache results to disk, and serve them in multiple text/JSON/script formats.
File Structure Analysis
• Top-level:
• Docker integration (.docker/, Dockerfile, docker-compose.yml, .env)
• Backend entrypoint (index.php), composer.json, config/… JSON domain configs, storage/… JSON cache files.
• frontend/ – a standalone Nuxt.js project (package.json, nuxt.config.ts, pages/, components/, stores/, public/_nuxt build).
• public/ – built static assets (generated by frontend build).
• src/ – backend source following a layered (“hexagonal”) architecture:
– App layer (Controllers, Services, Templates)
– Domain layer (Entity, Factory, Helper)
– Infrastructure layer (API server & handlers, Storage adapters, Task runners)
• Patterns:
• Hexagonal/Ports & Adapters (Infrastructure API & Storage adapters)
• Layered MVC‐style for HTTP controllers → services → domain → storage
• Docker Compose for orchestration
Key Architecture Insights from README
• Asynchronous PHP HTTP server powered by AMPHP and “index.php” as the entrypoint.
• Uses Linux tools (whois, ipcalc) via ShellTask adapter.
• Config JSON files (config/<group>/<portal>.json) drive domain lists, DNS servers, external URLs.
• Outputs in multiple formats via dedicated Controller classes (e.g., Mikrotik, ipset, comma).
• Configurable via environment (.env) and Docker Compose.
a. Main Components
• Client/browser – accesses the static frontend or calls the API endpoints directly.
• Frontend layer – Nuxt.js static site (built assets served from public/_nuxt or a CDN).
• Reverse proxy (optional NginxProxyManager) – routes HTTP 80/443 to backend container.
• Backend container – PHP 8.1+ AMPHP HTTP server (index.php → Infrastructure/API/Server).
• Router & Request Handlers – HTTPErrorHandler, HTTPHandler dispatch to App\Controllers.
• Controller layer – one Controller per format (e.g., JsonController, MikrotikController) implementing ControllerInterface.
• Service layer – IPListService orchestrates data gathering, applies Domain logic.
• Domain layer – Entities (Site), Factories (SiteFactory), Helpers (DNSHelper, IP4Helper, IP6Helper).
• Infrastructure Adapters:
– Task runner (ShellTask) for whois/ipcalc/dnsutils calls
– Storage adapters (CIDRStorage, IconsStorage) reading/writing storage/*.json
• Config loader – reads config/*.json into Domain factories
• External systems – Public DNS servers, external data URLs, Linux CLI tools
• Persistent volume – storage/ directory mounted in container
b. Relationships & Data Flow
1. Client → (optional) Reverse Proxy → Backend HTTP server
2. HTTP server → Request Handlers → Controller
3. Controller → IPListService →
• Config loader → Domain Factory → creates Site entity
• Domain Helpers → fetch DNS records via ShellTask → whois/ipcalc
• Storage adapters → read/write JSON cache
4. Service → collated data → chosen Controller → Template → HTTP response
5. Client receives formatted IP/CIDR list or static docs (frontend)
c. Architectural Patterns
• Hexagonal (“ports & adapters”) separating core domain logic from I/O (HTTP, CLI tasks, file storage)
• Layered approach: Infrastructure → Application → Domain → Infrastructure
• Single‐responsibility Controllers per output format
• Docker Compose microservices style (frontend build vs. backend service)
d. Key Technologies & Libraries
• PHP 8.1+, AMPHP (async HTTP server)
• Composer packages
• Linux utilities: whois, dnsutils, ipcalc
• JSON config & cache storage
• Nuxt.js + Vuetify (frontend)
• Docker, Docker Compose (.env, networks, volumes)