$ show labring/FastGPT
FastGPT is a production-grade AI Agent building platform that enables users to create, deploy, and manage AI applications through a visual workflow editor. The system provides a full-stack solution including a Next.js frontend with Chakra UI, a comprehensive REST API layer, and a modular backend architecture. Core capabilities include a workflow engine with agent loops, tool calling, dataset (knowledge base) management with vector search, sandboxed code execution (JS/Python), multi-tenant team management with fine-grained permissions, billing and usage tracking, and integration with external platforms (WeChat, Feishu, Dingtalk, MCP). The platform is designed for both open-source community and commercial deployments, with feature gating via license activation. The codebase is organized as a monorepo with clear separation of concerns: shared types and constants in `packages/global`, business logic in `packages/service`, UI components in `packages/web`, data access layer in `packages/dal`, and separate services for sandbox execution and volume management. It relies on MongoDB, Redis, BullMQ, S3-compatible storage, and multiple vector database backends (PG, Milvus, OceanBase, SeekDB, OpenGauss). The architecture is predominantly monolithic with the main application as a Next.js app, but sandbox and volume manager run as independent services, indicating a hybrid monolith/microservices pattern.
The LLM identified 4 files worth highlighting for reuse:
A reusable BullMQ queue manager that provides a factory for creating and caching queues, lifecycle event listeners to prevent memory leaks, and graceful shutdown with timeout and force-disconnect fallback. It encapsulates Redis connection management, error handling, and queue reuse logic, making it extractable for any Node.js project needing reliable job queue management.
Defines the sandbox session interface with `checkSandboxSessionExist` and `keepaliveSandboxSession` functions, abstracting over multiple sandbox providers (OpenSandbox, Sealos Devbox). This pattern allows any application requiring ephemeral, isolated execution environments to manage session lifecycle without coupling to a specific provider implementation.
A memoized Markdown rendering component that shares a unified unified processor instance across renders, avoiding costly re-creation of plugins and parsers. It demonstrates a non-obvious performance optimization pattern for React applications that render dynamic Markdown content, and can be extracted as a standalone component.
Implements a Redis-backed fixed-window rate limiter with configurable window size and max requests. It provides a clean, reusable abstraction for rate limiting across different scenes (IP, team, outLink, upload) and can be extracted for any Node.js service needing distributed rate limiting without external dependencies beyond Redis.