# keplar-404/relie-deep-agent architecture

> Architecture diagram of the GitHub repository keplar-404/relie-deep-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/keplar-404/relie-deep-agent
- Repository: https://github.com/keplar-404/relie-deep-agent

## Overview

Relie AI is a natural-language web engineering IDE: users create projects, upload materials, and chat with an agent that edits and verifies applications in isolated sandboxes, then view a live preview. The main request path is the agent API through workflow selection into an agent configured with routing, tools, and persistent graph state. Separate branches cover project lifecycle, uploads, visual asset extraction, and preview. The README documents additional agent safeguards and routing capabilities; unsampled implementation details are represented only where the tree or documentation supports them.

Main entry points: [`src/app/api/v1/agent/route.ts`](https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/api/v1/agent/route.ts) (Agent API), [`src/lib/agent/index.ts`](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/index.ts) (Agent Core), [`src/app/(app)/chat/[...slug]/page.tsx`](https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/(app)/chat/%5B...slug%5D/page.tsx) (Chat and IDE), [`src/app/api/v1/project/route.ts`](https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/api/v1/project/route.ts) (Project API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web IDE"]
  node_ide["Chat and IDE<br/>[page.tsx]"]
  node_projects_ui["Projects UI<br/>[page.tsx]"]
  node_preview["Live Preview<br/>[page.tsx]"]
end

subgraph group_api["Application API"]
  node_agent_api["Agent API<br/>[route.ts]"]
  node_project_api["Project API<br/>[route.ts]"]
  node_upload_api["Upload API<br/>[route.ts]"]
  node_auth["User Resolver<br/>[currentUser.ts]"]
end

subgraph group_agent["Agent Execution"]
  node_workflow["Workflow Selection<br/>[index.ts]"]
  node_router["Intent and Tool Routing<br/>[index.ts]"]
  node_agent_core["Agent Core<br/>[index.ts]"]
  node_agent_tools["Agent Tools<br/>[index.ts]"]
  node_asset_tool["Asset Extraction<br/>[engine.ts]"]
  node_screenshot_tool["Screenshot Verification"]
end

subgraph group_sandbox["Sandbox and Media"]
  node_sandbox_create["Sandbox Provisioning<br/>[index.ts]"]
  node_sandbox_fs["Sandbox Filesystem<br/>[index.ts]"]
  node_file_processor["File Ingestion<br/>[fileProcessor.ts]"]
end

subgraph group_data["Persistence"]
  node_db_actions["Project and Chat Actions<br/>[index.ts]"]
  node_db[("Neon Postgres<br/>[drizzle.ts]")]
  node_object_storage["Object Storage<br/>[index.ts]"]
end

node_user(("User"))
node_llm["Vision LLM"]
node_daytona["Daytona Sandbox"]
node_s3[("Neon S3 Storage")]

node_user -->|"uses"| node_ide
node_ide -->|"sends prompt"| node_agent_api
node_ide -->|"uploads files"| node_upload_api
node_projects_ui -->|"manages projects"| node_project_api
node_agent_api -->|"resolves user"| node_auth
node_project_api -->|"resolves user"| node_auth
node_upload_api -->|"resolves user"| node_auth
node_agent_api -->|"reads project; writes chat"| node_db_actions
node_agent_api -->|"runs workflow"| node_workflow
node_workflow -->|"selects route"| node_router
node_workflow -->|"runs agent"| node_agent_core
node_router -.->|"classifies and selects"| node_llm
node_agent_core -->|"dispatches tools"| node_agent_tools
node_agent_core -->|"dispatches tool"| node_asset_tool
node_agent_core -->|"dispatches tool"| node_screenshot_tool
node_agent_tools -->|"operates files"| node_sandbox_fs
node_sandbox_fs -->|"calls sandbox"| node_daytona
node_sandbox_create -->|"provisions sandbox"| node_daytona
node_project_api -->|"creates sandbox"| node_sandbox_create
node_project_api -->|"creates or deletes project"| node_db_actions
node_asset_tool -->|"locates assets"| node_llm
node_asset_tool -->|"uploads crops"| node_object_storage
node_screenshot_tool -->|"captures preview"| node_daytona
node_upload_api -->|"writes upload"| node_s3
node_object_storage -->|"stores assets"| node_s3
node_file_processor -->|"processes attachments"| node_agent_api
node_db_actions -->|"reads and writes"| node_db
node_agent_core -->|"persists graph state"| node_db
node_agent_api -->|"returns response"| node_ide
node_ide -->|"shows sandbox preview"| node_preview
node_daytona -.->|"serves signed preview"| node_preview

click node_ide "https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/(app)/chat/%5B...slug%5D/page.tsx"
click node_projects_ui "https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/(app)/projects/page.tsx"
click node_agent_api "https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/api/v1/agent/route.ts"
click node_project_api "https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/api/v1/project/route.ts"
click node_upload_api "https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/api/v1/upload/route.ts"
click node_auth "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/auth/currentUser.ts"
click node_workflow "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/agentWorkflow/index.ts"
click node_router "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/agentRouter/index.ts"
click node_agent_core "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/index.ts"
click node_agent_tools "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/tools/fsOperations/index.ts"
click node_asset_tool "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/tools/assetExtraction/engine.ts"
click node_screenshot_tool "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/tools/sandboxcodeprescreenshottool.ts"
click node_sandbox_create "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/sandbox/index.ts"
click node_sandbox_fs "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/sandbox/fileOperation/index.ts"
click node_file_processor "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/utils/fileProcessor.ts"
click node_preview "https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/(app)/chat/%5B...slug%5D/page.tsx"
click node_db_actions "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/db/action/index.ts"
click node_db "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/db/drizzle.ts"
click node_object_storage "https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/objectStorage/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ide,node_projects_ui,node_preview,node_user toneBlue
class node_agent_api,node_project_api,node_upload_api,node_auth,node_s3 toneAmber
class node_workflow,node_router,node_agent_core,node_agent_tools,node_asset_tool,node_screenshot_tool toneMint
class node_sandbox_create,node_sandbox_fs,node_file_processor toneRose
class node_db_actions,node_db,node_object_storage,node_llm,node_daytona toneIndigo
```

## Components

### Web IDE

- [Chat and IDE](https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/(app)/chat/%5B...slug%5D/page.tsx): `src/app/(app)/chat/[...slug]/page.tsx`
- [Projects UI](https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/(app)/projects/page.tsx): `src/app/(app)/projects/page.tsx`
- [Live Preview](https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/(app)/chat/%5B...slug%5D/page.tsx): `src/app/(app)/chat/[...slug]/page.tsx`

### Application API

- [Agent API](https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/api/v1/agent/route.ts): `src/app/api/v1/agent/route.ts`
- [Project API](https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/api/v1/project/route.ts): `src/app/api/v1/project/route.ts`
- [Upload API](https://github.com/keplar-404/relie-deep-agent/blob/main/src/app/api/v1/upload/route.ts): `src/app/api/v1/upload/route.ts`
- [User Resolver](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/auth/currentUser.ts): `src/lib/auth/currentUser.ts`

### Agent Execution

- [Workflow Selection](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/agentWorkflow/index.ts): `src/lib/agent/agentWorkflow/index.ts`
- [Intent and Tool Routing](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/agentRouter/index.ts): `src/lib/agent/agentRouter/index.ts`
- [Agent Core](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/index.ts): `src/lib/agent/index.ts`
- [Agent Tools](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/tools/fsOperations/index.ts): `src/lib/agent/tools/fsOperations/index.ts`
- [Asset Extraction](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/tools/assetExtraction/engine.ts): `src/lib/agent/tools/assetExtraction/engine.ts`
- [Screenshot Verification](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/agent/tools/sandboxcodeprescreenshottool.ts): `src/lib/agent/tools/sandboxcodeprescreenshottool.ts`

### Sandbox and Media

- [Sandbox Provisioning](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/sandbox/index.ts): `src/lib/sandbox/index.ts`
- [Sandbox Filesystem](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/sandbox/fileOperation/index.ts): `src/lib/sandbox/fileOperation/index.ts`
- [File Ingestion](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/utils/fileProcessor.ts): `src/lib/utils/fileProcessor.ts`

### Persistence

- [Project and Chat Actions](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/db/action/index.ts): `src/lib/db/action/index.ts`
- [Neon Postgres](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/db/drizzle.ts): `src/lib/db/drizzle.ts`
- [Object Storage](https://github.com/keplar-404/relie-deep-agent/blob/main/src/lib/objectStorage/index.ts): `src/lib/objectStorage/index.ts`

### Other components

- **User**
- **Vision LLM**
- **Daytona Sandbox**
- **Neon S3 Storage**

## Connections

- User → Chat and IDE: uses
- Chat and IDE → Agent API: sends prompt
- Chat and IDE → Upload API: uploads files
- Projects UI → Project API: manages projects
- Agent API → User Resolver: resolves user
- Project API → User Resolver: resolves user
- Upload API → User Resolver: resolves user
- Agent API → Project and Chat Actions: reads project; writes chat
- Agent API → Workflow Selection: runs workflow
- Workflow Selection → Intent and Tool Routing: selects route
- Workflow Selection → Agent Core: runs agent
- Intent and Tool Routing → Vision LLM: classifies and selects
- Agent Core → Agent Tools: dispatches tools
- Agent Core → Asset Extraction: dispatches tool
- Agent Core → Screenshot Verification: dispatches tool
- Agent Tools → Sandbox Filesystem: operates files
- Sandbox Filesystem → Daytona Sandbox: calls sandbox
- Sandbox Provisioning → Daytona Sandbox: provisions sandbox
- Project API → Sandbox Provisioning: creates sandbox
- Project API → Project and Chat Actions: creates or deletes project
- Asset Extraction → Vision LLM: locates assets
- Asset Extraction → Object Storage: uploads crops
- Screenshot Verification → Daytona Sandbox: captures preview
- Upload API → Neon S3 Storage: writes upload
- Object Storage → Neon S3 Storage: stores assets
- File Ingestion → Agent API: processes attachments
- Project and Chat Actions → Neon Postgres: reads and writes
- Agent Core → Neon Postgres: persists graph state
- Agent API → Chat and IDE: returns response
- Chat and IDE → Live Preview: shows sandbox preview
- Daytona Sandbox → Live Preview: serves signed preview
