Building With AI When You Don't Know Architecture: A Survival Guide
Let me describe a moment you might recognize. You had an idea for an app. You didn't know how to build it — not really — but you opened an AI chat, described what you wanted, and it gave you working code. You ran it. It worked . It felt like magic, because it was: something you couldn't have written a month ago was running on your screen. So you added another feature. And another. And somewhere…
In a world where artificial intelligence can quickly generate functional code, a new challenge emerges: understanding how to organize and structure that code effectively. Without proper architecture and structure, an AI-built project can quickly become a tangled mess of code, rendering it difficult to maintain and expand. This survival guide aims to provide tips and habits to prevent such a situation, even for those who have no formal computer science background.
The main issue is not that the AI writes bad code, but that it allows you to produce a working app without fully understanding its underlying structure. This lack of understanding can lead to problems when attempting to make changes, as every edit has the potential to break the entire project. This is where the concept of architecture and structure becomes crucial.
Architecture, in simple terms, refers to the layout and organization of a project, outlining what each component does and how they interact with one another. Structure, on the other hand, is what makes a project understandable. As your project grows, maintaining a clear architecture becomes essential to ensure that changes remain contained and do not spread, causing a cascading effect of issues throughout the codebase.
Survival skill #1: Separate the pieces. AI often generates code with all components packed into a single file. This makes it difficult to make changes without affecting other parts of the project. To mitigate this, separate three key elements: the user interface (UI), the business logic, and the data layer. By keeping each of these components in separate files, changes can be made without affecting other parts of the program, keeping everything contained and preventing the spread of issues.
Survival skill #2: One job per thing. Each file and function should have a single, clear responsibility. If a file or function is doing more than one job, it can become difficult to understand and change, increasing the risk of bugs and errors. To avoid this, split any file or function that is performing multiple tasks into smaller, more manageable pieces.
Survival skill #3: One home for each piece of data. As your app grows, it's easy for pieces of data to get scattered across the project, leading to multiple copies of the same information. This can cause issues when those copies become out of sync, making it difficult to debug and maintain the project. To avoid this, ensure that every piece of data has a single source of truth, with all other components reading from that single location.
Survival skill #4: Decide the shape before you generate. Many beginners build their projects by repeatedly asking the AI to generate code for each feature, without first determining the overall structure. This results in a haphazard arrangement of code that is difficult to maintain and expand. To avoid this, outline the main components and their responsibilities before generating any code.
For example, for a simple app, you might have pieces like login, user profile, the main dashboard, and payments. Each piece should have a clear job, forming the foundation of your project's architecture. By building each piece one at a time, you can ensure a clear and organized structure that is easier to understand and modify.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.