System Design Diagrams with ChatGPT
Science & Technology
System Design Diagrams with ChatGPT
In an intriguing experiment, I requested ChatGPT to craft an architecture diagram for a web application. This exercise made me ponder the future of solutions architecture and how AI can significantly enhance architects' productivity. It's evident that AI can aid coding, yet programmers aren't being replaced by large language models (LLMs). While much discussion surrounds coding automation and AI-driven software development disruption, the impact on systems and applications design and architecture remains relatively unexplored. However, solution architects are not immune to AI disruption.
For this experiment, I used ChatGPT-4 and started with a basic high-level requirements prompt: "Design a simple architecture for an analytics dashboard web application where the frontend is built with React.js, the backend is microservices-based, and the database is PostgreSQL." The response was impressive.
Frontend and Backend Recommendations
For the frontend, ChatGPT suggested using REST APIs or GraphQL, Redux, and possibly D3 and Chart.js. Regarding the backend, it recommended each microservice have its own schema within the database, which is sound advice. It also emphasized that the database should only be accessed via the backend microservices.
The AI continued with additional recommendations, such as an API Gateway, security, logging, and monitoring. It even explained the flow system, which was quite useful.
Generating a Diagram
I then sought to generate a visual diagram for this architecture. ChatGPT is familiar with the "diagrams" package in Python, which allows architecture diagrams to be drawn with code. I copied and ran the code from ChatGPT, generating a draft architecture diagram. Interestingly, ChatGPT made some opinionated architecture decisions, such as incorporating an API Gateway and running services inside Docker containers without Kubernetes.
Prompting for refinements, I specified that the backend should comprise two microservices: user management and data analytics, with the analytics service being fast and utilizing caching. ChatGPT appropriately suggested using Redis for caching.
Decisions and Recommendations
The combination of a load balancer and API Gateway raised some questions. Asking ChatGPT for a refinement led to the suggestion of using only a load balancer, while noting that losing the API Gateway would mean missing out on some features, which would then need to be implemented within each service.
Next, I transformed the components to AWS-specific products and made further tweaks such as removing the load balancer and adding a database replica. This refined the diagram into a strong first draft of a high-level architecture.
Finally, I requested ChatGPT to provide the pros and cons of this architecture. It offered a detailed analysis that could be included in official architecture documentation, highlighting the immense productivity gains this AI tool can provide.
Minimizing Costs
When asked about minimizing costs, ChatGPT suggested using AWS Lambda, among other ideas I hadn't considered. This resulted in an updated diagram which, although susceptible to occasional hallucinations, proved valuable in the initial design stages. For instance, ChatGPT sometimes attempted to import non-existent libraries or generated odd architectural configurations.
Future Prospects
Imagine if major cloud providers like AWS, Google Cloud, and Azure offered LLM-based assistance to help solution architects. These providers have extensive access to architecture diagrams and documents, potentially enhanced by human-labelled data for fine-tuning.
GCP already offers an architecture diagramming tool with templates, hinting at a future where generative AI will integrate with such tools. These smart assistants could guide architects through options, refine ideas, and select optimal products and solutions for specific requirements.
I foresee a future where autonomous agents manage requirement gathering, architect solutions, design systems, code, deploy, and maintain them with minimal human intervention. AI could dynamically evolve architectures, potentially migrating a microservice from a container to a serverless function to reduce costs without affecting performance.
While the idea of self-adapting architectures controlled by AI poses significant challenges, its eventual necessity and inevitability are hard to ignore.
Keywords
- AI disruption
- Architecture diagrams
- ChatGPT-4
- Cloud providers
- Generative AI
- High-level requirements
- Microservices
- React.js
- Solutions architecture
- Systems design
FAQ
What was the main focus of the experiment with ChatGPT-4?
- The experiment aimed to explore how ChatGPT-4 can design an architecture diagram for a web application, and to discuss the implications of AI in the field of systems and application design.
What were the primary technologies and tools discussed?
- The experiment discussed React.js for the frontend, a microservices-based backend, PostgreSQL for the database, REST APIs, GraphQL, Redux, D3, Chart.js, Redis for caching, and various AWS services.
What suggestions did ChatGPT-4 make for minimizing costs?
- ChatGPT-4 proposed using AWS Lambda, among other ideas, to help reduce costs while maintaining performance.
What are the potential future developments mentioned in the article?
- Future developments may include autonomous agents for requirement gathering, solution architecture, system design, coding, deployment, and maintenance with minimal human intervention. There is also a possibility of AI dynamically evolving architectures.
What challenges do these future prospects pose?
- The biggest challenges include ensuring proper control and boxing of AI to prevent unintended consequences and managing the complexity of self-adapting architectures driven by AI.