<?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="0 0 980 780" xmlns="http://www.w3.org/2000/svg" style="max-width: 100%; height: auto;">
  <defs>
    <!-- Arrow markers -->
    <marker id="arrow" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">
      <path d="M0,0 L0,6 L9,3 z" fill="#2563EB">
    </marker>

    <!-- Drop shadow for depth -->
    <filter id="shadow" x="-20%" y="-20%" width="140%" height="140%">
      <feGaussianBlur in="SourceAlpha" stdDeviation="2">
      <feOffset dx="1" dy="1" result="offsetblur">
      <feComponentTransfer>
        <feFuncA type="linear" slope="0.2">
      </feComponentTransfer>
      <feMerge>
        <feMergeNode/>
        <feMergeNode in="SourceGraphic">
      </feMerge>
    </filter>
  </defs>



  <!-- Beautiful gradient definitions for depth -->
  

  <!-- White background with subtle border -->
  <rect x="0" y="0" width="980" height="780" fill="#F9FAFB" stroke="#9CA3AF" stroke-width="2" rx="8">

  <!-- Content container with proper margins -->
  <g transform="translate(40, 40)">
  

  <!-- Title -->
  <text x="450" y="30" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="24" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">BotServer Architecture - Virtual Crates System</text>

  <!-- Main Container -->
  <rect x="40" y="50" width="820" height="620" fill="none" stroke="#2563EB" stroke-width="2" rx="12" stroke-opacity="0.5" filter="url(#shadow)"/>

  <!-- Binary Output -->
  <rect x="350" y="70" width="200" height="40" fill="#4B5563" stroke="#2563EB" stroke-width="2" rx="8" filter="url(#shadow)">
  <text x="450" y="95" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="16" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">BotServer Binary</text>

  <!-- Compilation Arrow -->
  <line x1="450" y1="110" x2="450" y2="140" stroke="#666" stroke-width="2" marker-end="url(#arrowhead)" stroke-dasharray="5,3" opacity="0.6">
  <text x="470" y="130" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">compiles to</text>

  <!-- Core Layer -->
  <g id="core-layer">
    <rect x="60" y="140" width="780" height="120" fill="#4B5563" fill-opacity="0.3" stroke="#2563EB" stroke-width="2" rx="8" filter="url(#shadow)">
    <text x="450" y="165" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="18" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">Core Engine (src/core/)</text>

    <!-- Core Components -->
    <rect x="80" y="185" width="140" height="55" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="150" y="205" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">Bootstrap</text>
    <text x="150" y="220" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)" font-weight="600">System Init</text>
    <text x="150" y="232" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Service Start</text>

    <rect x="240" y="185" width="140" height="55" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="310" y="205" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">Package Manager</text>
    <text x="310" y="220" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Component Registry</text>
    <text x="310" y="232" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Module Loader</text>

    <rect x="400" y="185" width="140" height="55" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="470" y="205" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">Session Manager</text>
    <text x="470" y="220" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Context Handling</text>
    <text x="470" y="232" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">State Management</text>

    <rect x="560" y="185" width="140" height="55" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="630" y="205" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">Shared State</text>
    <text x="630" y="220" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">AppState</text>
    <text x="630" y="232" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Configuration</text>

    <rect x="720" y="185" width="100" height="55" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="770" y="205" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">Utils</text>
    <text x="770" y="220" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Helpers</text>
    <text x="770" y="232" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Common</text>
  </g>

  <!-- Bidirectional Arrow -->
  <line x1="450" y1="260" x2="450" y2="290" stroke="#666" stroke-width="2" marker-end="url(#arrowhead)" opacity="0.6">
  <line x1="460" y1="290" x2="460" y2="260" stroke="#666" stroke-width="2" marker-end="url(#arrowhead)" opacity="0.6">

  <!-- Virtual Crates Layer (gbapps) -->
  <g id="gbapp-layer">
    <rect x="60" y="290" width="780" height="180" fill="#4B5563" fill-opacity="0.3" stroke="#2563EB" stroke-width="2" rx="8" filter="url(#shadow)">
    <text x="450" y="315" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="18" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">Virtual Crates (gbapp modules in src/)</text>

    <!-- BASIC gbapp -->
    <rect x="80" y="335" width="170" height="115" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="165" y="355" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">basic.gbapp</text>
    <text x="165" y="370" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">src/basic/</text>
    <line x1="90" y1="378" x2="240" y2="378" stroke="#2563EB" stroke-width="2">
    <text x="165" y="393" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">• BASIC Interpreter</text>
    <text x="165" y="408" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">• Keywords Registry</text>
    <text x="165" y="423" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">• Script Execution</text>
    <text x="165" y="438" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">• Rhai Engine</text>

    <!-- Channels gbapp -->
    <rect x="270" y="335" width="170" height="115" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="355" y="355" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">channels.gbapp</text>
    <text x="355" y="370" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">src/channels/</text>
    <line x1="280" y1="378" x2="430" y2="378" stroke="#2563EB" stroke-width="2">
    <text x="355" y="393" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">• WhatsApp</text>
    <text x="355" y="408" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">• Teams</text>
    <text x="355" y="423" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">• Email</text>
    <text x="355" y="438" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">• Web UI</text>

    <!-- Storage gbapp -->
    <rect x="460" y="335" width="170" height="115" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="545" y="355" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">storage.gbapp</text>
    <text x="545" y="370" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">src/storage/</text>
    <line x1="470" y1="378" x2="620" y2="378" stroke="#2563EB" stroke-width="2">
    <text x="545" y="393" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">• Knowledge Base</text>
    <text x="545" y="408" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">• Drive Integration</text>
    <text x="545" y="423" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">• Vector DB</text>
    <text x="545" y="438" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">• Cache</text>

    <!-- Custom gbapp (Your Contribution) -->
    <rect x="650" y="335" width="170" height="115" fill="#1F2937" stroke="#2563EB" stroke-width="2" rx="4" stroke-dasharray="5,3" filter="url(#shadow)">
    <text x="735" y="355" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">your_feature.gbapp</text>
    <text x="735" y="370" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">src/your_feature/</text>
    <line x1="660" y1="378" x2="810" y2="378" stroke="#2563EB" stroke-width="2">
    <text x="735" y="393" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-style="italic" fill="#4B5563" filter="url(#textShadow)">• Your Keywords</text>
    <text x="735" y="408" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-style="italic" fill="#4B5563" filter="url(#textShadow)">• Your Services</text>
    <text x="735" y="423" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-style="italic" fill="#4B5563" filter="url(#textShadow)">• Your Models</text>
    <text x="735" y="438" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">+ Add yours!</text>
  </g>

  <!-- Arrow from gbapp to AI -->
  <line x1="450" y1="470" x2="450" y2="500" stroke="#666" stroke-width="2" marker-end="url(#arrowhead)" opacity="0.6">

  <!-- AI/LLM Layer -->
  <g id="ai-layer">
    <rect x="60" y="500" width="380" height="80" fill="#4B5563" fill-opacity="0.3" stroke="#2563EB" stroke-width="2" rx="8" filter="url(#shadow)">
    <text x="250" y="525" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="16" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">AI &amp; LLM Integration</text>

    <rect x="80" y="535" width="100" height="35" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="130" y="555" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">LLM Service</text>

    <rect x="195" y="535" width="100" height="35" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="245" y="555" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Embeddings</text>

    <rect x="310" y="535" width="110" height="35" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="365" y="555" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Semantic Search</text>
  </g>

  <!-- Storage Layer -->
  <g id="storage-layer">
    <rect x="460" y="500" width="380" height="80" fill="#1F2937" fill-opacity="0.3" stroke="#2563EB" stroke-width="2" rx="8" filter="url(#shadow)">
    <text x="650" y="525" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="16" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">Persistence Layer</text>

    <rect x="480" y="535" width="85" height="35" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="522" y="555" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Database</text>

    <rect x="580" y="535" width="85" height="35" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="622" y="555" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Vector DB</text>

    <rect x="680" y="535" width="70" height="35" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="715" y="555" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Drive</text>

    <rect x="765" y="535" width="60" height="35" fill="white" stroke="#2563EB" stroke-width="2" rx="4" filter="url(#shadow)"/>
    <text x="795" y="555" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Cache</text>
  </g>

  <!-- Legend -->
  <g id="legend" transform="translate(60, 600)">
    <text x="0" y="0" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-weight="bold" fill="#4B5563" filter="url(#textShadow)">Key Concepts:</text>

    <rect x="120" y="-12" width="15" height="15" fill="#4B5563" stroke="#2563EB" stroke-width="2" rx="2" filter="url(#shadow)">
    <text x="140" y="0" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Virtual Crates = Modules in src/</text>

    <rect x="320" y="-12" width="15" height="15" fill="#1F2937" stroke="#2563EB" stroke-width="2" rx="2" stroke-dasharray="3,2" filter="url(#shadow)">
    <text x="340" y="0" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">Your Contribution Space</text>

    <text x="500" y="0" font-family="system-ui, -apple-system, sans-serif" font-size="14" fill="#4B5563" filter="url(#textShadow)">All compile to single optimized binary</text>
  </g>

  <!-- Philosophy Note -->
  <text x="450" y="650" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="14" font-style="italic" fill="#4B5563" filter="url(#textShadow)">gbapp virtual crates: The bridge between old Node.js packages and new Rust modules</text>


  </g>

</svg>