Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
303 commits
Select commit Hold shift + click to select a range
814e82f
Create Add Content Brain Modules
RoyalMix Jan 7, 2026
f27b799
Create docAI_Automated_Posting_System
RoyalMix Jan 7, 2026
18115ea
Create Add Scheduler System
RoyalMix Jan 7, 2026
2486be1
Create Add Platform API Integration
RoyalMix Jan 7, 2026
81b2145
Create Add Learning Engine
RoyalMix Jan 7, 2026
f20605c
Create Add Documentation
RoyalMix Jan 7, 2026
c79068a
Create └── event_trigger_engine.md
RoyalMix Jan 7, 2026
1701fc7
Create on_new_content.js
RoyalMix Jan 7, 2026
16f9079
Create on_schedule_tick.js
RoyalMix Jan 7, 2026
f222419
Create on_trending_detected.js
RoyalMix Jan 7, 2026
43f7590
Create on_low_performance.js
RoyalMix Jan 7, 2026
a21a481
Create event_queue.js
RoyalMix Jan 7, 2026
10f7243
Create trigger_rules.json
RoyalMix Jan 7, 2026
92ce639
Create └── prediction_engine_v1.md
RoyalMix Jan 7, 2026
e659e3e
Create trend_detector.py
RoyalMix Jan 7, 2026
bcfa967
Create │ └── reinforcement_engine_v2.md
RoyalMix Jan 7, 2026
abbf583
Create Agent (AI Brain) — agent.py
RoyalMix Jan 7, 2026
f01da56
Create Reward System — reward_system.py
RoyalMix Jan 7, 2026
fe3a41d
Create Memory Buffer — memory_buffer.py
RoyalMix Jan 7, 2026
9050985
Create optimization_engine.md
RoyalMix Jan 7, 2026
d4c5b09
Create scoring.py
RoyalMix Jan 7, 2026
e811a1c
Create content_selector.py
RoyalMix Jan 7, 2026
88a27e9
Create auto_adjuster.py
RoyalMix Jan 7, 2026
c49dd31
Create execution_engine.md _scheduler.js
RoyalMix Jan 7, 2026
a352a72
Create scheduler.js
RoyalMix Jan 7, 2026
9ba3ca9
Create executor.js
RoyalMix Jan 7, 2026
8f7e25b
Create failover.js
RoyalMix Jan 7, 2026
527614a
Create └── ig_api.js
RoyalMix Jan 7, 2026
610b82e
Create scoring.py
RoyalMix Jan 7, 2026
5d447f7
Create predictor.py
RoyalMix Jan 7, 2026
6662626
Create ├── ai_system_overview.md ├── optimization_engine_v2.…
RoyalMix Jan 7, 2026
b73235c
Create Express.js
RoyalMix Jan 7, 2026
bc5b058
Create cors.js
RoyalMix Jan 7, 2026
d3503a4
Create cors.js
RoyalMix Jan 7, 2026
cd5bb4f
Create rateLimit.js
RoyalMix Jan 7, 2026
af87843
Create rateLimit.js
RoyalMix Jan 7, 2026
3d6b8da
Create helmet.js
RoyalMix Jan 7, 2026
1d9ffb3
Create sanitize.js
RoyalMix Jan 7, 2026
ede61bd
Create sanitize.js
RoyalMix Jan 7, 2026
48f9cb6
Create validateSignature.js
RoyalMix Jan 7, 2026
c7f0fba
Create errorHandler.js
RoyalMix Jan 7, 2026
ffbe056
Create index.html
RoyalMix Jan 7, 2026
fa70986
Create mongo.js
RoyalMix Jan 7, 2026
fb88ada
Create nginx.conf
RoyalMix Jan 7, 2026
cd35b84
Create server.js:
RoyalMix Jan 7, 2026
f6b9374
Create Never commit .env
RoyalMix Jan 7, 2026
392a2f3
Create Required variables:
RoyalMix Jan 7, 2026
661b13c
Create validation-key.txt
RoyalMix Jan 7, 2026
42aa39a
Create payments
RoyalMix Jan 9, 2026
d0c1b55
Create backend
RoyalMix Jan 9, 2026
2c95753
Create frontend
RoyalMix Jan 9, 2026
5c253ef
Create docs
RoyalMix Jan 9, 2026
07743df
Create index.js
RoyalMix Jan 9, 2026
b9444d6
Create wallet.model.js
RoyalMix Jan 9, 2026
4aa4952
Create transaction.model.js
RoyalMix Jan 9, 2026
14aab2b
Create security.middleware.js
RoyalMix Jan 9, 2026
378058f
Create pi.routes.js
RoyalMix Jan 9, 2026
3a9e603
Create crypto.routes.js
RoyalMix Jan 9, 2026
4b192de
Create mobile-money.routes.js
RoyalMix Jan 9, 2026
67f7308
Create bank.routes.js
RoyalMix Jan 9, 2026
89eaa0d
Create README.md
RoyalMix Jan 9, 2026
1d550e1
Create ├── architecture.md ├── api-spec.md └── security.md
RoyalMix Jan 9, 2026
5e3edd4
Create Frontend Init
RoyalMix Jan 9, 2026
e2e52f5
Create Backend Init
RoyalMix Jan 9, 2026
ecfd46f
Create Database Schema
RoyalMix Jan 9, 2026
d1efc3d
Create Security Layer
RoyalMix Jan 9, 2026
52aec6b
Create AI Modules
RoyalMix Jan 9, 2026
0836979
Create Optimization Pass
RoyalMix Jan 9, 2026
f11e2c1
Create FOLDER STRUCTURE — Royal Mix Global Super-App
RoyalMix Jan 10, 2026
f23ceb3
Create docs │ ├── API_PAYMENTS.md │ ├── INTEGRATION_GUIDE.md │ …
RoyalMix Jan 10, 2026
11d6cdb
Create Recommendation Engine.md
RoyalMix Jan 10, 2026
e0b1d45
Create stock │ │── getStock.js │ │── updateStock.js │ │──…
RoyalMix Jan 10, 2026
67eb056
Create stock │ │── getStock.js │ │── updateStock.js │ │──…
RoyalMix Jan 10, 2026
853cd06
Create get
RoyalMix Jan 10, 2026
7febda7
Create update
RoyalMix Jan 10, 2026
b89938b
Create auto-reorder
RoyalMix Jan 10, 2026
d839100
Create Production Ready)
RoyalMix Jan 11, 2026
ba4f266
Create Stock.js
RoyalMix Jan 11, 2026
6f2f2c3
Create Supplier.js
RoyalMix Jan 11, 2026
839b264
Create ReorderLog.js
RoyalMix Jan 11, 2026
decf059
Create PredictionEngine.js
RoyalMix Jan 11, 2026
1fdd27f
Create StockMonitor.js
RoyalMix Jan 11, 2026
bba8352
Create AutoReorderService.js
RoyalMix Jan 11, 2026
1724415
Create stockController.js
RoyalMix Jan 11, 2026
770c1c8
Create EVENT BUS
RoyalMix Jan 11, 2026
df0f13b
Create Event bus.js
RoyalMix Jan 11, 2026
79bfbe2
Create SECURITY – Pi Payments Integration
RoyalMix Jan 11, 2026
ad4177e
Create SECURITY – Pi Payments Integration.js
RoyalMix Jan 11, 2026
9382d33
Create SECURITY – Pi Payments Integration.md
RoyalMix Jan 11, 2026
ba671b7
Create RouteEngine.js
RoyalMix Jan 11, 2026
5069fe3
Create SupplierRanking.js
RoyalMix Jan 11, 2026
e560c36
Create WarehouseHeatmap.js
RoyalMix Jan 11, 2026
17628a4
Create driverController.js
RoyalMix Jan 11, 2026
964f8b6
Create CameraRecognition.js
RoyalMix Jan 11, 2026
8ad64bb
Create logistics-events.log
RoyalMix Jan 11, 2026
002f44a
Create AISafety.js
RoyalMix Jan 11, 2026
5eaffc3
Create eventBus.js
RoyalMix Jan 11, 2026
636511d
Create driverRoutes.js
RoyalMix Jan 11, 2026
277ba14
Create driverRoutes.js
RoyalMix Jan 11, 2026
c76cf05
Create RouteEngine.js
RoyalMix Jan 11, 2026
ccc487f
Create SupplierRanking.js
RoyalMix Jan 11, 2026
adabcb0
Create PaymentsEngine.js
RoyalMix Jan 11, 2026
01758be
Create PiPayments.js
RoyalMix Jan 11, 2026
fa61925
Create MobileMoney.js
RoyalMix Jan 11, 2026
f3440d0
Create Wallet.js
RoyalMix Jan 11, 2026
cdc3e57
Create CryptoPayments.js
RoyalMix Jan 11, 2026
aa947e7
Create MobileMoney.js
RoyalMix Jan 11, 2026
dc38204
Create PiPayments.js
RoyalMix Jan 11, 2026
79bad94
Create PaymentsEngine.js
RoyalMix Jan 11, 2026
5f2c4f9
Create paymentsRoutes.js
RoyalMix Jan 11, 2026
2792c8b
Create Driver.js
RoyalMix Jan 11, 2026
8b6fef9
Create FleetManager.js
RoyalMix Jan 11, 2026
0a75ef3
Create fleetRoutes.js
RoyalMix Jan 11, 2026
722b13a
Create risk_rules_engine.py ml_detection_mod…
RoyalMix Jan 11, 2026
54f600a
Create risk_rules_engine.py
RoyalMix Jan 11, 2026
7ba8b81
Create ml_detection_model.py
RoyalMix Jan 11, 2026
54a6b20
Create payment_velocity_checker.py
RoyalMix Jan 11, 2026
91bba19
Create anomaly_monitor.py
RoyalMix Jan 11, 2026
28c2796
Create device_fingerprint.py
RoyalMix Jan 11, 2026
f35db3a
Create fraud_dashboard_api.py
RoyalMix Jan 11, 2026
50774f7
Create geolocation_mismatch.py sim_swap_dete…
RoyalMix Jan 11, 2026
b6b455d
Create geolocation_mismatch.py
RoyalMix Jan 11, 2026
9382d13
Create sim_swap_detector.py
RoyalMix Jan 11, 2026
751e862
Create ip_reputation_checker.py
RoyalMix Jan 11, 2026
d7290e6
Create behavioral_biometrics.py
RoyalMix Jan 11, 2026
a8ffd65
Create adaptive_layout.js
RoyalMix Jan 11, 2026
9b1431c
Create theme_manager.js
RoyalMix Jan 11, 2026
43062fd
Create gesture_ai.js
RoyalMix Jan 11, 2026
a26eb2c
Create ui_personalization.js
RoyalMix Jan 11, 2026
1bdaf6e
Create pi_gateway.js
RoyalMix Jan 13, 2026
290190d
Create escrow_module.js
RoyalMix Jan 13, 2026
14335fa
Create settlement_engine.js
RoyalMix Jan 13, 2026
a800d4f
Create fraud_guard.js
RoyalMix Jan 13, 2026
5cd8c74
Create route_optimizer.py
RoyalMix Jan 13, 2026
d8dc18f
Create driver_score.py
RoyalMix Jan 13, 2026
485e49c
Create heatmap_engine.py
RoyalMix Jan 13, 2026
4902517
Create eta_predictor.py
RoyalMix Jan 13, 2026
a9db7f8
Create tracking_node.js
RoyalMix Jan 13, 2026
a6f4297
Create audit_blockchain.js
RoyalMix Jan 13, 2026
26b1ab1
Create supplier_score_engine.js
RoyalMix Jan 13, 2026
8ee02f9
Create batch_verify.js
RoyalMix Jan 13, 2026
0f5219c
Create xp_manager.js
RoyalMix Jan 13, 2026
0b2694f
Create badge_engine.js
RoyalMix Jan 13, 2026
235e810
Create streak_tracker.js
RoyalMix Jan 13, 2026
04c8455
Create referral_booster.js
RoyalMix Jan 13, 2026
9ce80d4
Create autoscale.yaml
RoyalMix Jan 13, 2026
94a3b1a
Create loadbalancer.yaml
RoyalMix Jan 13, 2026
2c6ffc5
Create cache_cluster.js
RoyalMix Jan 13, 2026
f34b1a1
Create global_cdn_config.json
RoyalMix Jan 13, 2026
897bc72
Create adaptive_layout.js
RoyalMix Jan 13, 2026
1000066
Create theme_manager.js
RoyalMix Jan 13, 2026
985685e
Create gesture_ai.js
RoyalMix Jan 13, 2026
2f3739d
Create ui_personalization.js
RoyalMix Jan 13, 2026
19dab7a
Create pi_gateway.js
RoyalMix Jan 13, 2026
033af68
Create escrow_module.js
RoyalMix Jan 13, 2026
4f235bd
Create settlement_engine.js
RoyalMix Jan 13, 2026
57c7b98
Create escrow_module.js
RoyalMix Jan 13, 2026
0012231
Create fraud_guard.js
RoyalMix Jan 13, 2026
1ce062f
Create nlp_engine.js
RoyalMix Jan 13, 2026
97311ad
Create intent_classifier.js
RoyalMix Jan 13, 2026
94d2b0d
Create voice_processor.js
RoyalMix Jan 13, 2026
5f239c3
Create action_executor.js
RoyalMix Jan 13, 2026
dfdebb0
Create pos_terminal.js
RoyalMix Jan 13, 2026
32937f9
Create receipt_engine.js
RoyalMix Jan 13, 2026
3752ae0
Create barcode_scanner.js
RoyalMix Jan 13, 2026
dbf6e10
Create staking_pool.js
RoyalMix Jan 13, 2026
fde4856
Create yield_engine.js
RoyalMix Jan 13, 2026
543f19a
Create swap_engine.js
RoyalMix Jan 13, 2026
7296cb1
Create nlp_engine.js
RoyalMix Jan 15, 2026
656dbaa
Create intent_classifier.js
RoyalMix Jan 15, 2026
470862b
Create voice_processor.js
RoyalMix Jan 15, 2026
10ced87
Create action_executor.js
RoyalMix Jan 15, 2026
34fe1c6
Create nlp_engine.js intent_classifier.js voice_processo…
RoyalMix Jan 15, 2026
e19a3fc
Create pos_terminal.js
RoyalMix Jan 15, 2026
3c82eb4
Create receipt_engine.js
RoyalMix Jan 15, 2026
e0ae096
Create barcode_scanner.js
RoyalMix Jan 15, 2026
09335aa
Create swap_engine.js
RoyalMix Jan 15, 2026
4804b22
Create yield_engine.js
RoyalMix Jan 15, 2026
8db6cd9
Create courier_tracker.js
RoyalMix Jan 15, 2026
b03777b
Create kitchen_timer.js
RoyalMix Jan 15, 2026
7f8c56a
Create eta_predictor.js
RoyalMix Jan 15, 2026
01a64eb
Create age_verification.js
RoyalMix Jan 15, 2026
9e2e8e7
Create brand_catalog.js
RoyalMix Jan 15, 2026
6fdb3a8
Create liquor_auto_reorder.js
RoyalMix Jan 15, 2026
7072dd9
Create ui AdsDashboard.js CreateAdForm.js AdAnalyti…
RoyalMix Jan 15, 2026
05bf36d
Create AdBiddingEngine.js
RoyalMix Jan 15, 2026
1a6147d
Create seller-center Dashboard.js SalesAnalytics.js Inventor…
RoyalMix Jan 15, 2026
89136c6
Create search-engine SearchAPI.js RankingLogic.js AutoSugges…
RoyalMix Jan 15, 2026
d565d4f
Create notifications EventDispatcher.js PushService.js InApp…
RoyalMix Jan 15, 2026
b4defe9
Create ads-manager
RoyalMix Jan 15, 2026
ebd4a9e
Create support supportChatScreen.jsx faqScreen.jsx
RoyalMix Jan 15, 2026
c1f0cf3
Create settlements SettlementEngine.js Ledger.js PayoutSchedule…
RoyalMix Jan 15, 2026
1f9844d
Create settlements SettlementEngine.js Ledger.js PayoutSchedule…
RoyalMix Jan 15, 2026
e1216e9
Create rmix-os AdminConsole.js StaffRoles.js PermissionsMatrix.js
RoyalMix Jan 15, 2026
7fd3b53
Create analytics analyticsDashboard.jsx
RoyalMix Jan 15, 2026
f5d0f0c
Create voice-commerce SpeechToOrder.js VoiceIntentParser.js Pro…
RoyalMix Jan 15, 2026
252bbd0
Create marketing-ai CampaignGenerator.js UserSegmentation.js Pe…
RoyalMix Jan 15, 2026
a23ae19
Create translator TranslateService.js LanguageDetector.js
RoyalMix Jan 15, 2026
8708276
Create social-commerce LiveShopping.js GroupShops.js Influencer…
RoyalMix Jan 15, 2026
57f82ea
Create blockchain-audit AuditTrail.js HashGenerator.js PiChainS…
RoyalMix Jan 15, 2026
bb3f9c9
Create security DeviceFingerprint.js RiskEngine.js BehaviorAnal…
RoyalMix Jan 15, 2026
a62dde2
Create pi_domain_verification.txt Content: _pi-domain-verification c…
RoyalMix Jan 19, 2026
8902659
Create validation-key.txt
RoyalMix Jan 20, 2026
6dbfc9a
Create DOMAIN_VERIFICATION.md
RoyalMix Jan 20, 2026
4eebe23
Create validation-key.txt
RoyalMix Jan 20, 2026
634d410
Update pi_domain_verification.txt Content: _pi-domain-verification c…
RoyalMix Jan 21, 2026
5126f91
Create │ ├── ministries.config.json │ ├── tax-rates.conf…
RoyalMix Jan 24, 2026
ab7074d
Create integration-layer
RoyalMix Jan 24, 2026
3f11a39
Create SUPER_DATABASE_ARCHITECTURE.md
RoyalMix Jan 25, 2026
a186a32
Create wallet
RoyalMix Jan 25, 2026
42e8325
Update wallet
RoyalMix Jan 25, 2026
a3f8f45
Create marketplace
RoyalMix Jan 25, 2026
cfd3782
Create property
RoyalMix Jan 25, 2026
eac231f
Create analytics
RoyalMix Jan 25, 2026
0d06cb2
Create PI_AI_STUDIO_BACKEND_TASKS.md
RoyalMix Jan 25, 2026
d8cc9cf
Create └── deploy
RoyalMix Jan 27, 2026
21ab8a8
Create GovTechDashboard.js
RoyalMix Jan 27, 2026
d6249e1
Create taxEngine.js
RoyalMix Jan 27, 2026
d1830de
Create economicAI.js
RoyalMix Jan 27, 2026
3f974b4
Create verification.js
RoyalMix Jan 27, 2026
1512f38
Create agentNetwork.js
RoyalMix Jan 27, 2026
d548200
Create CitizenApp.js
RoyalMix Jan 27, 2026
89f8aa8
Create ChocoMarket.js
RoyalMix Jan 27, 2026
6916b46
Create WalletSync.js
RoyalMix Jan 27, 2026
80815c9
Create app.js
RoyalMix Jan 27, 2026
327bf71
Create authMiddleware.js
RoyalMix Jan 27, 2026
2eaaf55
Create roleMiddleware.js
RoyalMix Jan 27, 2026
32628a5
Create govDashboard.js
RoyalMix Jan 27, 2026
7562d56
Create riskEngine.js
RoyalMix Jan 27, 2026
cfe0e83
Create govConfig.js
RoyalMix Jan 27, 2026
e6f8bdf
Create health.js
RoyalMix Jan 27, 2026
83888ec
Create RoleRouter.js
RoyalMix Jan 27, 2026
6d0ebd8
Create .env.templete
RoyalMix Jan 27, 2026
2c50995
Update app.js
RoyalMix Jan 27, 2026
d8abd45
Update app.js
RoyalMix Jan 27, 2026
5bdc479
Update app.js
RoyalMix Jan 27, 2026
9b880c9
Create encryption.js
RoyalMix Jan 27, 2026
0a04a56
Create env.template
RoyalMix Jan 27, 2026
0940a71
Create gitignore
RoyalMix Jan 27, 2026
dff8731
Create integrationRoutes.js
RoyalMix Jan 27, 2026
64d767e
Create walletRoutes.js
RoyalMix Jan 27, 2026
864f47a
Create aiRoutes.js
RoyalMix Jan 27, 2026
7230e4a
Create citizenAIRoutes.js
RoyalMix Jan 27, 2026
6118233
Create pi-domain-verification.txt
RoyalMix Jan 27, 2026
3469b33
Create verifyGovToken.js
RoyalMix Jan 27, 2026
fccefd5
Create riskRoutes.js
RoyalMix Jan 27, 2026
26fabb9
Create riskController.js
RoyalMix Jan 27, 2026
c5361ab
Create env.template
RoyalMix Jan 27, 2026
cf017f8
Update app.js
RoyalMix Jan 27, 2026
c6bc4c7
Update app.js
RoyalMix Jan 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Add Content Brain Modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
git add ai-system/content-brain/
git commit -m "feat: add trend detector, script generator, caption builder engines"
2 changes: 2 additions & 0 deletions Add Documentation
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
git add docs/
git commit -m "docs: add AI Automated Posting System documentation"
2 changes: 2 additions & 0 deletions Add Learning Engine
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
git add ai-system/learning-engine/
git commit -m "feat: add engagement analyzer + virality predictor + auto optimizer"
2 changes: 2 additions & 0 deletions Add Platform API Integration
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
git add ai-system/platforms/
git commit -m "feat: integrate TikTok, IG, FB, YouTube, Telegram API modules"
2 changes: 2 additions & 0 deletions Add Scheduler System
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
git add ai-system/scheduler/
git commit -m "feat: add cron manager, posting queue, automatic retry handler"
1 change: 1 addition & 0 deletions Deploy Hooks
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://api.render.com/deploy/srv-XXXXXX?key=YYYYYYYY
1 change: 1 addition & 0 deletions Express.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cors.js rateLimit.js helmet.js sanitize.js validateSignature.js errorHandler.js
26 changes: 26 additions & 0 deletions FILE & FOLDER STRUCTURE (Final / Clean /Production Ready)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/services
├── StockService.js
├── StockMonitor.js
├── AutoReorderService.js
└── PredictionEngine.js

/controllers
└── stockController.js

/models
├── Stock.js
├── Supplier.js
└── ReorderLog.js

/events
└── eventBus.js

/utils
├── notifications.js
└── security.js

/api
└── stockRoutes.js

/config
└── db.js
15 changes: 15 additions & 0 deletions FILE & FOLDER STRUCTURE (Final / Clean /models/ReorderLog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import mongoose from "mongoose";

const ReorderLogSchema = new mongoose.Schema(
{
stockId: { type: mongoose.Schema.Types.ObjectId, ref: "Stock" },
quantityOrdered: Number,
status: { type: String, default: "PENDING" },
auto: { type: Boolean, default: true }
},
{ timestamps: true }
);

ReorderLogSchema.index({ createdAt: 1 }, { expireAfterSeconds: 86400 * 30 });

export default mongoose.model("ReorderLog", ReorderLogSchema);
16 changes: 16 additions & 0 deletions FILE & FOLDER STRUCTURE (Final / Clean /models/Stock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import mongoose from "mongoose";

const StockSchema = new mongoose.Schema(
{
productId: { type: String, required: true, index: true },
productName: { type: String, required: true },
quantity: { type: Number, required: true },
reorderLevel: { type: Number, default: 10 },
supplierId: { type: mongoose.Schema.Types.ObjectId, ref: "Supplier" }
},
{ timestamps: true }
);

StockSchema.index({ productId: 1, supplierId: 1 });

export default mongoose.model("Stock", StockSchema);
12 changes: 12 additions & 0 deletions FILE & FOLDER STRUCTURE (Final / Clean /models/models/Supplier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import mongoose from "mongoose";

const SupplierSchema = new mongoose.Schema(
{
name: { type: String, required: true },
contact: { type: String },
piWallet: { type: String, required: true }
},
{ timestamps: true }
);

export default mongoose.model("Supplier", SupplierSchema);
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export class PredictionEngine {
static forecast(dailySalesHistory = []) {
if (dailySalesHistory.length < 3) return 5;

const smoothingFactor = 0.6;

let prediction = dailySalesHistory[0];
for (let i = 1; i < dailySalesHistory.length; i++) {
prediction =
smoothingFactor * dailySalesHistory[i] +
(1 - smoothingFactor) * prediction;
}

return Math.round(prediction);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import eventBus from "../events/eventBus.js";

export class StockMonitor {
static check(stock) {
if (stock.quantity <= stock.reorderLevel) {
eventBus.emit("stock.low", stock);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import ReorderLog from "../models/ReorderLog.js";
import Supplier from "../models/Supplier.js";
import { sendNotification } from "../utils/notifications.js";
import { initiatePiPayment } from "../utils/security.js";

export class AutoReorderService {
static async createReorder(stock) {
const supplier = await Supplier.findById(stock.supplierId);

const order = await ReorderLog.create({
stockId: stock._id,
quantityOrdered: stock.reorderLevel * 2
});

sendNotification(supplier.contact, `Auto-reorder placed for ${stock.productName}`);

await initiatePiPayment(supplier.piWallet, 1.5);

return order;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export async function initiatePiPayment(wallet, amount) {
return {
wallet,
amount,
status: "INITIATED",
timestamp: Date.now()
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export async function initiatePiPayment(wallet, amount) {
return {
wallet,
amount,
status: "INITIATED",
timestamp: Date.now()
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export async function initiatePiPayment(wallet, amount) {
return {
wallet,
amount,
status: "INITIATED",
timestamp: Date.now()
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import EventEmitter from "events";
import { AutoReorderService } from "../services/AutoReorderService.js";

const eventBus = new EventEmitter();

eventBus.on("stock.low", async (stock) => {
await AutoReorderService.createReorder(stock);
});

export default eventBus;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import EventEmitter from "events";
import { AutoReorderService } from "../services/AutoReorderService.js";

const eventBus = new EventEmitter();

eventBus.on("stock.low", async (stock) => {
await AutoReorderService.createReorder(stock);
});

export default eventBus;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Stock from "../models/Stock.js";
import { PredictionEngine } from "../services/PredictionEngine.js";
import { StockMonitor } from "../services/StockMonitor.js";
import { AutoReorderService } from "../services/AutoReorderService.js";

export const StockController = {
async checkAndReorder(req, res) {
const stock = await Stock.findById(req.params.id);
StockMonitor.check(stock);
res.json({ status: "checked", stock });
},

async predict(req, res) {
const { history } = req.body;
const forecast = PredictionEngine.forecast(history);
res.json({ forecast });
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class RouteEngine {
static optimize(deliveries = []) {
return deliveries.sort((a, b) => a.distance - b.distance);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export class SupplierRanking {
static rank(suppliers) {
return suppliers.sort((a, b) => b.score - a.score);
}

static calculateScore(stats) {
return (
stats.onTimeDelivery * 0.4 +
stats.priceStability * 0.2 +
stats.quality * 0.3 +
stats.communication * 0.1
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export class WarehouseHeatmap {
static generate(stockList) {
return stockList.map(item => ({
product: item.productName,
temperature: item.quantity < item.reorderLevel ? "HOT" : "COLD"
}));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import eventBus from "../utils/eventBus.js";

export const DriverController = {
updateLocation(req, res) {
eventBus.emit("driver.location.update", req.body);
res.json({ status: "location updated" });
},

confirmDelivery(req, res) {
eventBus.emit("delivery.completed", req.body);
res.json({ status: "delivery confirmed" });
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export class CameraRecognition {
static detect(frameData) {
return {
detectedItems: [
{ productId: "RM-CH-01", count: 12 },
{ productId: "RM-ML-02", count: 4 }
]
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Logistics AI Events Log
# System-generated events related to stock, delivery, and supplier AI.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export class AISafety {
constructor() {
this.failCount = 0;
this.threshold = 3;
}

recordFailure() {
this.failCount++;
if (this.failCount >= this.threshold) {
return { locked: true, message: "AI fail-lock triggered" };
}
return { locked: false };
}

reset() {
this.failCount = 0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { EventEmitter } from "events";
const eventBus = new EventEmitter();
export default eventBus;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import express from "express";
import { DriverController } from "../controllers/driverController.js";

const router = express.Router();

router.post("/location", DriverController.updateLocation);
router.post("/confirm", DriverController.confirmDelivery);

export default router;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import express from "express";
import { DriverController } from "../controllers/driverController.js";

const router = express.Router();

router.post("/location", DriverController.updateLocation);
router.post("/confirm", DriverController.confirmDelivery);

export default router;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class RouteEngine {
static optimize(deliveries = []) {
return deliveries.sort((a, b) => a.distance - b.distance);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export class SupplierRanking {
static rank(suppliers) {
return suppliers.sort((a, b) => b.score - a.score);
}

static calculateScore(stats) {
return (
stats.onTimeDelivery * 0.4 +
stats.priceStability * 0.2 +
stats.quality * 0.3 +
stats.communication * 0.1
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export class PaymentsEngine {
static validateTransaction(tx) {
if (!tx.amount || tx.amount <= 0) return false;
if (!tx.currency) return false;
if (!tx.userId) return false;
return true;
}

static convertCurrency(amount, rate) {
return amount * rate;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Pi } from "@pi-network/pi-sdk";

export class PiPayments {
static async createPayment(amount, user) {
const payment = await Pi.createPayment({
amount,
memo: "RoyalMix Payment",
metadata: { userId: user }
});
return payment;
}

static async verifyPayment(paymentId) {
return await Pi.verifyPayment(paymentId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export class MobileMoney {
static async sendMoney(phone, amount) {
return { status: "success", phone, amount };
}

static async receiveMoney(phone, amount) {
return { status: "received", phone, amount };
}
}
Loading