-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
141 lines (126 loc) · 5.39 KB
/
Copy pathmain.py
File metadata and controls
141 lines (126 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
"""
BazaarOps - Single Entry Point with Claude AI Agents
Runs everything using subprocess for proper isolation
"""
import subprocess
import sys
import time
from pathlib import Path
# Get base directory
BASE_DIR = Path(__file__).parent.absolute()
def main():
print("=" * 70)
print("🛒 BazaarOps - AI-Powered Store Management System")
print("=" * 70)
print("\n🧠 Powered by Claude 3.5 Sonnet AI Agents\n")
print("Starting all services...\n")
processes = []
try:
# 1. Start Owner Service (FastAPI Backend)
print("🚀 Starting Owner Service...")
owner_service_process = subprocess.Popen(
[sys.executable, "main.py"],
cwd=str(BASE_DIR / "owner-service"),
shell=True
)
processes.append(("Owner-Service", owner_service_process))
print("✅ Started: Owner-Service (Port 8001)")
time.sleep(2)
# 2. Start Customer Service (FastAPI Backend)
print("🛍️ Starting Customer Service...")
customer_service_process = subprocess.Popen(
[sys.executable, "main.py"],
cwd=str(BASE_DIR / "customer-service"),
shell=True
)
processes.append(("Customer-Service", customer_service_process))
print("✅ Started: Customer-Service (Port 8002)")
time.sleep(2)
# 3. Start Agent Service (AI Agents)
print("🤖 Starting Agent Service...")
agent_service_process = subprocess.Popen(
[sys.executable, "main.py"],
cwd=str(BASE_DIR / "agent-service"),
shell=True
)
processes.append(("Agent-Service", agent_service_process))
print("✅ Started: Agent-Service (Port 8003)")
time.sleep(2)
# 4. Start Owner Telegram Bot
print("📱 Starting Owner Bot...")
owner_bot_process = subprocess.Popen(
[sys.executable, "bot.py"],
cwd=str(BASE_DIR / "telegram-bots" / "owner-bot"),
shell=True
)
processes.append(("Owner-Bot", owner_bot_process))
print("✅ Started: Owner-Bot (@BazaarOpsAdminBot)")
time.sleep(2)
# 5. Start Customer Telegram Bot
print("🛒 Starting Customer Bot...")
customer_bot_process = subprocess.Popen(
[sys.executable, "bot.py"],
cwd=str(BASE_DIR / "telegram-bots" / "customer-bot"),
shell=True
)
processes.append(("Customer-Bot", customer_bot_process))
print("✅ Started: Customer-Bot (@BazaarOpsCustomerHelpBot)")
time.sleep(2)
# 6. Start AI Scheduler
print("🧠 Starting AI Agent Scheduler...")
scheduler_process = subprocess.Popen(
[sys.executable, "scheduler.py"],
cwd=str(BASE_DIR / "telegram-bots" / "owner-bot"),
shell=True
)
processes.append(("Claude-AI-Scheduler", scheduler_process))
print("✅ Started: Claude-AI-Scheduler")
print("\n" + "=" * 70)
print("🎉 All Backend Services Running Successfully!")
print("=" * 70)
print("\n📱 Access Points:")
print(" • Owner API: http://localhost:8001")
print(" • Customer API: http://localhost:8002")
print(" • Agent API: http://localhost:8003")
print(" • Owner Bot: @BazaarOpsAdminBot")
print(" • Customer Bot: @BazaarOpsCustomerHelpBot")
print("\n💡 Dashboard:")
print(" • Run separately: cd owner-dashboard && npm run dev")
print(" • Access at: http://localhost:3000")
print("\n🧠 Claude AI Agents (Automated):")
print(" • 10:00 AM - AI Inventory Analysis (demand prediction, restocking)")
print(" • 04:00 PM - AI Inventory Analysis (afternoon check)")
print(" • 09:00 PM - AI Daily Business Insights (performance analysis)")
print(" • 09:05 PM - AI Credit Risk Assessment (collection strategies)")
print("\n💡 Features:")
print(" • Real-time inventory management")
print(" • Intelligent restocking recommendations")
print(" • Credit risk analysis with collection strategies")
print(" • Daily AI-powered business insights")
print(" • Customer ordering via Telegram (deep linking)")
print(" • Automatic inventory reduction on orders")
print(" • Auto-notifications on delivery")
print(" • WhatsApp supplier integration")
print("\n🔗 Customer Deep Linking:")
print(" Share: https://t.me/BazaarOpsCustomerHelpBot?start=YOUR_STORE_ID")
print("\nPress Ctrl+C to stop all services\n")
# Keep running and monitor processes
while True:
time.sleep(5)
# Check if any process died
for name, proc in processes:
if proc.poll() is not None:
print(f"⚠️ {name} stopped unexpectedly!")
except KeyboardInterrupt:
print("\n\n👋 Shutting down all services...")
for name, proc in processes:
print(f"Stopping {name}...")
proc.terminate()
# Wait for all to terminate
time.sleep(2)
for name, proc in processes:
if proc.poll() is None:
proc.kill()
print("Goodbye!")
if __name__ == "__main__":
main()