Case Study · AI Automation & Commerce Engineering

Al-Raky — AI Commerce Operating System

An autonomous, AI-powered platform that runs an online cosmetics business end to end: from product onboarding to content, publishing, sales, and operations.

The owner takes a photo and sets a price. The system does everything else.
Business Process AutomationAI Integration Distributed Systemsn8nPostgreSQL WooCommercePrompt Engineering
case scorecard production
50+
automated workflows
1
manual step (photo + price)
1
client · Egypt · cosmetics retail
< 1¢
media cost per product

01Executive Summary

Al-Raky is a fully automated, AI-powered commerce operating system built for a cosmetics retailer. It turns the entire business into an autonomous digital operation: product onboarding, market research, content generation, image and video production, publishing, customer service, order management, and operational data sync all run automatically.

The owner performs a single manual task — photograph a product, enter cost and selling price, and submit a Google Form. From that point on, the platform takes over. The multi-tenant foundation underneath it — per-client configuration and keys — later carried into a separate project for a home-appliances retailer in Mauritania, built around a different problem entirely: SalamaSons, an ad-intelligence and recommendation loop.

02The Business Problem

In the Egyptian cash-on-delivery cosmetics market, a single operator must perform 15–20 manual steps per product: research, analysis, pricing, ad copy, image design, video editing, publishing, customer replies, and shipping follow-up. This manual ceiling caps how many products can be tested each month — and in a market that runs on volume-testing, that ceiling is the profit ceiling.

The objective was never to build a website. It was to remove the human from every step that doesn't need human judgment.

03Design Philosophy

Every workflow was redesigned automation-first. Instead of asking “How can employees do this faster?”, the system asks “Why should humans do this at all?” Humans keep only the decisions that need judgment — approve a product, review content, confirm a price — while the operator's role shifts from executor to reviewer. The number of products tested becomes a function of budget, not working hours.

04My Role

I designed, engineered, deployed, and currently maintain the entire platform independently. Responsibilities spanned:

Strategy & Analysis

Business analysis, business-process engineering, system & automation architecture.

AI & Data

AI architecture, prompt engineering, content pipelines, database design.

Engineering

Backend & Node.js services, WordPress/WooCommerce, integrations, infrastructure.

Operations

Deployment, monitoring, maintenance, and continuous improvement.

05Architecture

A distributed, pull-model architecture. A central PostgreSQL database holds each product's state; a Dispatcher reads states on a schedule and triggers the right stage for each product; stateless Node.js microservices handle heavy work (scraping, image and video processing) outside the automation engine; and a unified AI Gateway abstracts three providers behind one contract with automatic fallback.

Google Form
photo · cost · price
Pipeline Dispatcher
state engine · reads PostgreSQL
Pricing Engine
deterministic code
Unified AI Gateway
OpenAI · Gemini · OpenRouter + fallback
Media Service
Node.js · rembg · sharp · ffmpeg
WooCommerce Store
Facebook / Instagram
Messenger & WhatsApp
AI sales agent
Central PostgreSQL holds all state · a central Alerter pushes any failure to Telegram
N8N CANVAS SLOT
production workflow canvas
(blur credentials & keys)assets/commerce-os-n8n-canvas.png

06End-to-End Product Lifecycle

One Google Form submission triggers this entire chain, with no further human input.

Intake

The owner submits a Google Form: product images, cost price, selling price, category, and basic info.

Product Analysis

AI extracts type, features, materials, colors, target audience, benefits, objections, positioning, and use cases.

Market Research

AI studies trends, competitors, customer language, buying motivations, and pain points to build positioning.

Product Brain

A knowledge object is generated: USP, customer avatars, emotional/engagement/conversion hooks, objection handling, cross-sell ideas, sales talking points, and FAQs.

Image Generation

Commercial-quality lifestyle, studio, and campaign images are generated. The original phone photo is never used publicly.

Video Production

Promotional videos with scenario, storyboard, hooks, captions, voice-over script, and platform-specific versions.

Social Content

Facebook/Instagram posts, reels, captions, CTAs, hashtags, plus a monthly content plan and publishing schedule.

WooCommerce Listing

The product is created automatically: title, descriptions, specs, SEO, gallery, categories, pricing, attributes, tags, and metadata.

Publishing Queue

The product is slotted into the monthly social publishing calendar.

Sales-Agent Sync

The Messenger/WhatsApp AI agent's knowledge base updates instantly — every new product is sellable with no retraining.

RAW PHOTO
the owner’s phone shotassets/commerce-os-before.png
before — raw phone photo
GENERATED
campaign imageassets/commerce-os-after.png
after — AI-generated campaign image

07Key Engineering Decisions

Language vs. money, strictly separated

AI owns language, description, and visual analysis only. Anything touching money or state — pricing, order totals, stage transitions — runs in deterministic code, removing a whole class of unpredictable errors from the financial path.

Control by configuration

Dozens of database settings drive behaviour: which AI provider and model, how many posts, which video templates, brand colors, margin tiers, shipping rates, publishing on/off. Changing behaviour edits a cell, not code.

Exit-checks at every stage

Each workflow ends by re-reading the database to verify what should have been written actually was. Nothing counts as success until it is proven — turning silent failures into immediate, visible ones.

Structural locks over discipline

An asset cannot be marked “ready” while its file link is empty; the rule is enforced at one un-bypassable point, so it is structurally impossible to publish a post without an image.

08AI & Prompt Engineering

A unified AI Gateway sits over three providers (OpenAI, Google Gemini, OpenRouter) behind a single call contract, with an automatic fallback chain on failure or quota limits and per-call cost logging. Prompt pipelines generate the Product Brain, marketing copy with multiple selling angles, video scripts, image prompts, and the sales agent's knowledge — each passing through a validation layer that enforces content rules before anything is stored or published.

09Data & Database

A central PostgreSQL database is the single source of truth: products, orders, customers, content, knowledge base, automation logs, and operational/reporting data — with indexes, JSONB fields, views, and triggers. Migrating off cloud spreadsheets removed the throughput ceiling that appeared under load: query time became a function of active work, not archive size.

10Technical Stack

Automation & Orchestration
n8n (self-hosted, Docker) Webhooks
Data
PostgreSQL Google Sheets Google Forms/Drive
Backend & Media
Node.js / Express Puppeteer sharp rembg ffmpeg
AI
OpenAI Google Gemini OpenRouter Prompt Engineering
Storefront
WordPress WooCommerce Elementor Pro Astra Pro
Channels & Infra
Meta Graph API WhatsApp API Telegram Cloudflare Tunnel REST APIs

11Results & Impact

Time per product: from hours of manual work to minutes of automated operation.
Output per product: multiple posts, several ad images in different roles, promotional videos, and a full sales-agent knowledge base.
Media cost: under one cent per typical product — image and video processing run locally at near-zero cost; only text calls carry a cost.
Scalability: the system's ceiling became the advertising budget, not operator hours.
Productization: multi-tenant from the ground up (per-client configuration and keys) — the foundation a second, different client project was later built on.
CHAT SLOT
Messenger sales-agent conversation
(blur customer identity)assets/commerce-os-sales-agent-chat.png

12Skills Demonstrated

Distributed systems designWorkflow engineering Database design & optimizationMicroservices AI integrationPrompt engineering Media-processing automationWeb scraping API designData migration Secrets & operational securityBusiness-logic modeling