firecommerce-enterprise
v1.0.0
Published
Enterprise-grade headless e-commerce backend with Shopify-level features, multi-tenant architecture, and React integration
Maintainers
Readme
FireCommerce Enterprise
🔥 Enterprise-grade headless e-commerce backend with Shopify-level features, multi-tenant architecture, and React integration.
Features
🏢 Enterprise Core
- ✅ Multi-tenant architecture with complete data isolation
- ✅ RBAC system with 5 role levels and granular permissions
- ✅ Enterprise authentication with JWT, refresh tokens, and MFA
- ✅ Security hardening with rate limiting and audit logging
- ✅ API gateway with versioning and monitoring
🛒 E-commerce Features
- ✅ Product management with variants, categories, and bulk operations
- ✅ Order management with full workflow automation
- ✅ Inventory management with low-stock alerts and forecasting
- ✅ Customer management with profiles and segmentation
- ✅ Payment processing with multiple gateways (Stripe, Razorpay, PayPal, PhonePe)
📊 Analytics & Intelligence
- ✅ Admin dashboard with real-time metrics and KPIs
- ✅ Advanced analytics with cohort and funnel analysis
- ✅ AI recommendations with ML-powered personalization
- ✅ Dynamic pricing with competitive analysis
- ✅ Fraud detection with ML-based risk scoring
🚀 Advanced Features
- ✅ Marketing automation with email/SMS campaigns
- ✅ Abandoned cart recovery with automated workflows
- ✅ Subscription billing with recurring payment management
- ✅ Multi-currency support with real-time conversion
- ✅ Tax calculations with India + international support
- ✅ Shipping management with multiple carriers
- ✅ Return management with automated workflows
- ✅ Loyalty program with points and rewards
🔧 Database Support
- ✅ MongoDB - High-performance document database
- ✅ Firebase Firestore - Google's NoSQL cloud database
- ✅ Seamless switching between database providers
⚛️ React Integration
- ✅ Ready-to-use hooks for all e-commerce operations
- ✅ Pre-built components for admin dashboard and storefront
- ✅ TypeScript support with full type safety
- ✅ Context providers for state management
Quick Start
Installation
```bash npm install firecommerce-enterprise
or
yarn add firecommerce-enterprise ```
Basic Setup
```typescript import { initializeFireCommerce, createDefaultConfig } from 'firecommerce-enterprise';
// Initialize with default configuration const config = { ...createDefaultConfig(), database: { provider: 'mongodb', connection_string: 'mongodb://localhost:27017/mystore' }, auth: { jwt_secret: 'your-super-secret-key', jwt_expiry: '15m', refresh_token_expiry: '7d', mfa_enabled: true, password_requirements: { min_length: 8, require_uppercase: true, require_lowercase: true, require_numbers: true, require_symbols: true, } }, payments: { gateways: { stripe: { publishable_key: 'pk_test_...', secret_key: 'sk_test_...', webhook_secret: 'whsec_...' }, razorpay: { key_id: 'rzp_test_...', key_secret: 'your_secret' } } } };
// Initialize FireCommerce const firecommerce = initializeFireCommerce(config); await firecommerce.initialize(); ```
React Integration
```tsx import React from 'react'; import { FireCommerceProvider, useFireCommerce, AdminDashboard } from 'firecommerce-enterprise/react';
function App() { return ( ); }
function MyEcommerceApp() { const { user, isAuthenticated, login, logout } = useFireCommerce();
if (!isAuthenticated) { return ; }
return ( Welcome, {user?.first_name}! <AdminDashboard tenantId={user.tenant_id} storeId="your-store-id" modules={['analytics', 'orders', 'products', 'customers']} /> Logout ); } ```
Core Concepts
Multi-Tenancy
FireCommerce is built from the ground up as a multi-tenant system:
```typescript // Create a tenant const tenant = await firecommerce.multiTenant.createTenant({ name: 'My Business', domain: 'mybusiness.com', plan: 'enterprise', settings: { currency: 'USD', timezone: 'America/New_York', features: ['ai_recommendations', 'fraud_detection'] } });
// Create stores within the tenant const store = await firecommerce.database.create('stores', { tenant_id: tenant.id, name: 'Main Store', currency: 'USD', payment_gateways: ['stripe', 'razorpay'] }); ```
Authentication & Security
```typescript // Register a user with MFA const authResult = await firecommerce.auth.register({ tenant_id: tenant.id, email: '[email protected]', password: 'SecurePassword123!', first_name: 'John', last_name: 'Doe', role: UserRole.TENANT_ADMIN });
// Setup MFA const mfaSetup = await firecommerce.auth.setupMFA(authResult.user.id); console.log('MFA QR Code:', mfaSetup.qr_code);
// Login with MFA const loginResult = await firecommerce.auth.login({ email: '[email protected]', password: 'SecurePassword123!', tenant_id: tenant.id, mfa_code: '123456' }); ```
Product Management
```typescript // Create a product with variants const product = await firecommerce.database.create('products', { store_id: store.id, title: 'Premium T-Shirt', description: 'High-quality cotton t-shirt', variants: [ { title: 'Small / Red', sku: 'TSHIRT-SM-RED', price: 29.99, inventory_quantity: 100, option1: 'Small', option2: 'Red' }, { title: 'Medium / Blue', sku: 'TSHIRT-MD-BLUE', price: 29.99, inventory_quantity: 150, option1: 'Medium', option2: 'Blue' } ], options: [ { name: 'Size', values: ['Small', 'Medium', 'Large'] }, { name: 'Color', values: ['Red', 'Blue', 'Green'] } ] }); ```
Order Processing
```typescript // Create an order const order = await firecommerce.database.create('orders', { store_id: store.id, customer_id: customer.id, line_items: [ { product_id: product.id, variant_id: product.variants[0].id, title: product.title, quantity: 2, price: 29.99, total: 59.98 } ], shipping_address: { first_name: 'Jane', last_name: 'Smith', address1: '123 Main St', city: 'New York', country: 'United States', zip: '10001' }, subtotal_price: 59.98, total_price: 65.98 });
// Process payment const transaction = await firecommerce.payments.processPayment({ order_id: order.id, amount: order.total_price, currency: 'USD', payment_method: 'credit_card', gateway: 'stripe' }); ```
Analytics & Insights
```typescript // Get dashboard metrics const metrics = await firecommerce.analytics.getDashboardMetrics(store.id, { start: new Date('2024-01-01'), end: new Date('2024-12-31') });
console.log('Revenue:', metrics.overview.total_revenue); console.log('Orders:', metrics.overview.total_orders); console.log('Growth:', metrics.trends.revenue_growth);
// Generate AI insights const insights = await firecommerce.analytics.generateInsights(store.id); console.log('Recommendations:', insights.recommendations); ```
API Reference
Core Classes
- FireCommerce - Main class that orchestrates all modules
- DatabaseManager - Handles database operations with MongoDB/Firebase
- AuthManager - Authentication, JWT, MFA, and session management
- SecurityManager - Rate limiting, audit logging, and encryption
- MultiTenantManager - Tenant management and data isolation
- PaymentManager - Multi-gateway payment processing
- AnalyticsManager - Event tracking and business intelligence
- AutomationManager - Workflow automation and AI features
React Hooks
- useFireCommerce() - Main hook for accessing FireCommerce context
- useAuth() - Authentication state and methods
- useProducts() - Product management operations
- useOrders() - Order management operations
- useCustomers() - Customer management operations
- useAnalytics() - Analytics data and insights
Components
- AdminDashboard - Complete admin panel with metrics and management
- ProductCatalog - Product browsing and search interface
- ShoppingCart - Shopping cart with real-time updates
- CheckoutForm - Multi-step checkout with payment processing
Database Schemas
FireCommerce uses flexible, document-based schemas that work with both MongoDB and Firebase:
Core Collections
- tenants - Multi-tenant configuration and settings
- users - User accounts with RBAC and MFA support
- stores - Store configuration and settings
- products - Product catalog with variants and options
- orders - Order management with full workflow
- customers - Customer profiles and segmentation
- inventory_levels - Real-time inventory tracking
- transactions - Payment processing records
- analytics_events - Event tracking for business intelligence
- workflows - Automation and workflow definitions
Security Features
Authentication
- JWT access tokens (15 min expiry)
- Refresh tokens (7 day expiry)
- Multi-factor authentication (TOTP)
- Session management with automatic cleanup
- Password requirements with complexity rules
Authorization
- Role-based access control (RBAC) with 5 levels
- Granular permissions for resources and actions
- Multi-tenant data isolation
- API key management with scoping
Security Hardening
- Rate limiting per endpoint and user
- Audit logging for all actions
- Data encryption at rest and in transit
- IP whitelisting support
- DDoS protection
Payment Gateways
Supported Gateways
- Stripe - Credit cards, digital wallets, bank transfers
- Razorpay - Popular in India, supports UPI, net banking
- PayPal - Global payment solution
- PhonePe - Indian digital payment platform
Features
- Automatic gateway selection based on customer location
- Fraud detection with ML scoring
- Subscription billing with recurring payments
- Multi-currency support with real-time conversion
- Refund management with automated workflows
Deployment
Production Setup
```typescript import { initializeFireCommerce } from 'firecommerce-enterprise';
const productionConfig = { database: { provider: 'mongodb', connection_string: process.env.MONGODB_URI, options: { retryWrites: true, maxPoolSize: 100 } }, auth: { jwt_secret: process.env.JWT_SECRET, jwt_expiry: '15m', refresh_token_expiry: '7d', mfa_enabled: true, }, payments: { gateways: { stripe: { secret_key: process.env.STRIPE_SECRET_KEY, webhook_secret: process.env.STRIPE_WEBHOOK_SECRET }, razorpay: { key_secret: process.env.RAZORPAY_KEY_SECRET } } }, storage: { provider: 'firebase', bucket: process.env.FIREBASE_STORAGE_BUCKET }, email: { provider: 'sendgrid', api_key: process.env.SENDGRID_API_KEY } };
const firecommerce = initializeFireCommerce(productionConfig); await firecommerce.initialize(); ```
Environment Variables
```env
Database
MONGODB_URI=mongodb://localhost:27017/firecommerce JWT_SECRET=your-super-secret-jwt-key
Payment Gateways
STRIPE_SECRET_KEY=sk_live_... STRIPE_WEBHOOK_SECRET=whsec_... RAZORPAY_KEY_SECRET=your_razorpay_secret
Storage & Email
FIREBASE_STORAGE_BUCKET=your-project.appspot.com SENDGRID_API_KEY=SG.your_api_key ```
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
License
MIT License - see LICENSE file for details.
Support
- 📧 Email: [email protected]
- 💬 Discord: FireCommerce Community
- 📖 Documentation: docs.firecommerce.dev
- 🐛 Issues: GitHub Issues
Built with ❤️ by the FireCommerce team. Making enterprise e-commerce accessible to everyone.
