Spaces:
Sleeping
Sleeping
File size: 21,326 Bytes
f84a02d | 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | #!/usr/bin/env python3
"""
ATOM Platform - 33 Integrations Deployment Script
This script executes the production deployment process for all 33 ATOM platform
integrations, including comprehensive testing, validation, and monitoring setup.
Usage:
python deploy_33_integrations.py
"""
import asyncio
from dataclasses import dataclass
from datetime import datetime
import json
import logging
import os
import subprocess
import sys
import time
from typing import Any, Dict, List, Optional, Tuple
import requests
# Configure logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
handlers=[logging.FileHandler("deployment.log"), logging.StreamHandler(sys.stdout)],
)
logger = logging.getLogger(__name__)
@dataclass
class IntegrationStatus:
"""Status tracking for each integration"""
name: str
category: str
endpoints: List[str]
status: str = "pending"
health_check: str = "not_tested"
performance: Optional[float] = None
errors: List[str] = None
def __post_init__(self):
if self.errors is None:
self.errors = []
class IntegrationDeployment:
"""Production deployment execution for 33 integrations"""
def __init__(self):
self.base_url = "http://localhost:5058"
self.frontend_url = "http://localhost:3000"
self.deployment_log = []
self.start_time = datetime.now()
self.integrations = self._initialize_integrations()
def _initialize_integrations(self) -> Dict[str, IntegrationStatus]:
"""Initialize all 33 integrations with their endpoints"""
return {
# Communication & Collaboration (7)
"slack": IntegrationStatus(
name="Slack",
category="Communication",
endpoints=["/slack/auth", "/slack/channels", "/slack/messages"],
),
"teams": IntegrationStatus(
name="Microsoft Teams",
category="Communication",
endpoints=["/teams/auth", "/teams/channels", "/teams/messages"],
),
"discord": IntegrationStatus(
name="Discord",
category="Communication",
endpoints=["/discord/auth", "/discord/channels", "/discord/messages"],
),
"google_chat": IntegrationStatus(
name="Google Chat",
category="Communication",
endpoints=[
"/google_chat/auth",
"/google_chat/spaces",
"/google_chat/messages",
],
),
"telegram": IntegrationStatus(
name="Telegram",
category="Communication",
endpoints=["/telegram/auth", "/telegram/chats", "/telegram/messages"],
),
"whatsapp": IntegrationStatus(
name="WhatsApp",
category="Communication",
endpoints=["/whatsapp/auth", "/whatsapp/chats", "/whatsapp/messages"],
),
"zoom": IntegrationStatus(
name="Zoom",
category="Communication",
endpoints=["/zoom/auth", "/zoom/meetings", "/zoom/recordings"],
),
# Document Storage & File Management (5)
"google_drive": IntegrationStatus(
name="Google Drive",
category="Document Storage",
endpoints=[
"/google_drive/auth",
"/google_drive/files",
"/google_drive/search",
],
),
"dropbox": IntegrationStatus(
name="Dropbox",
category="Document Storage",
endpoints=["/dropbox/auth", "/dropbox/files", "/dropbox/search"],
),
"box": IntegrationStatus(
name="Box",
category="Document Storage",
endpoints=["/box/auth", "/box/files", "/box/search"],
),
"onedrive": IntegrationStatus(
name="OneDrive",
category="Document Storage",
endpoints=["/onedrive/auth", "/onedrive/files", "/onedrive/search"],
),
"github": IntegrationStatus(
name="GitHub",
category="Document Storage",
endpoints=["/github/auth", "/github/repos", "/github/search"],
),
# Productivity & Project Management (7)
"asana": IntegrationStatus(
name="Asana",
category="Productivity",
endpoints=["/asana/auth", "/asana/projects", "/asana/tasks"],
),
"notion": IntegrationStatus(
name="Notion",
category="Productivity",
endpoints=["/notion/auth", "/notion/pages", "/notion/databases"],
),
"linear": IntegrationStatus(
name="Linear",
category="Productivity",
endpoints=["/linear/auth", "/linear/issues", "/linear/teams"],
),
"monday": IntegrationStatus(
name="Monday.com",
category="Productivity",
endpoints=["/monday/auth", "/monday/boards", "/monday/items"],
),
"trello": IntegrationStatus(
name="Trello",
category="Productivity",
endpoints=["/trello/auth", "/trello/boards", "/trello/cards"],
),
"jira": IntegrationStatus(
name="Jira",
category="Productivity",
endpoints=["/jira/auth", "/jira/projects", "/jira/issues"],
),
"gitlab": IntegrationStatus(
name="GitLab",
category="Productivity",
endpoints=["/gitlab/auth", "/gitlab/projects", "/gitlab/issues"],
),
# CRM & Business Operations (5)
"salesforce": IntegrationStatus(
name="Salesforce",
category="CRM",
endpoints=[
"/salesforce/auth",
"/salesforce/contacts",
"/salesforce/opportunities",
],
),
"hubspot": IntegrationStatus(
name="HubSpot",
category="CRM",
endpoints=[
"/hubspot/auth",
"/hubspot/contacts",
"/hubspot/deals",
"/hubspot/campaigns",
],
),
"intercom": IntegrationStatus(
name="Intercom",
category="CRM",
endpoints=[
"/intercom/auth",
"/intercom/contacts",
"/intercom/conversations",
],
),
"freshdesk": IntegrationStatus(
name="Freshdesk",
category="CRM",
endpoints=[
"/freshdesk/auth",
"/freshdesk/tickets",
"/freshdesk/contacts",
],
),
"zendesk": IntegrationStatus(
name="Zendesk",
category="CRM",
endpoints=["/zendesk/auth", "/zendesk/tickets", "/zendesk/users"],
),
# Financial & Payment Systems (3)
"stripe": IntegrationStatus(
name="Stripe",
category="Financial",
endpoints=["/stripe/auth", "/stripe/customers", "/stripe/payments"],
),
"quickbooks": IntegrationStatus(
name="QuickBooks",
category="Financial",
endpoints=[
"/quickbooks/auth",
"/quickbooks/invoices",
"/quickbooks/customers",
],
),
"xero": IntegrationStatus(
name="Xero",
category="Financial",
endpoints=["/xero/auth", "/xero/invoices", "/xero/contacts"],
),
# Marketing & Analytics (6)
"mailchimp": IntegrationStatus(
name="Mailchimp",
category="Marketing",
endpoints=[
"/mailchimp/auth",
"/mailchimp/campaigns",
"/mailchimp/audiences",
],
),
"hubspot_marketing": IntegrationStatus(
name="HubSpot Marketing",
category="Marketing",
endpoints=[
"/hubspot_marketing/auth",
"/hubspot_marketing/campaigns",
"/hubspot_marketing/analytics",
],
),
"tableau": IntegrationStatus(
name="Tableau",
category="Analytics",
endpoints=[
"/tableau/auth",
"/tableau/workbooks",
"/tableau/dashboards",
],
),
"google_analytics": IntegrationStatus(
name="Google Analytics",
category="Analytics",
endpoints=[
"/google_analytics/auth",
"/google_analytics/reports",
"/google_analytics/audiences",
],
),
"figma": IntegrationStatus(
name="Figma",
category="Design",
endpoints=["/figma/auth", "/figma/files", "/figma/prototypes"],
),
"shopify": IntegrationStatus(
name="Shopify",
category="E-commerce",
endpoints=["/shopify/auth", "/shopify/products", "/shopify/orders"],
),
}
def log_step(self, step_name: str, status: str, message: str = ""):
"""Log deployment step with timestamp"""
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
log_entry = f"{timestamp} - {step_name} - {status} - {message}"
self.deployment_log.append(log_entry)
logger.info(f"{step_name}: {status} - {message}")
# Update integration status if applicable
for integration_name, integration in self.integrations.items():
if integration_name in step_name.lower():
integration.status = status
if "error" in status.lower():
integration.errors.append(message)
async def check_backend_health(self) -> bool:
"""Check if backend API is healthy"""
try:
response = requests.get(f"{self.base_url}/health", timeout=10)
if response.status_code == 200:
self.log_step(
"Backend Health Check", "success", "Backend API is healthy"
)
return True
else:
self.log_step(
"Backend Health Check",
"error",
f"Status code: {response.status_code}",
)
return False
except Exception as e:
self.log_step("Backend Health Check", "error", f"Exception: {str(e)}")
return False
async def test_integration_endpoint(
self, integration_name: str, endpoint: str
) -> Tuple[bool, float]:
"""Test a specific integration endpoint"""
try:
start_time = time.time()
url = f"{self.base_url}{endpoint}"
# For testing purposes, we'll check if the endpoint exists
# In production, this would make actual API calls
response = requests.get(url, timeout=30)
response_time = (time.time() - start_time) * 1000 # Convert to milliseconds
if response.status_code in [
200,
401,
]: # 401 is expected for unauthenticated endpoints
return True, response_time
else:
return False, response_time
except Exception as e:
return False, 0.0
async def validate_integration(
self, integration_name: str, integration: IntegrationStatus
):
"""Validate a single integration"""
self.log_step(
f"Validate {integration_name}",
"started",
f"Testing {len(integration.endpoints)} endpoints",
)
successful_endpoints = 0
total_response_time = 0
for endpoint in integration.endpoints:
success, response_time = await self.test_integration_endpoint(
integration_name, endpoint
)
if success:
successful_endpoints += 1
total_response_time += response_time
self.log_step(
f"{integration_name} - {endpoint}",
"success",
f"Response: {response_time:.2f}ms",
)
else:
self.log_step(
f"{integration_name} - {endpoint}", "error", "Endpoint test failed"
)
# Calculate average response time
if successful_endpoints > 0:
avg_response_time = total_response_time / successful_endpoints
integration.performance = avg_response_time
# Update integration status
if successful_endpoints == len(integration.endpoints):
integration.status = "healthy"
integration.health_check = "passed"
self.log_step(
f"Validate {integration_name}",
"success",
f"All endpoints healthy (avg: {integration.performance:.2f}ms)",
)
else:
integration.status = "degraded"
integration.health_check = "partial"
self.log_step(
f"Validate {integration_name}",
"warning",
f"{successful_endpoints}/{len(integration.endpoints)} endpoints working",
)
async def validate_all_integrations(self):
"""Validate all 33 integrations"""
self.log_step(
"Validate All Integrations", "started", "Testing all 33 integrations"
)
tasks = []
for integration_name, integration in self.integrations.items():
task = self.validate_integration(integration_name, integration)
tasks.append(task)
# Run validation in batches to avoid overwhelming the system
batch_size = 5
for i in range(0, len(tasks), batch_size):
batch = tasks[i : i + batch_size]
await asyncio.gather(*batch)
await asyncio.sleep(1) # Brief pause between batches
self.log_step(
"Validate All Integrations", "completed", "All integrations validated"
)
def generate_deployment_report(self) -> Dict[str, Any]:
"""Generate comprehensive deployment report"""
healthy_count = sum(
1 for i in self.integrations.values() if i.status == "healthy"
)
degraded_count = sum(
1 for i in self.integrations.values() if i.status == "degraded"
)
failed_count = sum(1 for i in self.integrations.values() if i.status == "error")
# Calculate performance statistics
response_times = [
i.performance for i in self.integrations.values() if i.performance
]
avg_response_time = (
sum(response_times) / len(response_times) if response_times else 0
)
report = {
"deployment_id": f"deploy_{int(time.time())}",
"timestamp": datetime.now().isoformat(),
"duration_seconds": (datetime.now() - self.start_time).total_seconds(),
"summary": {
"total_integrations": 33,
"healthy_integrations": healthy_count,
"degraded_integrations": degraded_count,
"failed_integrations": failed_count,
"success_rate": (healthy_count / 33) * 100,
"average_response_time_ms": avg_response_time,
},
"integrations": {
name: {
"name": integration.name,
"category": integration.category,
"status": integration.status,
"health_check": integration.health_check,
"performance_ms": integration.performance,
"endpoints": integration.endpoints,
"errors": integration.errors,
}
for name, integration in self.integrations.items()
},
"log_entries": self.deployment_log,
}
return report
def save_deployment_report(self, report: Dict[str, Any]):
"""Save deployment report to file"""
filename = f"deployment_report_{report['deployment_id']}.json"
with open(filename, "w") as f:
json.dump(report, f, indent=2)
self.log_step(
"Save Deployment Report", "success", f"Report saved to {filename}"
)
# Also save a human-readable summary
summary_filename = f"deployment_summary_{report['deployment_id']}.txt"
with open(summary_filename, "w") as f:
f.write("ATOM Platform - 33 Integrations Deployment Summary\n")
f.write("=" * 60 + "\n\n")
f.write(f"Deployment ID: {report['deployment_id']}\n")
f.write(f"Timestamp: {report['timestamp']}\n")
f.write(f"Duration: {report['duration_seconds']:.2f} seconds\n\n")
f.write("SUMMARY:\n")
f.write(
f" Total Integrations: {report['summary']['total_integrations']}\n"
)
f.write(f" Healthy: {report['summary']['healthy_integrations']}\n")
f.write(f" Degraded: {report['summary']['degraded_integrations']}\n")
f.write(f" Failed: {report['summary']['failed_integrations']}\n")
f.write(f" Success Rate: {report['summary']['success_rate']:.1f}%\n")
f.write(
f" Avg Response Time: {report['summary']['average_response_time_ms']:.2f}ms\n\n"
)
f.write("INTEGRATION STATUS BY CATEGORY:\n")
categories = {}
for integration in report["integrations"].values():
category = integration["category"]
if category not in categories:
categories[category] = {"total": 0, "healthy": 0}
categories[category]["total"] += 1
if integration["status"] == "healthy":
categories[category]["healthy"] += 1
for category, stats in categories.items():
success_rate = (stats["healthy"] / stats["total"]) * 100
f.write(
f" {category}: {stats['healthy']}/{stats['total']} ({success_rate:.1f}%)\n"
)
async def execute_deployment(self):
"""Execute the complete deployment process"""
self.log_step(
"Deployment Start", "started", "Beginning 33 integrations deployment"
)
try:
# Step 1: Verify backend health
if not await self.check_backend_health():
self.log_step("Deployment", "error", "Backend health check failed")
return False
# Step 2: Validate all integrations
await self.validate_all_integrations()
# Step 3: Generate and save report
report = self.generate_deployment_report()
self.save_deployment_report(report)
# Step 4: Final status
success_rate = report["summary"]["success_rate"]
if success_rate >= 95:
self.log_step(
"Deployment Complete",
"success",
f"Deployment successful! {success_rate:.1f}% of integrations healthy",
)
return True
elif success_rate >= 80:
self.log_step(
"Deployment Complete",
"warning",
f"Deployment completed with warnings. {success_rate:.1f}% of integrations healthy",
)
return True
else:
self.log_step(
"Deployment Complete",
"error",
f"Deployment failed. Only {success_rate:.1f}% of integrations healthy",
)
return False
except Exception as e:
self.log_step(
"Deployment", "error", f"Deployment failed with exception: {str(e)}"
)
return False
async def main():
"""Main execution function"""
print("🚀 ATOM Platform - 33 Integrations Deployment")
print("=" * 50)
deployment = IntegrationDeployment()
success = await deployment.execute_deployment()
print("\n" + "=" * 50)
if success:
print("✅ DEPLOYMENT COMPLETED SUCCESSFULLY")
|