# Technical Architecture

AgentsLab is built on a modern Web3 technology stack that seamlessly integrates frontend interaction, on-chain smart contracts, data indexing, and decentralized storage. The result is a scalable, modular, and autonomous AI platform.

#### 3.1 Frontend Interface

* **Framework**: Built with **Next.js** for hybrid static and server-side rendering, ensuring fast performance and SEO optimization.
* **Styling**: Uses **TailwindCSS** for atomic, utility-first styling and responsive design.
* **Wallet Integration**: Powered by **Wagmi + RainbowKit**, supporting major wallets like MetaMask and WalletConnect for seamless Web3 connectivity.
* **Agent Builder UI**: Offers a no-code, visual interface for configuring personality training, behavior logic, model selection, and event triggers.

#### 3.2 Smart Contracts

* **Languages**: Core contracts are written in **Solidity**, with some security-critical logic implemented in **Vyper**.
* **Deployment Networks**: Initially deployed on **Ethereum**, with multichain compatibility for networks like Arbitrum, Base, and Polygon.
* **Contract Modules** include:
  * `AgentFactory.sol`: Handles creation and registration of agents with unique AgentIDs.
  * `TokenLauncher.sol`: Enables one-click meme-style token deployment.
  * `Governance.sol`: Implements proposal voting and feature access via $AL token.
  * `Marketplace.sol`: Supports agent listing, invocation, and trading.
  * `Permission.sol`: Manages access control and execution permissions for agents.

#### 3.3 Data Layer

* **Indexing**: Utilizes **The Graph** to build subgraphs that index:
  * Agent creation and invocation history
  * Token issuance records
  * Plugin usage logs
  * User-agent interaction events
* **Query Layer**: Exposes a GraphQL API for frontend and third-party developers, with support for filtering, pagination, and real-time subscriptions.

#### 3.4 Storage Layer

* **Agent Logic & Memory**: Long-term agent data, including behavior logic, training snapshots, and memory states, is stored via:
  * **IPFS**: For storing logic files, metadata, and plugin manifests.
  * **Arweave**: For immutable and auditable records of agent creation and update history.
* **Model Snapshots**: Agent model presets (e.g., initial prompts, personalities) are stored off-chain, cryptographically linked to AgentIDs.

#### 3.5 Agent Runtime Layer *(Upcoming)*

* **Agent Execution VM**: Future integration of lightweight sandboxes for hybrid on/off-chain reasoning and execution.
* **A2A Protocol (Agent-to-Agent)**: Enables agents to invoke and collaborate with each other, supporting multi-agent intelligent workflows.
