GitHub Copilot Built My Blazor App in Minutes
Why working code is not enough and how I refactor AI generated apps without losing control
I have been using GitHub Copilot a lot lately, especially for small demos and quick prototypes.
So I decided to try something simple.
I asked Copilot to build a small Blazor weather app. Nothing fancy. Just a textbox, a button, and real weather data coming from an external API.
It worked almost instantly.
Before we go any further, a quick note.
If you want to learn how I use GitHub Copilot as a real coding partner in .NET and Blazor projects, not just for quick demos, I cover this in depth in my course .NET Web Development with AI and Copilot. I focus heavily on prompts, structure, and keeping control over your architecture.
…and use the code SUBSTACK for a discount.
Back to the app.
At first glance, everything looked great. I could enter a city, click a button, and get the current temperature in both Celsius and Fahrenheit. The app even used real API calls under the hood.
Then I opened the Razor file.
When Working Code Is Still a Problem
All the logic was in one place.
UI code, API calls, business logic, and even the models were sitting inside a single Razor component. The app worked, but the structure felt wrong.
This is the moment where many developers get uncomfortable with AI generated code.
Not because the code is broken.
But because they know what comes next.
As soon as the app grows, this kind of structure becomes hard to maintain. Testing gets tricky. Refactoring feels risky. Small changes start to take longer than they should.
And none of this is Copilot’s fault.
AI Optimizes for Speed, not for Architecture
Copilot did exactly what I asked.
It focused on making the app work as fast as possible. It had no reason to think about long term structure, architecture patterns, or clean separation of concerns.
AI needs constraints.
Without clear rules, it will always optimize for speed and convenience. That is great for experiments. It is not great for production code.
So instead of throwing the code away, I tried a different approach.
One Refactoring Prompt Changed Everything
I asked Copilot to refactor the app without changing its behavior.
That part was important.
The app should work exactly the same. No new features. No shortcuts. Just better structure.
Then I gave Copilot a clear set of rules.
Move all API and business logic out of the Razor component.
Keep Razor focused on UI only.
Organize the code by feature, not by technical layer.
Use Vertical Slice Architecture.
Use CQRS and Mediator where it makes sense.
Then I ran the prompt and waited.
Same App
Finally Clean Code
A lot changed under the hood.
Copilot introduced feature folders and vertical slices. It created queries, handlers, and result objects. External API calls moved into a dedicated service.
The Razor component became simple and readable. The logic was easier to follow. The structure finally matched how I would build this by hand.
And most importantly, the app still behaved exactly the same.
This is the moment where AI starts to feel useful instead of risky.
This Is How I Use AI in Real Projects
This workflow is exactly how I use Copilot in real .NET and Blazor projects.
I do not let it decide the structure.
I give it rules.
I guide it with prompts.
And I use instruction files so these rules apply from the very beginning.
This is also what I teach in my course .NET Web Development with AI and Copilot. If you want to move faster without sacrificing code quality, this approach makes a huge difference.
Watch the Full Walkthrough
I recorded the entire process in a video, from the first Copilot generated version to the final refactored structure.
If you care about clean architecture and want to use AI without losing control of your codebase, this video will resonate.
Final Thought
AI can make you incredibly fast.
But speed without structure creates debt.
Give Copilot clear boundaries.
Set the rules early.
And let AI work with you, not against you.
Take care
Patrick
P.S. If you want a clear, repeatable system for using GitHub Copilot in real .NET and Blazor projects, my course .NET Web Development with AI and Copilot walks through it step by step.
…and use the code SUBSTACK for a discount.



