Loading repository data…
Loading repository data…
jainanushk8 / repository
SwarmPIM is a production-grade, containerized PIM system engineered with Next.js 14 and FastAPI. It orchestrates a multi-agent AI swarm utilizing Gemini and Grok with dynamic fallback routing. The architecture features an embedded Qdrant vector cache, high-speed Polars batch ingestion, and analytical DuckDB storage optimized via Apache Arrow.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A containerized, microservice-based Product Information Management (PIM) system designed to ingest unorganized catalog data, process it via an asynchronous multi-agent AI swarm, and store structured attributes for high-performance analytical querying.
The system is split into two isolated service tiers orchestrated via standard container networking:
A decoupled client interface built on the React App Router, using headless UI primitives for administrative catalog management.
An asynchronous Python service that handles ingestion pipelines, vector caching, LLM orchestration, and analytical storage operations.
[Messy Ingestion Source]
│
▼
[Qdrant Vector Cache] ───(Hit: Return Attributes)───► [Client Dashboard]
│
(Miss: Cache Fault)
│
▼
[AI Swarm Orchestrator] ───► [Drafter Agent] ───► [Validator Agent] ───► [Structured Output]
│
[Client Dashboard] ◄───(Polars / Apache Arrow) ◄─── [DuckDB Storage] ◄──────────┘
Ingested strings are vectorized and checked against an embedded Qdrant database. If a matching signature exists within defined similarity thresholds, the system skips downstream LLM processing entirely to eliminate API latency and operational costs.
Cache misses route to a multi-agent state machine. A Drafter Agent extracts and structures raw properties, passing the payload to a Validator Agent that verifies structural schemas, schema constraints, and data integrity.
The agents utilize a dynamic client configuration with fallback routing. If primary providers (e.g., Gemini) hit rate limits or return exhaustion errors, the execution context falls back to secondary pipelines (e.g., Grok/OpenAI-compatible endpoints).
Validated attributes are written to DuckDB. Read operations utilize Polars to load data via the Apache Arrow format. This provides zero-copy memory transport, enabling fast analytical aggregations on the frontend UI without blocking the FastAPI event loop.
swarm-pim/
├── backend/
│ ├── app/
│ │ ├── __init__.py
│ │ ├── agents.py # Multi-agent logic and LLM tools
│ │ ├── cache.py # Qdrant semantic memory layer
│ │ ├── config.py # Environment variable resolution
│ │ ├── database.py # DuckDB connection and Arrow initialization
│ │ ├── main.py # REST endpoints and routing
│ │ └── schemas.py # Pydantic validation frames
│ ├── Containerfile # Multi-stage Python build instructions
│ └── requirements.txt # Frozen backend dependencies
├── frontend/
│ ├── app/ # Next.js pages and routing state
│ ├── package.json # Node dependency manifest
│ └── Containerfile # Multi-stage Node/Next production build
├── data/ # Persistent host volume mount mapping
│ ├── data.duckdb # Persistent storage target
│ └── qdrant_storage/ # Persistent vector indices
└── podman-compose.yaml # Service definitions and environment bindings
The system requires specific environment configurations for execution.
Create an .env file inside the backend/ directory using the structure defined below:
# API Gateway Keys
GEMINI_API_KEY=your_production_gemini_credential
GROQ_API_KEY=your_production_grok_credential
# Engine Runtime Flags
DATABASE_PATH=/app/data/data.duckdb
QDRANT_HOST=embedded
Ensure your host machine has the Podman Engine and the Podman-Compose toolchain installed.
If running on Windows, verify that:
.vhdx virtual machine filesTo execute a full multi-stage compilation and initialization of the service mesh, navigate to the root directory and run:
podman compose -f podman-compose.yaml up --build -d
Note: The
--buildflag is strictly required when dependencies are modified inrequirements.txtorpackage.jsonto overwrite cached filesystem layers.
To view unified application logs across the gateway and frontend clusters in real-time:
podman compose -f podman-compose.yaml logs -f
To pause execution without wiping container contexts:
podman compose -f podman-compose.yaml stop
To dismantle the local network bridge and terminate the container processes while leaving physical database state intact on the host storage volume:
podman compose -f podman-compose.yaml down
To access the internal runtime shell of the running backend container for live debugging or file structure verification:
podman exec -it swarmpim-backend ls -la /app/data
Once successfully booted, the services are bound to the host network interface:
| Service | URL |
|---|---|
| Web Dashboard Interface | http://localhost:3000 |
| Interactive Swagger Documentation | http://localhost:8000/docs |
This section provides a granular, production-level breakdown of the system mechanics for developers analyzing the engineering decisions behind the SwarmPIM repository.
When dealing with data transfers between storage engines and web runtimes, the conventional approach involves pulling data into a backend model, serializing it into standard JSON strings, and transmitting it over network sockets. In high-throughput environments, this incurs heavy CPU costs due to memory copying and string processing overhead.
SwarmPIM mitigates this via an analytical pipeline using DuckDB and Polars.
DuckDB natively supports export data operations in the Apache Arrow format. Apache Arrow defines a language-independent column-oriented memory layout.
When the Next.js client requests data from /api/v1/catalog, FastAPI invokes DuckDB's internal execution engine to fetch the structured rows.
Instead of converting rows into native Python dicts, the query returns an Arrow record batch stream.
Polars initializes a DataFrame directly on top of these Arrow memory pointers using pyarrow.
Because both utilities share an identical specifications layer for column data, the memory allocation is reused without duplication.
This pipeline reduces memory pressure and serialization bottlenecks.
It enables fast database querying and transmission speeds even when handling large batch sizes of deeply structured schema properties.
The multi-agent system does not rely on complex, unconstrained chain-of-thought prompts.
It follows a modular design with clear validation separation.
[Incoming Catalog Payload]
│
▼
┌───────────────────────┐
│ Drafter Agent │ ◄─── Validates structural extraction types
└───────────┬───────────┘
│
▼
┌───────────────────────┐
│ Validator Agent │ ◄─── Executes schema checks & constraints
└───────────┬───────────┘
│
┌───────┴───────┐
▼ ▼
[Passed] [Failed]
│ │
▼ ▼
[Save State] [Feedback Loop to Drafter]
The Drafter Agent receives an unorganized string payload.
It parses raw specifications, standardizes text attributes, resolves missing categories, and matches product values into structured data fields.
It outputs strict types enforced by Python validation schemas.
The Validator Agent reviews the output from the Drafter.
It runs programmatic checks against configuration parameters, validates mathematical boundaries (e.g., pricing or dimensions), and confirms that critical attributes are accurate.
If the validator identifies data gaps or contradictions, it creates an accurate error log and routes the data back to the Drafter in an automated loop.
To prevent system crashes during upstream service interruptions, the provider client implements a layered execution loop.
| Fallback Level | Service Provider | Model Context | Purpose |
|---|---|---|---|
| Primary | Google Vertex / Gemini API | Flash / Pro | High concurrency, long context optimization, schema formatting |
| Secondary (Failover) | Groq / OpenAI Compatible | Llama-3-Powered | Low latency, high throughput fallback execution during API exhaustion |
To minimize unnecessary LLM calls, every raw data string undergoes semantic preprocessing before hitting the agent pipelines.
Raw input fields are converted into vector representations using a local embedding algorithm.
The embedding is sent to an embedded instance of Qdrant.
The vector database runs distance calculations against existing indices using cosine similarity parameters.
If a vector signature falls within the matching threshold, it indicates an identical or nearly identical duplicate request.
The cache retrieves the structured results directly from the stored database index, resolving the request in milliseconds.
If the distance vector exceeds thresholds, a cache miss is logged.
The system forwards the payload to the AI swarm, and caches the final validated schema back into Qdrant for subsequent hits.
When configuring container topologies for applications deployed on Windows via WSL2, understanding the separation between execution memory and persistent storage is critical.
Containers are designed to be ephemeral.
If a container instance is dropped, modified, or destroyed via a down operation, any stateful changes made inside its isolated filesystem layers are instantly lost.
To guarantee database persistence across builds, SwarmPIM establishes explicit boundaries using host-mounted volumes.
volumes:
- ./data:/app/data:z
The
:zflag ensures safe shared SELinux labeling permissions when mounted across varying host file formats.
When running:
podman compose stop
container instances are paused, dropping active CPU use to 0% while retaining container cache tables.
A down command safely deletes the container instances entirely.
Even when containers are completely purged via down, the parent Linux instance (podman machine) remains active in system memory, holdi