Democratization of coding using Github Copilot

Intro
Hope everyone is doing well. We are ushering into a new era where using AI tools are becoming part and parcel of everyone’s lives. There are promises of increased efficiency or fears of job loss etc. We often read the news of CEOs saying that 50% of new code being written by AI or developers getting 30% more efficient or Jansen Huang statement on coding becoming obsolete. I personally thought how is this going to affect me until it did.
This weekend I got a chance to use Github copilot and it is darn amazing. Being a Devops Engineer I am not a very good programmer because my daily work doesn’t require me to code and it is very difficult to catch up with the changes in programming trends or languages etc. I recently learnt golang but I cannot keep my go skills on the edge because I write a piece of code and then nothing for weeks or months altogether. Typically my pace is unbearably slow. I have to open 50 tabs to write 10 lines of code. I can easily get distracted or lose interest altogether. In general reading code is very easy but writing has a very steep learning curve. Github copilot changed everything for me. I can ask for a function and it is aware of the context and the file structure and writes very accurate function for my needs and also tells me what changes do I need to make.
Project Fundata
If you are a long-term investor, you need to have access to company’s financial data like income statement and cashflow etc. This is called as Fundamental Data. I used to use TIKR which costs $20/month. The idea is to get data from alphavantage API for free and put it in MongoDB and visualize it using Grafana or something equivalent by writing queries. I have written a similar README and asked copilot for project structure. It read my readme file and gave the project structure exactly like I wanted.

cmd/myapp/main.go: Entry point of the application.
internal/api/handler.go: Handles HTTP requests.
internal/db/mongo.go: MongoDB connection and operations.
internal/models/data.go: Data models.
internal/services/alpha_vantage.go: Interactions with the AlphaVantage API.
pkg/utils/utils.go: Utility functions.
go.mod and go.sum: Go modules files.
README.md: Project documentation.
And it also gave this test to make me understand what goes where.

In this example, I have not told it how the struct should look like but it took it from my readme and understood what I am trying to do. This is from my readme
Currently I have subscribed to TIKR which costs me $20/month to get fundamental data like earnings, cashflow etc. This project is to bring that cost down by having a self-implemented solution using AlphaVantage API and my impeccable coding skills in golang with the help of github copilot.
Write a application which takes a post request with a json payload like
{"symbol": "META", "function": "cash_flow", "api_key":"xxxxx"}Store the data in mongo-db which will be deployed in the same cluster
Use Grafana to visualize the data stored in mongo-db

Initially for testing I have put everything in the same file. When I gave this prompt, it gave me two different files to tidy-up the code.

Ensure that the handler function in handler.go is exported (i.e., its name should start with an uppercase letter):

It gave me that there is a vulnerability in using hard-coded credentials


Initially the struct is not accurate because it did not know what incoming data looks like(duh!) So I gave another prompt with the json structure then it gave me accurate struct.



I never wrote code to connect with MongoDB in Golang. This is the first time I am seeing this and it worked without any error.

I can ask for explanations.
Make sure to replace "your_database_name" with the actual name of your MongoDB database.
This code updates the GetDividendInformation function to call the insertDividendData function, which inserts the dividend data into the MongoDB collection.



And then I asked it to get URI from secret.

Summary
I could never dreamt of writing an entire project in 2 hours. Github copilot can make us extremely efficient and language agnostic. This opens up all new possibilities





