Building an app with ChatGPT: Day 1
Project setup, authentication
4 min read
Before starting work on this project, I had an insightful discussion with ChatGPT about what I should build. My idea was simple: a habit tracker that motivates you by making you compete with yourself. For example, if I want to do 10 pushups per day, I should have a habit with a simple yes/no question, "Did you do 10 pushups today?", and I could just hit yes or no. Do this for enough days (~66), and you form a habit of doing pushups each day. For me, this is pretty motivat
ional. I'm using Habits Garden and look how nice my "No Coca-Cola" habit looks; I haven't drunk a sip of Coke since December last year, and keeping that streak keeps me motivated.
Another way to make this more motivational is to use the concept of "personal records." For example, I could try to do 10 pushups every day, but I'd also like to know my highest number of pushups in a day. Using my habit tracker, I could log that as well and try to beat it.
I presented this idea to ChatGPT, and it helped me plan the functionality for an MVP:
We agreed to work for 4 hours per day. Let's see if the estimation was correct for the first day by going through each task:
Set up the development environment
This was done already because I'm a .NET developer, so I had everything ready (.NET SDK, Visual Studio, etc.). Time required = 0 minutes.
Create a new Blazor WebAssembly project
As I said in the previous post, I don't have that much frontend experience so I asked ChatGpt what could I use. Its suggestion was to go with Blazor, which I'm already familiar with and I was thinking about this as well.
Plan the database schema
Here's where I think ChatGPT did a fantastic job. I just had to give the requirements and explain that I'm using EF Core with SQL Server, and it generated all the entities. First, it gave me a list of the entities with their fields:
Then I gave it some suggestions and asked for the actual code, which it handled pretty well:
Honestly, I think this saved a lot of time because it was all done in ~10 minutes.
Create entity classes
Already did this in the above step
Configure the connection string and register DbContext
This step was pretty simple, I just had to configure EF Core and the DbContext and it was a lot easier doing it myself instead of asking ChatGPT. Once the first migration ran I could go to the next step which was authentication.
Implement basic user authentication
I don't have a lot of experience with authentication, so I was happy to have someone help me in this area. Initially I wanted to allow users to login with their Facebook/Twitter/Google and Microsoft accounts but for the MVP we agreed we should have username and password authentication. I asked ChatGPT to generate the login and register pages along with the API controller and it did ~80% of the job.
It's not always perfect, as you can see it forgot that I'm creating a Blazor app, not ASP.NET MVC, and it did this a lot of times. Here's the next result... but without the API call:
I asked for the implementation of HandleLogin and it provided that as well:
The problem here is that I'm not accessing the UserManager directly from my Blazor app, I want to do that from the server controller, so I had to ask again for a rewrite:
Conclusion for the 1st day
In summary, ChatGPT has proven to be a valuable asset in this project, despite not being perfect. It generated most of the code and provided guidance, which saved a considerable amount of time. Although there were some errors and occasional trips to StackOverflow, these instances were less frequent than usual. The first day of work took less than 2 hours, which was quite efficient.
As I move on to developing UI components tomorrow, I'm eager to see the initial bits of functionality come together. Stay updated on my progress by subscribing to this blog or following my Twitter account!
Did you find this article valuable?
Support Bogdan Bujdea by becoming a sponsor. Any amount is appreciated!