E-Commerce Operations Hub with Smart Automation Rules Engine
π Live Demo β’ Features β’ Tech Stack β’ Getting Started β’ Architecture
ShopFlow is a full-stack e-commerce admin dashboard that goes beyond basic CRUD. It features a visual automation rules engine that lets store owners create IF/THEN rules to automate operations β like flagging high-value orders, auto-tagging VIP customers, applying discounts, and sending notifications.
Demo Credentials:
admin@shopflow.com/admin123
Real-time overview with revenue charts, order status distribution, key metrics, recent orders, and an activity feed β all powered by server-side Prisma aggregations.
Full CRUD with image previews, category management, SKU tracking, stock alerts (highlighted in red when low), status management (Active/Draft/Archived), search, and CSV export.
Complete order pipeline with status progression (Pending β Processing β Shipped β Delivered), one-click status updates, order creation dialog with live total calculation, and CSV export.
Customer profiles with expandable inline order history, total spend tracking, tag system (Regular/VIP/Wholesale/Flagged), and CSV export.
The standout feature β a visual rule builder with:
- 5 Trigger Types: Order Placed, Status Changed, Low Stock, High Value Order, Repeat Customer
- Nested AND/OR Conditions: Build complex condition trees with multiple groups
- 5 Action Types: Send Email, Tag Customer, Flag Order, Update Status, Apply Discount
- One-Click Templates: Pre-built rules for common scenarios
- Rule Execution Engine: Evaluates rules against live data in real-time
- Full Audit Log: Every execution logged with trigger data, actions performed, timestamps, and success/failure status
- Test Mode: Manually test rules against the latest order data
Full dark/light theme toggle with smooth transitions across all components.
Mobile-friendly with a collapsible sidebar and hamburger menu.
Email/password registration + Google OAuth with session management via Auth.js v5 (JWT strategy).
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FRONTEND β
β Next.js 16 (App Router) β’ TypeScript β’ Tailwind β’ shadcn/ui β
β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β βDashboard β βProducts β β Orders β βCustomers β β
β βAnalytics β β CRUD β βPipeline β β History β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Automation Rules Visual Builder β β
β β Triggers β Conditions (AND/OR) β Actions β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β API LAYER β
β Next.js API Routes (RESTful) β
β /products β’ /orders β’ /customers β’ /categories β
β /rules β’ /rules/[id]/execute β’ /rules/[id]/logs β’ /export β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β RULE EXECUTION ENGINE β
β βββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Condition βββββΆβ Action βββββΆβ Audit Log β β
β β Evaluator β β Executor β β (RuleLog) β β
β β (AND/OR tree) β β (DB + Email) β β β β
β βββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β DATABASE β
β PostgreSQL (Neon) + Prisma 7 ORM β
β 8 Tables: User, Product, Category, Order, OrderItem, β
β Customer, Rule, RuleLog β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Category | Technology |
|---|---|
| Framework | Next.js 16 (App Router, Server Components) |
| Language | TypeScript (end-to-end type safety) |
| Database | PostgreSQL via Neon (serverless) |
| ORM | Prisma 7 with Neon adapter |
| Authentication | Auth.js v5 (Credentials + Google OAuth) |
| UI Components | shadcn/ui + Tailwind CSS v4 |
| Charts | Recharts (Bar, Pie, Responsive) |
| Rule Engine | Custom-built JSON condition tree evaluator |
| Resend (with simulation fallback) | |
| Deployment | Vercel (frontend) + Neon (database) |
| Containerization | Docker + Docker Compose |
- Node.js 18+
- PostgreSQL database (Neon free tier recommended)
# Clone the repository
git clone https://github.com/srujankothuri/shopflow.git
cd shopflow
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your credentials
# Generate Prisma client and push schema
npx prisma generate
npx prisma db push
# Seed with demo data (22 products, 15 customers, 96 orders, 4 rules)
npx prisma db seed
# Start development server
npm run devDATABASE_URL="postgresql://..." # Neon connection string
AUTH_SECRET="..." # Generate with: npx auth secret
AUTH_URL="http://localhost:3000" # Your app URL
AUTH_GOOGLE_ID="" # Google OAuth (optional)
AUTH_GOOGLE_SECRET="" # Google OAuth (optional)
RESEND_API_KEY="" # For email actions (optional)docker-compose upsrc/
βββ app/
β βββ (auth)/ # Auth pages (no sidebar layout)
β β βββ login/
β β βββ register/
β βββ (dashboard)/ # Dashboard layout (with sidebar)
β β βββ dashboard/
β β βββ products/ # Products CRUD page
β β βββ orders/ # Orders management page
β β βββ customers/ # Customers page with history
β β βββ rules/ # Automation rules page
β β βββ settings/ # Settings page
β βββ api/ # REST API endpoints
β βββ products/[id]/
β βββ orders/[id]/
β βββ customers/[id]/
β βββ categories/
β βββ rules/[id]/
β β βββ execute/ # Manual rule testing
β β βββ logs/ # Rule execution logs
β βββ export/ # CSV export endpoint
β βββ register/
βββ components/
β βββ dashboard/ # Stats cards, charts, activity feed
β βββ products/ # Product dialog
β βββ orders/ # Order creation dialog
β βββ customers/ # Customer dialog
β βββ rules/ # Rule builder, logs viewer, templates
β βββ layout/ # Sidebar, header
β βββ providers/ # Auth + theme providers
β βββ ui/ # shadcn/ui primitives
βββ lib/
βββ auth.ts # NextAuth configuration
βββ db.ts # Prisma client singleton
βββ dashboard.ts # Dashboard aggregation queries
βββ rule-engine.ts # Rule evaluation + execution engine
βββ email.ts # Resend email integration
βββ utils.ts # Utility functions
Event Occurs (e.g., Order Placed)
β
βΌ
βββββββββββββββββββββββ
β Fetch Active Rules β β Filter by trigger type, sort by priority
β for this Trigger β
βββββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β Evaluate Conditions β β AND/OR tree evaluation against event data
β (per rule) β
βββββββββββ¬ββββββββββββ
β
βββββββ΄ββββββ
β β
PASS FAIL
β β
βΌ βΌ
ββββββββββ ββββββββββ
βExecute β β Log β
βActions β βSKIPPED β
βββββ¬βββββ ββββββββββ
β
βΌ
βββββββββββββββββββββββ
β Log Execution β β Status, actions run, trigger data snapshot
β (Audit Trail) β
βββββββββββββββββββββββ
- User creates a rule via the 3-step visual wizard (trigger β conditions β actions)
- Rule is stored as JSON in PostgreSQL (conditions as nested AND/OR tree, actions as array)
- When an event occurs (e.g., order created via API), the engine fetches all active rules for that trigger
- Conditions are evaluated using a recursive tree evaluator supporting AND/OR logic across groups
- If conditions pass, actions execute sequentially (DB updates, customer tagging, email notifications)
- Every execution is logged with full context β trigger data snapshot, actions performed, timestamps, success/failure
| Decision | Rationale |
|---|---|
| JSON conditions over relational tables | Flexible nested AND/OR groups without complex self-referencing joins |
| JWT sessions over DB sessions | Faster auth checks, no extra database table needed |
| Server Components for dashboard | Stats computed server-side with Prisma aggregations β zero client-side data fetching on initial load |
| Event-driven rule execution | Rules fire on API events (order creation); easily extensible to webhooks and cron triggers |
| Audit trail for every execution | Production-grade observability β debug failed rules, track automation history |
| CSV export via API route | Stream large datasets without loading everything into browser memory |
| Simulation mode for emails | App works without Resend API key; emails log to console in dev |
# Fork the repo
# Create your feature branch
git checkout -b feature/amazing-feature
# Commit your changes
git commit -m "feat: add amazing feature"
# Push to the branch
git push origin feature/amazing-feature
# Open a Pull RequestVenkata Srujan Kothuri
- π GitHub: @srujankothuri
- πΌ LinkedIn: srujankothuri
- π§ Email: srujan019@gmail.com
This project is open source under the MIT License.
Built with β€οΈ using Next.js, Prisma, and TypeScript








