@@ -11,9 +11,10 @@ This document provides a comprehensive overview of the LangGraph.js AI Agent Tem
11115 . [ Agent Workflow] ( #agent-workflow )
12126 . [ MCP Integration] ( #mcp-integration )
13137 . [ Tool Approval Process] ( #tool-approval-process )
14- 8 . [ Streaming Architecture] ( #streaming-architecture )
15- 9 . [ Error Handling] ( #error-handling )
16- 10 . [ Performance Considerations] ( #performance-considerations )
14+ 8 . [ File Upload & Storage] ( #file-upload--storage )
15+ 9 . [ Streaming Architecture] ( #streaming-architecture )
16+ 10 . [ Error Handling] ( #error-handling )
17+ 11 . [ Performance Considerations] ( #performance-considerations )
1718
1819## 🌐 System Overview
1920
@@ -52,14 +53,14 @@ This document provides a comprehensive overview of the LangGraph.js AI Agent Tem
5253 │
5354 Database/Network
5455 │
55- ┌─────────────────────────────────────────────────────────────────┐
56- │ External Systems │
57- ├─────────────────────────────────────────────────────────────────┤
58- │ ┌───────────────── ┐ ┌─────────────────┐ ┌─────────────────┐ │
59- │ │ PostgreSQL │ │ OpenAI/Google │ │ MCP Servers │ │
60- │ │ (Persistence) │ │ (LLM APIs) │ │ (Tools) │ │
61- │ └───────────────── ┘ └─────────────────┘ └─────────────────┘ │
62- └─────────────────────────────────────────────────────────────────┘
56+ ┌───────────────────────────────────────────────────────────────────────────── ┐
57+ │ External Systems │
58+ ├───────────────────────────────────────────────────────────────────────────── ┤
59+ │ ┌─────────────┐ ┌─────────────┐ ┌ ───────────── ┐ ┌──── ─────────────────┐ │
60+ │ │ PostgreSQL │ │OpenAI/Google│ │ MCP Servers │ │ MinIO/S3 (Storage) │ │
61+ │ │(Persistence)│ │ (LLM APIs) │ │ (Tools) │ │ (File Uploads) │ │
62+ │ └─────────────┘ └─────────────┘ └ ───────────── ┘ └──── ─────────────────┘ │
63+ └───────────────────────────────────────────────────────────────────────────── ┘
6364```
6465
6566### Technology Stack
@@ -79,6 +80,7 @@ This document provides a comprehensive overview of the LangGraph.js AI Agent Tem
7980- ** Prisma ORM** : Type-safe database access
8081- ** PostgreSQL** : Primary database
8182- ** Server-Sent Events** : Real-time streaming
83+ - ** MinIO/S3** : Object storage for file uploads
8284
8385#### AI & Tools
8486
@@ -471,6 +473,72 @@ Database MCPServer → getMCPServerConfigs() → MultiServerMCPClient → Agent
4714734 . ** Name Prefixing** : Add server name prefix to prevent conflicts
4724745 . ** Agent Binding** : Bind tools to language model
473475
476+ ## 📁 File Upload & Storage
477+
478+ The application supports multimodal AI conversations through file uploads. Files are stored in S3-compatible storage (MinIO for development) and processed for AI consumption.
479+
480+ ### Upload Flow
481+
482+ ```
483+ User → MessageInput → Upload API → MinIO/S3 → File Metadata
484+ ↓
485+ Agent Request ← processAttachmentsForAI ← Download & Convert to Base64
486+ ```
487+
488+ ### Supported File Types
489+
490+ | Type | Extensions | Max Size | AI Processing |
491+ | --------- | ---------- | -------- | --------------------- |
492+ | Images | PNG, JPEG | 10MB | Base64 data URL |
493+ | Documents | PDF | 32MB | Base64 data URL |
494+ | Text | MD, TXT | 1MB | UTF-8 text extraction |
495+
496+ ### Key Components
497+
498+ #### Upload Endpoint (` src/app/api/agent/upload/route.ts ` )
499+
500+ Handles file validation and storage:
501+
502+ - Validates MIME type and file size
503+ - Handles ` application/octet-stream ` for text files by extension
504+ - Uploads to MinIO/S3 with unique keys
505+ - Returns file metadata (URL, key, name, type, size)
506+
507+ #### Storage Utilities (` src/lib/storage/ ` )
508+
509+ - ** s3-client.ts** : AWS SDK S3 client configuration
510+ - ** upload.ts** : Upload functions with multipart support for large files
511+ - ** validation.ts** : File type and size validation rules
512+ - ** content.ts** : File processing for AI (base64 conversion, text extraction)
513+
514+ #### Multimodal Message Building (` src/services/agentService.ts ` )
515+
516+ ``` typescript
517+ if (opts ?.attachments && opts .attachments .length > 0 ) {
518+ const attachmentContents = await processAttachmentsForAI (opts .attachments );
519+ messageContent = [{ type: " text" , text: userText }, ... attachmentContents ];
520+ }
521+ ```
522+
523+ ### Storage Architecture
524+
525+ ```
526+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
527+ │ MessageInput │────►│ Upload API │────►│ MinIO/S3 │
528+ │ (File Select) │ │ (Validation) │ │ (Storage) │
529+ └─────────────────┘ └─────────────────┘ └─────────────────┘
530+ │
531+ ▼
532+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
533+ │ LangChain │◄────│ processAttach- │◄────│ Download & │
534+ │ HumanMessage │ │ mentsForAI() │ │ Base64 Convert │
535+ └─────────────────┘ └─────────────────┘ └─────────────────┘
536+ ```
537+
538+ ### Production Migration
539+
540+ The storage layer uses AWS SDK v3, which works with any S3-compatible service. To switch from MinIO to production storage (AWS S3, Cloudflare R2, etc.), update the environment variables - no code changes required.
541+
474542## ✅ Tool Approval Process
475543
476544### User Interface Flow
0 commit comments