I've been asking gpt to use mermaid to diagram before writing the code. It seems to help produce better results.