document/content/docs/self-host/dev.en.mdx
import { Alert } from '@/components/docs/Alert'; import FastGPTLink from '@/components/docs/linkFastGPT';
This guide covers how to set up your development environment to build and test <FastGPTLink>FastGPT</FastGPTLink>.
Install and configure these dependencies on your machine to build <FastGPTLink>FastGPT</FastGPTLink>:
We recommend developing on *nix environments (Linux, macOS, Windows WSL).
Fork the FastGPT repository.
Clone your forked repository from GitHub:
git clone [email protected]:<your_github_username>/FastGPT.git
If you're already running FastGPT locally via Docker, stop it first to avoid port conflicts.
Navigate to FastGPT/deploy/dev and run docker compose up -d to start FastGPT's dependencies:
cd FastGPT/deploy/dev
docker compose up -d
All files below are in the projects/app directory.
# Make sure you're in projects/app
pwd
# Should output /xxxx/xxxx/xxx/FastGPT/projects/app
1. Environment Variables
Copy .env.template to create .env.local in the same directory. Only changes in .env.local take effect.
See .env.template for variable descriptions.
If you haven't modified variables in docker-compose.yaml, the defaults in .env.template work as-is. Otherwise, match the values in your yml file.
cp .env.template .env.local
2. config.json Configuration File
Copy data/config.json to create data/config.local.json. For detailed parameters, see Configuration Guide.
cp data/config.json data/config.local.json
This file usually doesn't need changes. Key systemEnv parameters:
vectorMaxProcess: Max vector generation processes. Depends on database and key concurrency — for a 2c4g server, set to 10–15.qaMaxProcess: Max QA generation processesvlmMaxProcess: Max image understanding model processeshnswEfSearch: Vector search parameter (PG and OB only). Higher values = better accuracy but slower speed.See dev.md in the project root. The first compile may take a while — be patient.
# Run from the code root directory to install all dependencies
# If isolate-vm installation fails, see: https://github.com/laverdet/isolated-vm?tab=readme-ov-file#requirements
pwd # Should be in the code root directory
pnpm i
cd projects/app
pnpm dev
Next.js runs on port 3000 by default. Visit http://localhost:3000
We recommend using Docker for builds.
# Without proxy
docker build -f ./projects/app/Dockerfile -t fastgpt . --build-arg name=app
# With Taobao proxy
docker build -f ./projects/app/Dockerfile -t fastgpt. --build-arg name=app --build-arg proxy=taobao
Without Docker, you'd need to manually execute all the run-stage commands from the Dockerfile (not recommended).
If you run into issues like merge conflicts, check GitHub's pull request tutorial. Once your PR is merged, you'll be listed in the contributors table.
If your default timezone is Asia/Shanghai, system time may be incorrect in non-Linux environments. For local development, change your timezone to UTC (+0).
host to localhost or 127.0.0.1.directConnection=true to connect to replica sets.mongocompass for MongoDB connection testing and visual management.navicat for PostgreSQL connection and management.FastGPT runs a postinstall script after pnpm i to auto-generate ChakraUI types. If you get a permission error, run chmod -R +x ./scripts/ first, then pnpm i.
If that doesn't work, manually execute the contents of ./scripts/postinstall.sh.
On Windows, use git bash to add execute permissions and run the script.
Delete all node_modules and reinstall with Node 18 — newer Node versions may have issues. Local dev workflow:
pnpm iconfig.json -> config.local.json.env.template -> .env.localcd projects/apppnpm devThis may be caused by leftover files from a previous container stop. Make sure all related containers are stopped, then manually delete the files or restart Docker.
Having trouble? Join the Lark group to connect with developers and users.
FastGPT uses Next.js page routing. To separate frontend and backend code, directories are split into global, service, and web subdirectories for shared, backend-only, and frontend-only code respectively.
FastGPT uses pnpm workspace for its monorepo structure, with two main parts:
FastGPT's code modules follow DDD principles, divided into these domains:
.
├── .github // GitHub config
├── .husky // Formatting config
├── document // Documentation
├── files // External files, e.g., docker-compose, helm
├── packages // Subpackages
│ ├── global // Frontend/backend shared subpackage
│ ├── plugins // Workflow plugins (for custom packages)
│ ├── service // Backend subpackage
│ └── web // Frontend subpackage
├── projects
│ └── app // FastGPT main project
├── python // Model code, unrelated to FastGPT itself
└── scripts // Automation scripts
├── icon // Icon scripts: pnpm initIcon (write SVG to code), pnpm previewIcon (preview icons)
└── postinstall.sh // ChakraUI custom theme TS type initialization
├── package.json // Top-level monorepo
├── pnpm-lock.yaml
├── pnpm-workspace.yaml // Monorepo declaration
├── Dockerfile
├── LICENSE
├── README.md
├── README_en.md
├── README_ja.md
├── dev.md