2025-09-16 14:22:14 +08:00
# AGENTS.md
## Project Overview
Dify is an open-source platform for developing LLM applications with an intuitive interface combining agentic AI workflows, RAG pipelines, agent capabilities, and model management.
2025-09-27 10:05:30 +08:00
The codebase is split into:
2025-09-16 14:22:14 +08:00
2025-09-27 10:05:30 +08:00
- **Backend API** (`/api` ): Python Flask application organized with Domain-Driven Design
- **Frontend Web** (`/web` ): Next.js 15 application using TypeScript and React 19
2025-09-16 14:22:14 +08:00
- **Docker deployment** (`/docker` ): Containerized deployment configurations
2025-09-27 10:05:30 +08:00
## Backend Workflow
2025-09-16 14:22:14 +08:00
2025-09-27 10:05:30 +08:00
- Run backend CLI commands through `uv run --project api <command>` .
2025-09-16 14:22:14 +08:00
2025-10-20 09:36:41 +08:00
- Before submission, all backend modifications must pass local checks: `make lint` , `make type-check` , and `uv run --project api --dev dev/pytest/pytest_unit_tests.sh` .
2025-09-16 14:22:14 +08:00
2025-09-27 10:05:30 +08:00
- Use Makefile targets for linting and formatting; `make lint` and `make type-check` cover the required checks.
- Integration tests are CI-only and are not expected to run in the local environment.
2025-09-16 14:22:14 +08:00
2025-09-27 10:05:30 +08:00
## Frontend Workflow
2025-09-16 14:22:14 +08:00
```bash
cd web
2025-09-27 10:05:30 +08:00
pnpm lint
pnpm lint:fix
pnpm test
2025-09-16 14:22:14 +08:00
```
2025-09-27 10:05:30 +08:00
## Testing & Quality Practices
2025-09-16 14:22:14 +08:00
2025-09-27 10:05:30 +08:00
- Follow TDD: red → green → refactor.
- Use `pytest` for backend tests with Arrange-Act-Assert structure.
- Enforce strong typing; avoid `Any` and prefer explicit type annotations.
- Write self-documenting code; only add comments that explain intent.
2025-09-16 14:22:14 +08:00
2025-09-27 10:05:30 +08:00
## Language Style
2025-09-16 14:22:14 +08:00
2025-09-27 10:05:30 +08:00
- **Python**: Keep type hints on functions and attributes, and implement relevant special methods (e.g., `__repr__` , `__str__` ).
- **TypeScript**: Use the strict config, lean on ESLint + Prettier workflows, and avoid `any` types.
2025-09-16 14:22:14 +08:00
2025-09-27 10:05:30 +08:00
## General Practices
2025-09-16 14:22:14 +08:00
2025-09-27 10:05:30 +08:00
- Prefer editing existing files; add new documentation only when requested.
- Inject dependencies through constructors and preserve clean architecture boundaries.
- Handle errors with domain-specific exceptions at the correct layer.
2025-09-16 14:22:14 +08:00
2025-09-27 10:05:30 +08:00
## Project Conventions
2025-09-16 14:22:14 +08:00
2025-09-27 10:05:30 +08:00
- Backend architecture adheres to DDD and Clean Architecture principles.
- Async work runs through Celery with Redis as the broker.
- Frontend user-facing strings must use `web/i18n/en-US/` ; avoid hardcoded text.