GameSage App: My CLI Python application project journey

Emily Chew
5 min readJun 8, 2024

--

Picture of games from(Microsoft, Nintendo, Respawn, Psyonix)
Photo sourced from PCMag

In this blog post, I’ll be sharing my experience and reflections on my journey with Python, along with insights into my first CLI (Command Line Interface) project, a game lookup app called GameSage .

The Learning period

After completing my front-end Crux Games Web app React project, it was time to learn the fun of backend. Python is a popular, widely-used programming language that many people encounter, even outside the tech scene. The reason why it is so popular? Created by Guido Van Rossum, is known for its easy-to-read code syntax and versatility, making it a great entry point into the world of programming. However, it can quickly become complex, especially when used for advanced tasks like machine learning.

Before my bootcamp, Python was my first introduction to programming, even before HTML or CSS. It sparked my interest in tech and served as the foundation for my learning journey.

During this phase of my bootcamp, I started by understanding the fundamentals of Python, including data structures, object-oriented programming (OOP), object inheritance, classes and methods, and SQL fundamentals. Then, I moved on to more advanced topics like object-relational mapping with Python and SQLAlchemy. Understanding these concepts was crucial for building a functional CLI application.

The Project Requirements:

  • It must be a CLI application that adheres to best practices.
  • A database created and modified with SQLAlchemy ORM with 3+ related tables.
  • Uses Alembic to manage migrations.
  • A well-maintained virtual environment using Pipenv.
  • Proper package structure in the application.
  • Use of data structures such as lists, tuples, and dictionaries.

My Project: GameSage

This app aimed to enable users to register themselves into the database app, be able to search for details about their favourite games, save them to their favourite list, manage their favourites, and make notes about the games.

Database Schema
The three main tables I used were:

  • Users: This table stores the names of all registered users.
  • Games: Initially seeded with data, this table contains information about various games.
  • Favourites: This table stores the relationship between users and their favourite games, along with any notes the user adds about the game.

Application Structure

  1. Introduction & Sign Up or Login
  2. Games Lookup
  3. Favourite List
  4. Exit the App
Introduction & Sign Up or Login

Introduction & Sign Up or Login
Upon launching the app, users are greeted with a welcoming message and prompted to enter their username to log in or sign up. New users are automatically registered, and their usernames are stored in the database.

Main Menu

Main Menu
The main menu offers three options:

  1. View all games
  2. View your saved favourites
  3. Exit the app
Game List
Game details

The Games Lookup Section
Users can choose to view all games in a general list or filter by genre. The general list displays all games in a table format, while the genre option presents five categories to choose from: RPG, Action, Anime, Battle, or Racing. Users can enter the game ID to view further details about a specific game.

Favourite list

Favourite Section
Users can see a list of their favourite games. From here, they also have the option to look into further details if they wish. Users can manage their favourites by deleting games from their list or making notes. They can also read and manage their notes in the view notes section, as notes can only be made if they are in the favourite lists.

Notes section

Notes Section
Users can view the notes they have made for their favourite games. Additionally, they have the option to delete any notes they no longer need. This section ensures that users can manage their notes efficiently, keeping their game information organized and up-to-date.

Styling
A few external libraries were installed and used for this application. Colorama was used for colours, which does an excellent job. For the title, I used PyFiglet. For the aesthetically pleasing table, I used Tabulate.

Challenges

Building the GameSage CLI app presented several challenges, each contributing to valuable learning experiences:

  • Bugs: During the development, I had to constantly test for all the scenarios of when it goes wrong. A lot of if/else, try/except, and loops were involved. Handling errors cases was another challenge. I had to implement a lot error handling mechanisms to ensure that the app could gracefully handle unexpected inputs and errors.
  • User Interface Design: Designing a user-friendly interface for a CLI app was a new experience for me. I had to experiment with different styles and layouts to find a design that was both functional and somewhat visually appealing.
  • Defining Appropriate Relationships Among Models: One of the most critical aspect was defining the relationships between the different tables in the database. For example, establishing a many-to-many relationship between users and their favourite games required a thorough understanding of how to properly set up foreign keys and join tables. This process involved designing the schema in a way that maintained data integrity and allowed for efficient queries.
  • Alembic Migrations: Alembic, a lightweight database migration tool for use with SQLAlchemy, although it seemed pretty straightforward, posed a challenge for me when changes needed to be made to the models. While Alembic is powerful and essential for managing database schema changes over time, understanding how to properly configure and execute migrations was challenging. I had to learn how to write migration scripts that accurately reflected changes to my models, such as adding new tables, modifying existing ones, or adding new columns. Managing these migrations helped me appreciate the importance of version control in database management.

Overall, I am happy with how the GameSage App turned out. The hours that have been spent learning the modules and fundamentals of Python, to creating my first CLI application has certainly made me feel more confident in the skills I have gained in my backend journey. I am eager to combine what I’ve learnt from both frontend and backend in the future. Onto the next!

--

--

Emily Chew
0 Followers

Software Engineer in Training | Allied Health Practitioner | Palworld Explorer