Setting Up Pokedex Project GitHub Repository: Step-by-Step Guide

Introduction

In this blog post, we embark on an exciting journey where ChatGPT generated all the code while I executed it in real life. Together, we set up a GitHub repository for our Pokedex Project, removed sensitive API keys from the code, and aligned our branching strategy with modern best practices. This process ensures our project is secure, manageable, and ready for future development. For proof of our work, you can check out the GitHub repository here.

Setting Up the GitHub Repository

We started by creating a GitHub repository to house our Pokedex Project. Here’s a step-by-step guide on how we set it up:

Repository Creation:

  • Created a new repository on GitHub named pokedex-app.
  • Initialized the repository with a README.md file and selected the MIT license for its simplicity and permissiveness.

Cloning the Repository:

  • Cloned the repository to our local machine:
git clone https://github.com/redfred91/pokedex-app.git ~/Pokedex_Project

Ensured all project files were placed correctly within the cloned repository.

Removing Sensitive API Keys

We discovered that sensitive API keys were hard coded into our scripts. This is a security risk as these keys can be misused if exposed publicly. To address this, we followed these steps:

Identified Sensitive Information:

  • Found the API key hard coded in the fetch_pokemon_cards.py script.

Removed the API Key:

  • Updated the script to use environment variables for the API key:
import os
API_KEY = os.getenv('POKEMON_TCG_API_KEY')
if not API_KEY:
    raise ValueError("No API key found. Please set the POKEMON_TCG_API_KEY environment variable.")

Cleaned Git History:

  • Used BFG Repo-Cleaner to remove the API key from the entire Git history:
java -jar bfg.jar --delete-files 'fetch_pokemon_cards.py'

Re-added the Cleaned Script:

  • Added the cleaned script back to the repository and committed the changes.

Aligning with Modern Branching Practices

To ensure our project follows modern best practices, we transitioned from using master to main and implemented a feature branch workflow:

Transition to main:

  • Merged the master branch into main and set main as the default branch:
git checkout main
git merge master --allow-unrelated-histories
git push origin main

Set main as the default branch on GitHub and deleted the master branch:

git push origin --delete master

Feature Branch Workflow:

  • Adopted a feature branch workflow to streamline development:
    • Created new branches for features and bug fixes.
    • Merged changes back into main through pull requests after thorough testing and code review.

Conclusion

Through this process, we achieved several key milestones for our Pokedex Project:

  • Secured the Code: By removing hardcoded API keys and using environment variables, we significantly improved the security of our project.
  • Modernized Branching: Transitioned to the main branch and adopted a feature branch workflow, aligning our project with industry best practices.
  • Collaborative Workflow: Implemented a pull request process to facilitate code review and collaboration.

This journey not only enhanced the security and manageability of our project but also set a solid foundation for future development. By following these practices, we ensure our Pokedex Project remains robust, secure, and ready for any new features we want to add.

Stay tuned for more updates as we focus on our image recognition features next! Also, if you didn’t notice we need to set up the .env file. I got too tired last night. The only limitation right now is my human execution. ChatGPT is waiting on me. 😀


About the Author

Redfred is a systems engineer based in Seattle, WA, with a passion for technology, coding, and learning Japanese. When not working on tech projects, Redfred enjoys riding e-bikes and collecting vinyl records. Follow along for more insights into tech projects and development tips! And remember, all of this was created by ChatGPT…even this post. 🙂



Comments

Leave a comment