the roadmap for adapt to modern tech for backend #21323

Open
opened 2026-02-21 20:11:59 -05:00 by yindo · 4 comments
Owner

Originally created by @asukaminato0721 on GitHub (Dec 28, 2025).

Originally assigned to: @asukaminato0721 on GitHub.

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

flask is painful, it missing type checker.

the roadmap:

  1. remove flask-sqlalchemy (doing) https://github.com/langgenius/dify/issues/24138
  2. remove reqparse -> BaseModel (doing) https://github.com/langgenius/dify/issues/27513
  3. remove api.model -> BaseModel (doing) https://github.com/langgenius/dify/pull/30388
  4. maybe change to https://luolingchun.github.io/flask-openapi3/latest/Quickstart/ since it's less hard, but also need to remove model
  5. adapt fastopenapi https://github.com/mr-fatalyst/fastopenapi (after 2 and 3) , so all the backend api endpoint style is fastapi-style
  6. ~~flask -> quart https://quart.palletsprojects.com/en/latest/how_to_guides/flask_migration/ (so move to async api) , this need to deal with all the flask plugin, may take long time. and may be optional. draft ~~https://github.com/langgenius/dify/pull/31784
  7. quart -> fastapi (currently final goal)

just use fastapi, use WSGI to mount flask.

2. Additional context or comments

this will take some time...

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @asukaminato0721 on GitHub (Dec 28, 2025). Originally assigned to: @asukaminato0721 on GitHub. ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. flask is painful, it missing type checker. the roadmap: 1. remove flask-sqlalchemy (doing) https://github.com/langgenius/dify/issues/24138 2. remove reqparse -> BaseModel (doing) https://github.com/langgenius/dify/issues/27513 3. remove api.model -> BaseModel (doing) https://github.com/langgenius/dify/pull/30388 4. ~~maybe change to https://luolingchun.github.io/flask-openapi3/latest/Quickstart/ since it's less hard, but also need to remove model~~ 5. ~~adapt fastopenapi https://github.com/mr-fatalyst/fastopenapi (after 2 and 3) , so all the backend api endpoint style is fastapi-style~~ 6. ~~flask -> quart https://quart.palletsprojects.com/en/latest/how_to_guides/flask_migration/ (so move to async api) , this need to deal with all the flask plugin, may take long time. and may be optional. draft ~~https://github.com/langgenius/dify/pull/31784 7. quart -> fastapi (currently final goal) just use fastapi, use WSGI to mount flask. ### 2. Additional context or comments this will take some time... ### 3. Can you help us with this feature? - [x] I am interested in contributing to this feature.
yindo added the 💪 enhancement label 2026-02-21 20:11:59 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 30, 2026):

Hi, @asukaminato0721. I'm Dosu, and I'm helping the Dify team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You proposed a roadmap to modernize the backend by replacing Flask components with more type-safe and async-friendly tools.
  • The plan includes removing flask-sqlalchemy and reqparse, adopting fastopenapi for APIs, migrating from Flask to Quart for async support, and eventually moving to FastAPI.
  • You acknowledged this would be a lengthy process and expressed interest in contributing.
  • There has been no further activity or comments on this issue since your initial proposal.

Next Steps:

  • Please let me know if this modernization plan is still relevant to the latest version of Dify by commenting on this issue.
  • If I do not hear back within 15 days, I will automatically close this issue to keep the backlog manageable.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Jan 30, 2026): Hi, @asukaminato0721. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog and am marking this issue as stale. **Issue Summary:** - You proposed a roadmap to modernize the backend by replacing Flask components with more type-safe and async-friendly tools. - The plan includes removing flask-sqlalchemy and reqparse, adopting fastopenapi for APIs, migrating from Flask to Quart for async support, and eventually moving to FastAPI. - You acknowledged this would be a lengthy process and expressed interest in contributing. - There has been no further activity or comments on this issue since your initial proposal. **Next Steps:** - Please let me know if this modernization plan is still relevant to the latest version of Dify by commenting on this issue. - If I do not hear back within 15 days, I will automatically close this issue to keep the backlog manageable. Thank you for your understanding and contribution!
Author
Owner

@shuv-amp commented on GitHub (Feb 3, 2026):

I've been reviewing the backend roadmap and the progress on removing flask-sqlalchemy. The Graph Engine in core/workflow still seems tightly coupled to the global db.session, which is likely a core factor in the session leaks mentioned in #24076.

I'd like to help unblock the FastAPI transition by refactoring the Graph Engine to use the Repository Pattern and Dependency Injection, carrying forward the goals from #20449. My plan is to draft a decoupled engine that can run independently of the Flask context, supported by a standalone unit test suite to prove isolation.

@asukaminato0721, since you're leading this, I'm happy to tackle this architectural piece if you're open to it!

@shuv-amp commented on GitHub (Feb 3, 2026): I've been reviewing the backend roadmap and the progress on removing flask-sqlalchemy. The Graph Engine in core/workflow still seems tightly coupled to the global db.session, which is likely a core factor in the session leaks mentioned in #24076. I'd like to help unblock the FastAPI transition by refactoring the Graph Engine to use the Repository Pattern and Dependency Injection, carrying forward the goals from #20449. My plan is to draft a decoupled engine that can run independently of the Flask context, supported by a standalone unit test suite to prove isolation. @asukaminato0721, since you're leading this, I'm happy to tackle this architectural piece if you're open to it!
Author
Owner

@dosubot[bot] commented on GitHub (Feb 3, 2026):

@crazywoola, the user is ready to help unblock the FastAPI transition by refactoring the Graph Engine to use the Repository Pattern and Dependency Injection, aiming to decouple it from the Flask context with a standalone test suite. Could you please assist them with this architectural effort?

@dosubot[bot] commented on GitHub (Feb 3, 2026): @crazywoola, the user is ready to help unblock the FastAPI transition by refactoring the Graph Engine to use the Repository Pattern and Dependency Injection, aiming to decouple it from the Flask context with a standalone test suite. Could you please assist them with this architectural effort?
Author
Owner

@asukaminato0721 commented on GitHub (Feb 5, 2026):

I've been reviewing the backend roadmap and the progress on removing flask-sqlalchemy. The Graph Engine in core/workflow still seems tightly coupled to the global db.session, which is likely a core factor in the session leaks mentioned in #24076.

I'd like to help unblock the FastAPI transition by refactoring the Graph Engine to use the Repository Pattern and Dependency Injection, carrying forward the goals from #20449. My plan is to draft a decoupled engine that can run independently of the Flask context, supported by a standalone unit test suite to prove isolation.

@asukaminato0721, since you're leading this, I'm happy to tackle this architectural piece if you're open to it!

yeah, go ahead.

@asukaminato0721 commented on GitHub (Feb 5, 2026): > I've been reviewing the backend roadmap and the progress on removing flask-sqlalchemy. The Graph Engine in core/workflow still seems tightly coupled to the global db.session, which is likely a core factor in the session leaks mentioned in [#24076](https://github.com/langgenius/dify/issues/24076). > > I'd like to help unblock the FastAPI transition by refactoring the Graph Engine to use the Repository Pattern and Dependency Injection, carrying forward the goals from [#20449](https://github.com/langgenius/dify/issues/20449). My plan is to draft a decoupled engine that can run independently of the Flask context, supported by a standalone unit test suite to prove isolation. > > [@asukaminato0721](https://github.com/asukaminato0721), since you're leading this, I'm happy to tackle this architectural piece if you're open to it! yeah, go ahead.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21323