From the course: AI-Powered Software Development: Coding, Testing, and System Design

AI-assisted software architecture planning

- [Instructor] All right, so at this point in the course, we've seen a fair number of examples of how to use generative AI to write code. We saw how to use it to write production code as well as test code. So the next thing that we're gonna take a look at here is how we can use generative AI for a higher level of the software development process. This is another question that I get fairly frequently is, "So we can use generative AI to write code, but can we also use it for the architectural planning of an application?" And the answer to that, of course, is yes, you can use it for that. So what I'm gonna do here is I'm actually going to take a step back from using tools like GitHub Copilot and Cursor to write code and I'm gonna show you how to do these things with tools like ChatGPT and Claude. Now, the reason that I'm doing this isn't because you can't do these things with Cursor and GitHub Copilot, you can. With GitHub Copilot Chat, you can talk with actually quite a wide variety of different assistants. But we've already seen these tools quite a lot, and so I wanna change the the scenery a little bit here. So let's head over to ChatGPT. And the first thing that I'm gonna show you here is how we can use tools like this just for simple AI-assisted software architecture planning. So let's go back to the idea of creating some sort of application, like maybe an expense tracker app. We've used this in multiple examples so far, but let's just pretend that we haven't created an expense tracker app yet. What we would do in ChatGPT is you could describe the app that you wanna build, so we're gonna say something like, "I want to build an expense tracker app," and we'll say something like, "It should let users add expenses with category, amount, and we'll say name," and we'll also do something like, "And get monthly summaries." So again, we're just giving it additional information about our app that makes it maybe a little bit different from what a stereotypical expense tracker app might look like. So this monthly summaries thing, you could consider that like an additional feature. Category, amount and name, those are specifics as well. And the next thing that we're gonna do is we're gonna tell it to, "Suggest a software architecture design with key components, classes and data flow." Now we're probably gonna wanna give it a few more details about what exactly we want from it, so we'll say something like, "We would like to build this app in, let's say, Java," because we're not writing code, I'll just use Java. Or you could say, "We would like to build this app in C++," or in Go, or whatever you wanna use. I'll just say Java for now, and let's just start there. If we hit Enter and wait for ChatGPT to generate its response, what we're gonna see is that it gives us a suggestion for how to organize our app on a higher level. Now this is pretty exciting because in previous videos in this course, we've seen how to take things from about this level where we have the main classes or maybe the main functions, or at least the main pieces of our app and actually write the code for them. So what we're doing here is we're kind of building another layer on top of that where we're going from just a general plain text description to those main pieces. So ultimately, the general process will look something a lot like that. You'll use a tool for doing architectural planning like this and getting the main classes or whatever other pieces your app is going to consist of. And then you'll use generative AI again to go from there to the actual specific code that will power your application. So as you can see, you can look through this and it goes into quite a bit of detail. So if we take a look at expense, we see that it's given an ID, name, amount, category, date. Category has an ID and a name as well. Monthly summary, we see that that has its own properties. So it's gone into quite a bit of detail as far as what this app is going to look like. And just like I've said multiple times while writing code, you're gonna wanna take a good long look at this and make sure that it fits in with your expectations, right? If you see something in this description that isn't really what you wanted, then you're gonna want to correct that here. That is the basics for getting generative AI to create just a simple architectural layout for your application. So the next thing that you might wanna do here, instead of just taking its word for it, even if you've examined what it says here, is you might wanna ask it some questions to help refine this a little bit more. So that might look something like this. If we say something like, "Assume this app should support, let's say, 100,000 users in the future," we'll say, "what changes would you recommend to make the architecture more scalable?" So this is a good question because you're giving ChatGPT more context about your app when you just say, "Hey, I wanna build an app," it doesn't really know whether you're just planning this as a hobby project or as a real serious scalable thing. And the way that you write an app in both those cases is going to be significantly different. So in this case, sure enough, we see that it suggests a few different changes to our application. I'll let you read through these, whatever output you get on your to see if you agree, and then it's going to give us sort of like an updated listing of all of the different components. And if you want this in a format that's a little bit easier to work with or easier to translate now into code, that's really kind of the final step here, once you've addressed all of your architectural concerns is you're gonna say something like, "Great, now translate all of this into a series of classes with unimplemented methods that I can give to another assistant to implement." So basically, we're just describing what we want to do with these things, and what that'll do is that'll get us back to basically where we were at in previous sections where we have a largely unimplemented class or set of classes that we can tell GitHub Copilot or some other AI coding tool to implement. You could also implement it in ChatGPT if you want and then copy and paste it over, it really just depends on your preferences.

Contents