Magic PIM
Overview
Section titled “Overview”Magic PIM is the master product database for the entire ecosystem. Built on Medusa 2.0, it imports product data from multiple suppliers and syncs to tenant databases.
GitHub: midego1/Magic-PIM (private)
URL: https://pim.magicomniverse.online (admin panel at /app)
Backend port: 4002 | Deployed on: Coolify (new server, 159.195.68.41)
Old location: /mnt/data/magic_pim/ (old server, being decommissioned)
Architecture
Section titled “Architecture”Supplier Feeds ──► Connectors ──► magic_pim DB ──► Tenant DBs(CSV/Excel/JSON) (Parse) (Master) (Per-tenant aplt_products)Suppliers & Connectors
Section titled “Suppliers & Connectors”| Supplier | Code | APLT Variants | Medusa Products | Medusa Variants | Connector File(s) | Notes |
|---|---|---|---|---|---|---|
| Spranz | 01 | 760 | 492 | 698 | spranz.ts | Stock sync only |
| Moxz | 02 | 9 | 15 | 15 | - | Not automated |
| Langenberg | 03 | 244 | 245 | 257 | - | Not automated |
| XD Connect | 04 | 6,165 | 1,386 | 6,247 | xdconnect.ts, xdconnect-categories.ts | Products + prices + stock + print |
| PF Concept | 05 | 17,825 | 2,030 | 17,808 | pfconcept.ts, pfconcept-imagedata.ts | Products + stock + print |
| Midocean | 06 | 14,496 | 2,443 | 14,496 | midocean.ts | Products + stock |
| Toppoint | 07 | 5,856 | 1,842 | 5,856 | toppoint.ts | Products |
| NewWave Textiles | 09 | 26,239 | 959 | 26,239 | newwave.ts | 4 brands: Cutter & Buck, Clique, Craft, Jobman |
Connector Configuration
Section titled “Connector Configuration”interface ConnectorConfig { id: string // e.g., 'spranz_stock' name: string // Display name supplierCode: string // Supplier identifier type: 'products' | 'stock' | 'prices' | 'categories' feedUrl?: string // Remote feed URL feedFormat: 'csv' | 'excel' | 'json' | 'xml' frequency: string // Update schedule active: boolean}Sync Endpoints
Section titled “Sync Endpoints”| Method | Endpoint | Purpose |
|---|---|---|
| GET/POST | /admin/connectors | List/configure connectors |
| POST | /admin/connectors/sync | Trigger sync (supports force download) |
| POST | /admin/connectors/medusa-sync | Sync to Medusa native tables |
APLT → Medusa Sync
Section titled “APLT → Medusa Sync”The Medusa sync (/admin/connectors/medusa-sync) groups APLT rows into Medusa products:
- Grouping: Products are grouped by the
modelfield in APLT. All variants with the same model become one Medusa product with multiple variants (color/size). - Variant SKU: Each Medusa variant gets the
variant_codefrom APLT as its SKU. - Categories: Products are linked to Medusa categories via
master_category_codein APLT →product_category.handlein Medusa. - Barcode conflicts: If an EAN is already used by another supplier, the product is created without barcode.
- SKU conflicts: If a variant SKU already exists under a different supplier, the product is skipped.
Database Functions
Section titled “Database Functions”All connectors use upsertProduct() (singular) from database.ts:
- Lookup:
variant_code + supplier_code(unique per variant) - Fallback:
sku + supplier_codeif no variant_code
Deployment (Coolify)
Section titled “Deployment (Coolify)”PIM runs on the new Coolify server as a standalone Docker app.
| Detail | Value |
|---|---|
| Coolify App UUID | a5j3s2r6zqjter8ps2mpqf12 |
| Container port | 4002 |
| Database | magic_pim (189 tables, shared magic-postgres) |
| Redis | Shared instance (db index 1) |
| Build | Multi-stage Dockerfile from backend/ |
Deploy via API
Section titled “Deploy via API”curl -X POST -H 'Authorization: Bearer <API_TOKEN>' \ 'https://coolify.magicomniverse.online/api/v1/deploy?uuid=a5j3s2r6zqjter8ps2mpqf12'