# derek2403/memest-cutest-platform architecture

> Architecture diagram of the GitHub repository derek2403/memest-cutest-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/derek2403/memest-cutest-platform
- Repository: https://github.com/derek2403/memest-cutest-platform

## Overview

##### Project’s Type & Purpose
- This project is a unified, full-stack platform that integrates both Web2 and Web3 services into one gamified and visually orchestrated interface.
- It enables users to connect multiple services (like MetaMask, 1inch, Polygon, Celo, Gmail, and Google Sheets) via drag-and-drop workflows and an AI agent that automates tasks.
- The platform is built with Next.js (React) for the frontend, Three.js for 3D visualization, and a backend component (the “mcp-server” directory) that manages event listening, email notifications, and blockchain interactions.

##### File Structure
- Frontend Code & User Interface:
– The “pages” directory shows several Next.js pages including key files like index.js (for the 3D environment) and API routes under “pages/api.”
– The “components” directory contains diverse React components (e.g., for wallet connections, UI navigation, visuals, and service blocks) that represent each integrated service.
– The “public” directory, along with “gltf,” “public/models,” “public/fbx,” and “public/assets,” holds 3D models and static assets used for the gamified UI.
- Backend/Server:
– The “mcp-server” folder contains the backend logic (server.js, workflow scripts, Dockerfile, and docker-compose.yml) which orchestrates service integrations and custom workflows.
- Utility & Configuration:
– Files like “next.config.mjs,” “tailwind.config.js,” and various JSON configuration files help set up the environment.
– The “utils” folder holds common assets (e.g., ABI definitions) for interacting with blockchain networks.
- Integration & Scripting:
– Several API endpoints in “pages/api” (such as claude-chat.js, parse-workflow.js, send-email.js) handle interactions between the frontend and backend.

A. Frontend (Client Side):
- Next.js UI & Pages:
- Pages like index, events, landing etc.
- React Components:
- Components that encapsulate service-specific logic (e.g., Wallet-related components, Service Blocks like one for 1inch, Polygon, Gmail, etc.).
- Drag-and-drop workflow interface that users interact with.
- 3D Assets & Models:
- Asset directories (“gltf,” “public/models,” “public/fbx”) that feed the 3D gamified interface.

B. Backend (Server Side):
- MCP Server:
- Backend server housed in “mcp-server” with its API endpoints, event listeners, and workflow processing (e.g., handling email notifications, and wallet events).
- Integration points such as Docker (Dockerfile, docker-compose.yml) to show containerization and deployment.
- API Routes:
- “pages/api” endpoints which serve as an orchestration layer linking the frontend to backend operations.

C. External Services & Blockchain Integrations:
- Wallet & Blockchain Services:
- External wallets (MetaMask, RainbowKit) and blockchain networks (Base, Sepolia, Polygon, Celo) connected using libraries like Wagmi, Ethers.js 6, and Viem.
- Web2 Integrations:
- Integrations with Gmail, Google Sheets (Spreadsheet), and other Web2 tools.
- AI-Driven Orchestration:
- A block for the AI agent that uses Anthropic AI SDK to interpret workflow instructions and manage cross-service communication.

##### Relationships & Data Flow
– From the Frontend (user interactions via the drag-and-drop interface) to API endpoints (in “pages/api”).
– From API endpoints to the Backend MCP server which listens for events and dispatches tasks.
– From the MCP server to the blockchain (via Ethers.js) for wallet event detection.
– Between external services (Gmail, Sheets, DEX aggregators like 1inch) and both the front- and backend layers.
- How the AI agent “walks” between service components to trigger actions.

##### Architectural Patterns & Design Principles
- Separation of concerns:
– The UI layer is isolated from the backend orchestration layer.
– API endpoints serve as an abstraction for business logic.
- Modular Design:
– Show how components can be replaced or extended (for example, new 3D assets or plugins in the future modular plugin system).
- Event-Driven Integration:
– Indicate how blockchain events, email notifications, and workflow triggers interconnect via the MCP server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        %% Next.js UI & Pages
        subgraph "Next.js UI & Pages"
            fp1("Index Page"):::frontend
            fp2("Landing Page"):::frontend
            fp3("Events Page"):::frontend
        end
        
        %% API Endpoints
        subgraph "API Endpoints"
            api1("claude-chat API"):::frontend
            api2("parse-workflow API"):::frontend
            api3("send-email API"):::frontend
        end
        
        %% React Components & Service Blocks
        subgraph "React Components"
            rc1("ConnectWallet Component"):::frontend
            rc2("WalletComponents"):::frontend
            rc3("WalletConnect Component"):::frontend
            rc4("metawallet Component"):::frontend
            rc5("1inch Component"):::frontend
            rc6("Polygon Component"):::frontend
            rc7("Celo Component"):::frontend
            rc8("Gmail Component"):::frontend
            rc9("Spreadsheet Component"):::frontend
            rc10("WorkflowGenerator Component"):::frontend
            rc11("WorkflowPopup Component"):::frontend
            rc12("AIAgent Component"):::frontend
        end
        
        %% 3D Visualization & Assets
        subgraph "3D Visualization & Assets"
            asset1("GLTF Assets"):::asset
            asset2("FBX Assets"):::asset
            asset3("3D Models"):::asset
        end
    end

    %% Backend Layer
    subgraph "Backend"
        %% MCP Server
        subgraph "MCP Server"
            bs1("Server Logic"):::backend
            bs2("Workflow Scripts"):::backend
            bs3("Event & Email Handlers"):::backend
        end
        
        %% Dockerization
        subgraph "Dockerization"
            bs4("Dockerfile"):::backend
            bs5("docker-compose"):::backend
        end
    end

    %% Utilities & Configurations
    subgraph "Utilities & Configurations"
        uc1("ABI Utilities"):::utility
        uc2("Build Configurations"):::utility
    end

    %% External Services & Integrations
    subgraph "External Services"
        ex1("Blockchain Networks"):::external
        ex2("Web2 Integrations"):::external
        ex3("AI-Driven Orchestration"):::external
    end

    %% Relationships & Data Flow
    %% Frontend pages call API endpoints
    fp1 -->|"calls"| api1
    fp2 -->|"calls"| api2
    fp3 -->|"calls"| api3

    %% API endpoints process requests through the backend server logic
    api1 -->|"processes"| bs1
    api2 -->|"processes"| bs1
    api3 -->|"processes"| bs1

    %% React Components interactions
    rc1 -->|"triggers"| ex1
    rc8 -->|"triggers"| ex2
    rc9 -->|"triggers"| ex2
    rc10 -->|"initiates"| api2
    rc11 -->|"triggers"| api2
    rc12 -->|"orchestrates"| ex3
    rc12 <-->|"sync"| ex3

    %% 3D Assets rendering in the UI
    asset1 -->|"renders"| fp1
    asset2 -->|"renders"| fp1
    asset3 -->|"renders"| fp1

    %% Backend interactions with external systems
    bs1 -->|"triggers"| ex1
    bs1 -->|"triggers"| ex2
    bs1 -->|"coordinates"| ex3

    %% Docker components support the MCP Server
    bs4 --> bs1
    bs5 --> bs1

    %% Utilities and Configurations used by Frontend and Backend
    uc1 -->|"provides ABI"| bs1
    uc2 -->|"configures"| fp1

    %% Click Events for Frontend (Next.js UI & Pages)
    click fp1 "https://github.com/derek2403/memest-cutest-platform/blob/main/pages/index.js"
    click fp2 "https://github.com/derek2403/memest-cutest-platform/blob/main/pages/landing.js"
    click fp3 "https://github.com/derek2403/memest-cutest-platform/blob/main/pages/events.js"
    
    %% Click Events for API Endpoints
    click api1 "https://github.com/derek2403/memest-cutest-platform/blob/main/pages/api/claude-chat.js"
    click api2 "https://github.com/derek2403/memest-cutest-platform/blob/main/pages/api/parse-workflow.js"
    click api3 "https://github.com/derek2403/memest-cutest-platform/blob/main/pages/api/send-email.js"
    
    %% Click Events for React Components
    click rc1 "https://github.com/derek2403/memest-cutest-platform/blob/main/components/ConnectWallet.js"
    click rc2 "https://github.com/derek2403/memest-cutest-platform/blob/main/components/WalletComponents.js"
    click rc3 "https://github.com/derek2403/memest-cutest-platform/blob/main/components/WalletConnect.js"
    click rc4 "https://github.com/derek2403/memest-cutest-platform/blob/main/components/metawallet.js"
    click rc5 "https://github.com/derek2403/memest-cutest-platform/blob/main/components/oneinch.js"
    click rc6 "https://github.com/derek2403/memest-cutest-platform/blob/main/components/polygon.js"
    click rc7 "https://github.com/derek2403/memest-cutest-platform/blob/main/components/celo.js"
    click rc8 "https://github.com/derek2403/memest-cutest-platform/blob/main/components/gmail.js"
    click rc9 "https://github.com/derek2403/memest-cutest-platform/blob/main/components/spreadsheet.js"
    click rc10 "https://github.com/derek2403/memest-cutest-platform/blob/main/components/WorkflowGenerator.js"
    click rc11 "https://github.com/derek2403/memest-cutest-platform/blob/main/components/WorkflowPopup.js"
    click rc12 "https://github.com/derek2403/memest-cutest-platform/blob/main/components/aiagent.js"
    
    %% Click Events for 3D Visualization & Assets
    click asset1 "https://github.com/derek2403/memest-cutest-platform/tree/main/gltf"
    click asset2 "https://github.com/derek2403/memest-cutest-platform/tree/main/public/fbx"
    click asset3 "https://github.com/derek2403/memest-cutest-platform/tree/main/public/models"
    
    %% Click Events for Backend (MCP Server & Docker)
    click bs1 "https://github.com/derek2403/memest-cutest-platform/blob/main/mcp-server/server.js"
    click bs2 "https://github.com/derek2403/memest-cutest-platform/blob/main/mcp-server/workflows.js"
    click bs4 "https://github.com/derek2403/memest-cutest-platform/tree/main/mcp-server/Dockerfile"
    click bs5 "https://github.com/derek2403/memest-cutest-platform/blob/main/mcp-server/docker-compose.yml"
    
    %% Click Event for Utilities & Configurations
    click uc1 "https://github.com/derek2403/memest-cutest-platform/blob/main/utils/abi.json"
    click uc2 "https://github.com/derek2403/memest-cutest-platform/blob/main/next.config.mjs"

    %% Styles
    classDef frontend fill:#d0e1f9,stroke:#0a3d62,stroke-width:2px;
    classDef backend fill:#d1f2eb,stroke:#239b56,stroke-width:2px;
    classDef utility fill:#fcf3cf,stroke:#b7950b,stroke-width:2px;
    classDef external fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef asset fill:#f5cba7,stroke:#a04000,stroke-width:2px;
```
