ChatGPT and the Evolution of Software Architecture

Tarasov Aleksandr
3 min readApr 28, 2023
Photo by Alex Knight on Unsplash

The other day, I conversed with a friend about the current trends in software architecture. I unexpectedly found myself saying to her, “The more code you can write with ChatGPT, the better your architecture is.” It might seem like a bold statement, but let me explain. As an AI language model developed by OpenAI, ChatGPT has revolutionized how I write code, with roughly 30–40% of my code now generated by it. But how does this relate to software architecture, and why does it matter? Let’s explore the seamless connection between these two.

A state-of-art software architecture should allow ChatGPT to generate code with minimal context. That’s where microservices (micro-frontends) excel and leave monolithic applications far behind once again. By breaking a complex system into smaller, more focused components, microservices make it easier for ChatGPT to generate relevant code snippets.

Let’s consider an example. When providing a prompt to ChatGPT, you might need to give some code snippets to help it understand the style or specific libraries (internal and external) you’re using. However, if your architecture is already modular and well-organized, you’ll need to provide less code to set the context, making it easier for ChatGPT to generate the desired output. For instance, if you have a microservice that handles user authentication, you might only need to provide a short example of how your authentication library is being used. ChatGPT can quickly grasp the context and generate code seamlessly, integrating with your existing codebase.

Of course, Copilot X, for instance, can use the context from the code in your IDE. Potentially it can fix the issue with a significant context, but still, the less context it requires to solve a task, the better the results you should achieve. However, it’s essential to remember that it’s not guaranteed to fix the problem with messy code. So, as a developer, you still need to validate the results, emphasizing clean code principles’ importance in this AI-driven development era.

I told with another friend who once mentioned that he couldn’t use ChatGPT because his code was a mess, making it hard to provide the proper context. In such cases, good old-fashioned design patterns, like the Strategy, Command, or Chain of Responsibility patterns, come to the rescue. Applying such patterns helps ChatGPT understand the context and generate organized and modular code.

So, proper code organization is crucial when using ChatGPT.

Of course, only some things are so rosy. One platform that has sparked some controversy is Temporal. On the one hand, Temporal helps you write less code and focus on business logic, which means less context for ChatGPT since you don’t need to explain which internal libraries and methods to use or write specific logic to support the robustness and reliability of workflows. However, on the other hand, ChatGPT should be aware of Temporal principles and APIs, and this can be problematic if ChatGPT uses outdated code or data. The potential for a mismatch in understanding can hinder the AI-driven development process.

Last but not least, the rise of cloud functions, or lambdas, has been a perfect match for ChatGPT-driven development. These small, independent units of code can be easily generated and managed by ChatGPT, streamlining the development process and improving the overall architecture. In my opinion, they are the best fit.

In my experience the best results are archived when you write some glue in the infrastructure field. For example, you can easily write bash-scripts that do complex staff (I bet the most of us have issues with bash syntax). You can create a smart proxy to route and handle requests to and from third-party systems that support only one sandbox environment.

In summary, the more code we can generate easily with ChatGPT, the better our software architecture is. We can do more by embracing microservices and cloud functions, focusing on proper code organization, and leveraging tools like ChatGPT and Github Copilot X. Ultimately, the rise of AI-driven development tools pushes us towards more modular and cleaner architectures, enabling us to build better software for a brighter future.

--

--

Tarasov Aleksandr

Principal Platform Engineer @ Cenomi. All thoughts are my own.