Smart Blogging: A Collaborative Effort with Your AI Partner

It can be tough to think of a programming project to showcase your coding skills and intellectual curiosity as well as your creativity. Basically, any first pet project you'll embark on has already been done before by thousands of other intrepid programmers and let's face it... it's probably been done better as well.

As someone who studied Artificial Intelligence extensively in college, and was thoroughly underwhelmed, I completely ignored all of the hullabaloo earlier last year. That all changed earlier this week, when I found myself bored and wanting to embark on a new project. Wanting to look for some fresh ideas, I decided to ask ChatGPT (on a whim) what it's thoughts were.

Q: I'm trying to think of a good coding project to showcase on my github profile. Can you help me brainstorm some ideas?

Certainly! The best coding projects to showcase on your GitHub profile often depend on your interests, skills, and the kind of work you want to be known for. Here are some project ideas across different domains that you can consider:

  1. Web Development:
    • Personal Portfolio Website: Build a personal website to showcase your projects, skills, and resume. Use HTML, CSS, and maybe a front-end framework like React or Vue.js.
    • Blog Engine: Create a simple blog engine where users can write, edit, and delete blog posts. You can use a framework like Django (Python) or Ruby on Rails.
    • E-commerce Platform: Build a basic e-commerce platform with product listings, shopping cart functionality, and user authentication.
  2. Machine Learning / Data Science:
    • Sentiment Analysis Tool: Develop a sentiment analysis tool using natural language processing (NLP) techniques and showcase it with a user-friendly interface.
    • Image Recognition App: Create an app that can identify objects in images using a pre-trained machine learning model, like TensorFlow or PyTorch.
    • Recommendation System: Build a recommendation system for movies, books, or music using collaborative or content-based filtering.
  3. Mobile App Development:
    • Task Manager App: Develop a task manager app for iOS or Android using frameworks like React Native or Flutter.
    • Fitness Tracking App: Create an app that tracks and displays fitness-related metrics, such as steps taken, calories burned, etc.
  4. Open Source Contributions:
    • Contribute to an existing open-source project that aligns with your interests. It could be fixing bugs, adding new features, or improving documentation.
  5. Game Development:
    • Simple Game: Create a basic game using a game development framework or engine like Unity (C#) or Godot (GDScript).
  6. Automation:
    • Automation Script: Develop a script to automate a repetitive task. For example, automate file organization, data scraping, or system maintenance tasks.
  7. Blockchain / Cryptocurrency:
    • Blockchain Explorer: Build a simple blockchain explorer for a popular cryptocurrency, displaying transaction history and block information.
  8. Internet of Things (IoT):
    • Smart Home System: Create a simple IoT-based smart home system that allows users to control devices like lights, thermostats, etc., through a web or mobile app.
  9. DevOps / Infrastructure:
    • Dockerized Application: Dockerize an existing application to make it easily deployable and scalable.
    • Continuous Integration Pipeline: Set up a CI/CD pipeline for a project of your choice.
  10. Educational Tools:
    • Flashcard App: Build an interactive flashcard app to help users study various topics.

Remember to choose a project that you're passionate about and that aligns with your career goals. It's also essential to document your code, write a README file, and include any necessary documentation to make it easy for others to understand and contribute to your project. Good luck!

Some people's eyes may glaze over at the long and draw out answer provided, but this gave me a novel idea: how about I write a blogging platform with the help of ChatGPT? The blogging platform itself will be about my interactions with it, as well as a commentary about learnings and iterations about the blogging platform, the different technologies I'll be using, as well as learnings about ChatGPT itself. And I'll provide a link to the actual conversation itself to showcase as much of the process as possible. I asked it what it thought (and not to my surprise) it liked that idea.

After a bit of back and forth on the tech stack we'd be using, some basic starting tips, and me cutting down on the scope a bit, We landed on an MVP. Basically it would look something like this:

  1. Back-end would be a standard RESTful API written in C# (a simple ASP.NET Core Web API project) with all of the fixin's. I'm pretty familiar with the .NET ecosystem, so getting up and running shouldn't be too terrible.
  2. Entity Framework connecting to and generating a SQLite3 schema.
  3. React.js frontend calling the aforementioned ASP.NET REST API.

I asked it for boilerplate code and got to work:

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

[Authorize] // This attribute requires authentication for all actions in this controller
[ApiController]
[Route("api/posts")]
public class PostsController : ControllerBase
{
    [HttpGet]
    public IActionResult GetPosts()
    {
        // Implement logic to retrieve a list of all blog posts
        // Example: var posts = _postService.GetPosts();
        // return Ok(posts);
        return Ok();
    }

    [HttpGet]
    public IActionResult GetPosts()
    {
        // Implement logic to retrieve a list of all blog posts
        // Example: var posts = _postService.GetPosts();
        // return Ok(posts);
        return Ok();
    }

    [HttpGet("{id}")]
    public IActionResult GetPostById(int id)
    {
        // Implement logic to retrieve a specific blog post by ID
        // Example: var post = _postService.GetPostById(id);
        // if (post == null) return NotFound();
        // return Ok(post);
        return Ok();
    }

    [HttpPost]
    public IActionResult CreatePost([FromBody] PostDto postDto)
    {
        // Implement logic to create a new blog post
        // Example: var createdPost = _postService.CreatePost(postDto);
        // return CreatedAtAction(nameof(GetPostById), new { id = createdPost.Id }, createdPost);
        return Ok();
    }

    [HttpPut("{id}")]
    public IActionResult UpdatePost(int id, [FromBody] PostDto postDto)
    {
        // Implement logic to update an existing blog post by ID
        // Example: var updatedPost = _postService.UpdatePost(id, postDto);
        // if (updatedPost == null) return NotFound();
        // return Ok(updatedPost);
        return Ok();
    }

    [HttpDelete("{id}")]
    public IActionResult DeletePost(int id)
    {
        // Implement logic to delete a blog post by ID
        // Example: _postService.DeletePost(id);
        // return NoContent();
        return Ok();
    }
}

Now, as you know if you've ever written an API of any sort, you'll know that this is probably the easiest part. What's harder is building out all of your services, getting a bulletproof authorization/authentication scheme in place, enabling all of the correct middleware for all of your use cases, and battling silly package management issues that are nearly certain to come up. So we did that.

After enough prodding, it helped me resolve compatibility issues due to a mismatch between the versions of the .NET SDK, Entity Framework Core, and related tools:

dotnet ef migrations add InitialCreate --version 6.0.0
dotnet ef database update
dotnet ef database update -Migration InitialCreate

When running the Migration gave me an error, it suggested several fixes... one of which was the root cause (I was missing the DesignTimeDbContextFactory). It also gave a detailed explanation as why not having that in place will throw the particular exception I was getting.

public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
{
    public ApplicationDbContext CreateDbContext(string[] args)
    {
        var optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();
        optionsBuilder.UseSqlServer("your_connection_string");

        return new ApplicationDbContext(optionsBuilder.Options);
    }
}

It also gave me the boilerplate I needed for the Startup.cs file:

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.EntityFrameworkCore;
using YourNamespace.Models; // Replace with the actual namespace of your models
using YourNamespace.Services; // Replace with the actual namespace of your services

public class Startup
{
    public IConfiguration Configuration { get; }

    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public void ConfigureServices(IServiceCollection services)
    {
        // Configure DbContext
        services.AddDbContext<ApplicationDbContext>(options =>
            options.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));

        // Add services
        services.AddScoped<IPostService, PostService>(); // Replace with your actual service
        // Add other services as needed

        services.AddControllers();
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            // Add production-specific configurations here
            app.UseExceptionHandler("/Home/Error");
            app.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseStaticFiles();

        app.UseRouting();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllerRoute(
                name: "default",
                pattern: "{controller=Home}/{action=Index}/{id?}");
        });
    }
}

This went on for quite a bit. We had a bit of a back and forth on why my SignInManager class wasn't actually signing in anyone, how to properly store secrets (in environment variables... duh), how to debug an entity framework misconfiguration, and how to properly create and use a JWT token. Being a .NET developer for almost 12 years, I kind of already knew the answer to a lot of these questions, but asked it them anyway. I'm pleasantly surprised at how quickly we were able to arrive at resolutions to these problems.

Key takeaways:

  1. ChatGPT is extraordinarily good at being a sounding board of ideas. It can suggest entire feature sets, break down your projects into actionable steps, and really get you to hit the ground running. Just remember to reign it in.
  2. It's incredible for debugging common problems and generating boilerplate, particularly when you're using well-documented and well-known programming libraries and frameworks.
  3. It can and will give you buggy and incomplete code. And it since the training cut-off for ChatGPT 3.5 was in January 2022, it has an incomplete view of the world and may suggest obsolete solutions and old library code.
  4. We're not getting replaced by AI anytime soon. It's a great tool that will turbocharge the productivity of anyone that will adopt them, but to suggest that it will eclipse us is absurd to me.

You can view the full chat here

The public Github repo for my work in progress can be found here

Note: the blog is absolutely nowhere near complete. For now, this blog post (and likely many future blog posts) will be powered by Ghost.