Hey there!
In this guide, you’ll build a web app that converts plain English into visual diagrams. The app uses a React frontend, a FastAPI backend and the Kroki API to turn generated diagram code into SVG or PNG images.
By the end, you’ll have a clean interface where users type a description, choose a diagram type and instantly see a rendered diagram. It’s fast, lean and surprisingly simple once you understand the flow.
Exact Prompt to Use
Paste this directly into Emergent:
System Overview
The frontend runs on React with Tailwind and shadcn/ui, giving you a fast, modern interface.
The backend runs on FastAPI and handles all text parsing.
Kroki does the heavy lifting by converting diagram code into images.
Flow:
The user types a description.
The backend generates diagram code.
The frontend sends the code to Kroki.
Kroki returns an SVG.
The preview updates instantly.
Core Features
The interface includes a text panel for natural language input, a dropdown to select GraphViz, Mermaid or PlantUML and a preview window that displays the rendered SVG. Users can switch between preview and raw code, zoom into diagrams, toggle themes and export to PNG by re-calling Kroki’s PNG endpoint.
The backend handles all parsing. Start with simple regex: split sentences, detect “if…then…” patterns and sanitize labels. Convert the cleaned structure into diagram syntax and return it. Each diagram type needs its own small generator function.
Implementation Notes
Make sure you only read the fetch response body once on the frontend.
Always use
returnafter sending a FastAPI response to avoid hitting fallback logic.Escape quotes and remove special characters before generating diagram code.
If SVGs show up with zero width or height, override those styles with CSS.
And don’t forget CORS—your frontend won’t reach the API without it.
Common Issues
You may see spacing issues with Select components in shadcn/ui; reduce padding or simplify the label.
If your diagram fails to render, test the generated code directly on Kroki—it’s the fastest way to find syntax errors.
If theme toggling doesn’t persist, store it in localStorage and apply it on initial load.
Make sure the layout adapts to mobile by using Tailwind responsive utilities.
Optional Improvements
You can extend the app with more diagram types, autosave, side-by-side editing, or real-time previews as the user types. Once the core flow works, it’s easy to iterate.
Wrapping Up
That is it.
You now have a well structured Natural Language to Diagram Generator running on Emergent.
You described the requirements and Emergent generated:
the backend parsing logic
the diagram code generator
the React interface
the Kroki rendering workflow
the export tools
Once deployed, your generator is live and ready to explore. Check out our published app at https://textflow-74.emergent.host/

