# devitaliya22/autominds architecture

> Architecture diagram of the GitHub repository devitaliya22/autominds, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/devitaliya22/autominds
- Repository: https://github.com/devitaliya22/autominds

## Overview

##### Project Type and Purpose
- AutoMinds is a full-stack automation platform.
- It lets users connect multiple external apps and configure workflows. Triggers from one app (such as a new Google Doc or CSV file in GitHub) automatically trigger actions in another.
- The README emphasizes automated triggers, state management (using Zustand), real-time updates (using WebSockets on the workflow page), and integrations with external services.

##### Analyzing the File Structure
- The top-level structure includes configuration files (like .eslintrc.json, tsconfig.json, etc.), the Next.js configuration (next.config.mjs), and a public folder for static assets.
- The core code lives in the "src" folder, which is further divided into "app", "components", "api" (in src/app/api), "lib", "hooks", "store", and "types". This separation suggests a clear division between UI, business logic, and data access.
- Database interactions and schema management are handled using Prisma (prisma folder), where multiple migrations, a seed file, and the schema are located.
- There are dedicated API routes for external integrations (e.g., /api/auth, /api/github, /api/google, and /api/webhook) indicating that the backend is segmented into modules corresponding to each integration.

##### Key Components
a. Frontend:
- Next.js-based client UI hosted under src/app and src/components.
- Pages for connections, dashboards, and workflow editors.
- Global layout and state management (using Zustand as mentioned in the README and implemented in src/store).
- Real-time updates on the workflows page (likely using WebSocket connections).

b. API/Backend Services:
- Next.js API routes (in src/app/api) for handling all integrations:
- Authentication endpoints in /api/auth for NextAuth.
- Integration endpoints for GitHub (/api/github) and Google (/api/google) including specialized routes for Drive and Gmail, handling creation, updates, and webhooks.
- Webhook endpoints (/api/webhook) to process incoming trigger events from external services.
- Auth & user management using NextAuth (under src/app/api/auth/[...nextauth]).

c. Database:
- Managed via Prisma with its own schema (prisma/schema.prisma) and migrations.
- This serves as the source of truth storing user details, workflows, integrations, and other metadata.

d. External Services:
- Third-party APIs for Google (Drive, Gmail, etc.), GitHub, and potentially Discord.
- These interact with the API endpoints and trigger actions on the platform.

##### Architectural Patterns & Design Principles
- The project follows a clear separation of concerns:
- Frontend (UI/UX, client state with Zustand) is distinct from backend logic.
- API endpoints are modularly separated based on functionality/integration.
- Database operations abstracted through Prisma.
- The RESTful API endpoints and webhooks pattern allow for clean bidirectional communication between AutoMinds and external services.
- Emphasis on modularity: Breaking the workflows into triggers, actions, and reactions, each manageable through clearly defined API routes and components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        nf1["Next.js Pages & Layout"]:::frontend
        nf2["Components"]:::frontend
        nf3["Zustand State Management"]:::frontend
    end

    %% Backend API Layer
    subgraph "Backend API"
        ba1["Auth API (NextAuth)"]:::backend
        ba2["GitHub API Endpoints"]:::backend
        ba3["Google API Endpoints"]:::backend
        ba4["Webhook API Endpoints"]:::backend
    end

    %% Database
    db1["Prisma ORM/Database"]:::database

    %% External Services
    subgraph "External Services"
        ext1["Google Services (Drive/Gmail)"]:::external
        ext2["GitHub Services"]:::external
        ext3["Discord Services"]:::external
    end

    %% Connections from Frontend to Backend
    nf1 -->|"API_Call"| ba1
    nf1 -->|"API_Call"| ba2
    nf1 -->|"API_Call"| ba3
    nf1 -->|"API_Call"| ba4

    %% Backend to Database connections
    ba1 -->|"DataSync"| db1
    ba2 -->|"DataSync"| db1
    ba3 -->|"DataSync"| db1
    ba4 -->|"DataSync"| db1

    %% Backend to External Services connections
    ba2 -->|"Calls"| ext2
    ba3 -->|"Calls"| ext1
    ext3 -->|"Trigger"| ba4

    %% Real-time updates (WebSocket) from Backend to Frontend
    ba4 -->|"RealtimeUpdates"| nf1

    %% Click Events
    click nf1 "https://github.com/devitaliya22/autominds/blob/main/src/app/layout.tsx"
    click nf2 "https://github.com/devitaliya22/autominds/tree/main/src/components"
    click nf3 "https://github.com/devitaliya22/autominds/tree/main/src/store"
    click ba1 "https://github.com/devitaliya22/autominds/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click ba2 "https://github.com/devitaliya22/autominds/tree/main/src/app/api/github"
    click ba3 "https://github.com/devitaliya22/autominds/tree/main/src/app/api/google"
    click ba4 "https://github.com/devitaliya22/autominds/tree/main/src/app/api/webhook"
    click db1 "https://github.com/devitaliya22/autominds/tree/main/prisma"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef backend fill:#C4F1BE,stroke:#333,stroke-width:2px;
    classDef database fill:#FFD6A5,stroke:#333,stroke-width:2px;
    classDef external fill:#F9C5D1,stroke:#333,stroke-width:2px;
```
