dify / CONTRIBUTING.md
Severian's picture
initial commit
a8b3f00
|
raw
history blame
9.92 kB

So you're looking to contribute to Dify - that's awesome, we can't wait to see what you do. As a startup with limited headcount and funding, we have grand ambitions to design the most intuitive workflow for building and managing LLM applications. Any help from the community counts, truly.

We need to be nimble and ship fast given where we are, but we also want to make sure that contributors like you get as smooth an experience at contributing as possible. We've assembled this contribution guide for that purpose, aiming at getting you familiarized with the codebase & how we work with contributors, so you could quickly jump to the fun part.

This guide, like Dify itself, is a constant work in progress. We highly appreciate your understanding if at times it lags behind the actual project, and welcome any feedback for us to improve.

In terms of licensing, please take a minute to read our short License and Contributor Agreement. The community also adheres to the code of conduct.

Before you jump in

Find an existing issue, or open a new one. We categorize issues into 2 types:

Feature requests:

  • If you're opening a new feature request, we'd like you to explain what the proposed feature achieves, and include as much context as possible. @perzeusss has made a solid Feature Request Copilot that helps you draft out your needs. Feel free to give it a try.

  • If you want to pick one up from the existing issues, simply drop a comment below it saying so.

    A team member working in the related direction will be looped in. If all looks good, they will give the go-ahead for you to start coding. We ask that you hold off working on the feature until then, so none of your work goes to waste should we propose changes.

    Depending on whichever area the proposed feature falls under, you might talk to different team members. Here's rundown of the areas each our team members are working on at the moment:

    Member Scope
    @yeuoly Architecting Agents
    @jyong RAG pipeline design
    @GarfieldDai Building workflow orchestrations
    @iamjoel & @zxhlyh Making our frontend a breeze to use
    @guchenhe & @crazywoola Developer experience, points of contact for anything
    @takatost Overall product direction and architecture

    How we prioritize:

    Feature Type Priority
    High-Priority Features as being labeled by a team member High Priority
    Popular feature requests from our community feedback board Medium Priority
    Non-core features and minor enhancements Low Priority
    Valuable but not immediate Future-Feature

Anything else (e.g. bug report, performance optimization, typo correction):

  • Start coding right away.

    How we prioritize:

    Issue Type Priority
    Bugs in core functions (cannot login, applications not working, security loopholes) Critical
    Non-critical bugs, performance boosts Medium Priority
    Minor fixes (typos, confusing but working UI) Low Priority

Installing

Here are the steps to set up Dify for development:

1. Fork this repository

2. Clone the repo

Clone the forked repository from your terminal:

git clone [email protected]:<github_username>/dify.git

3. Verify dependencies

Dify requires the following dependencies to build, make sure they're installed on your system:

4. Installations

Dify is composed of a backend and a frontend. Navigate to the backend directory by cd api/, then follow the Backend README to install it. In a separate terminal, navigate to the frontend directory by cd web/, then follow the Frontend README to install.

Check the installation FAQ for a list of common issues and steps to troubleshoot.

5. Visit dify in your browser

To validate your set up, head over to http://localhost:3000 (the default, or your self-configured URL and port) in your browser. You should now see Dify up and running.

Developing

If you are adding a model provider, this guide is for you.

If you are adding a tool provider to Agent or Workflow, this guide is for you.

To help you quickly navigate where your contribution fits, a brief, annotated outline of Dify's backend & frontend is as follows:

Backend

Dify’s backend is written in Python using Flask. It uses SQLAlchemy for ORM and Celery for task queueing. Authorization logic goes via Flask-login.

[api/]
β”œβ”€β”€ constants             // Constant settings used throughout code base.
β”œβ”€β”€ controllers           // API route definitions and request handling logic.           
β”œβ”€β”€ core                  // Core application orchestration, model integrations, and tools.
β”œβ”€β”€ docker                // Docker & containerization related configurations.
β”œβ”€β”€ events                // Event handling and processing
β”œβ”€β”€ extensions            // Extensions with 3rd party frameworks/platforms.
β”œβ”€β”€ fields                // field definitions for serialization/marshalling.
β”œβ”€β”€ libs                  // Reusable libraries and helpers.
β”œβ”€β”€ migrations            // Scripts for database migration.
β”œβ”€β”€ models                // Database models & schema definitions.
β”œβ”€β”€ services              // Specifies business logic.
β”œβ”€β”€ storage               // Private key storage.      
β”œβ”€β”€ tasks                 // Handling of async tasks and background jobs.
└── tests

Frontend

The website is bootstrapped on Next.js boilerplate in Typescript and uses Tailwind CSS for styling. React-i18next is used for internationalization.

[web/]
β”œβ”€β”€ app                   // layouts, pages, and components
β”‚   β”œβ”€β”€ (commonLayout)    // common layout used throughout the app
β”‚   β”œβ”€β”€ (shareLayout)     // layouts specifically shared across token-specific sessions 
β”‚   β”œβ”€β”€ activate          // activate page
β”‚   β”œβ”€β”€ components        // shared by pages and layouts
β”‚   β”œβ”€β”€ install           // install page
β”‚   β”œβ”€β”€ signin            // signin page
β”‚   └── styles            // globally shared styles
β”œβ”€β”€ assets                // Static assets
β”œβ”€β”€ bin                   // scripts ran at build step
β”œβ”€β”€ config                // adjustable settings and options 
β”œβ”€β”€ context               // shared contexts used by different portions of the app
β”œβ”€β”€ dictionaries          // Language-specific translate files 
β”œβ”€β”€ docker                // container configurations
β”œβ”€β”€ hooks                 // Reusable hooks
β”œβ”€β”€ i18n                  // Internationalization configuration
β”œβ”€β”€ models                // describes data models & shapes of API responses
β”œβ”€β”€ public                // meta assets like favicon
β”œβ”€β”€ service               // specifies shapes of API actions
β”œβ”€β”€ test                  
β”œβ”€β”€ types                 // descriptions of function params and return values
└── utils                 // Shared utility functions

Submitting your PR

At last, time to open a pull request (PR) to our repo. For major features, we first merge them into the deploy/dev branch for testing, before they go into the main branch. If you run into issues like merge conflicts or don't know how to open a pull request, check out GitHub's pull request tutorial.

And that's it! Once your PR is merged, you will be featured as a contributor in our README.

Getting Help

If you ever get stuck or got a burning question while contributing, simply shoot your queries our way via the related GitHub issue, or hop onto our Discord for a quick chat.