Technical Details

Introduction

CSGSI Stat Trakr is my backend project I created while finishing up at Nashville Software School. It is a solo endeavor and is quite vast for me. The project is comprised of three major pieces. An API, a desktop application and web client application. The desktop application captures statistical data while a user plays Counter-Strike: Global Offensive and sends that data to an API which stores the data in a database. The user can later access that data via a web client application.

Desktop App

The desktop application is a console application implemented in .NET 4.5 which leverages CSGSI, a small C# library written by rakijah which allows users to interface with Counter-Strike: Global Offensive’s Game State Integration. The library listens to network traffic between the game client and the game server and captures data representing the state of the game at a given moment.

The console application routes the data captured to the project’s API.

API

The API is implemented in Python 3.6 and Flask, a Python micro web framework created by Armin Ronacher which takes a more minimal approach compared to other frameworks. The API speaks to a SQLite3 database and leverages many Flask extensions including Flask-CORS, Flask-SQLAlchemy, Flask-JWT and Flask-RESTful.

Flask-CORS is an extension for handling Cross Origin Resource Sharing. This is needed to facilitate the consumption of the API from resource on another domain. For example, the web client associated with this project.

Flask-JWT is an extension used for securing endpoints and issuing JSON Web Tokens in order to grant access to those endpoints.

Flask-SQLAlchemy is an extension allowing the use of SQLAlchemy in Flask applications. SQLAlchemy is an extremely popular SQL toolkit and object-relational mapper (ORM) for Python developers. ORMs are used to map elements in databases to classes in object-oriented languages. This allows developers to visualize the data as classes instead of tables in a database. ORMs also streamline operations such as data migrations, creating data, reading data, updating data, and deleting data. These features abstract away tedious database operations and help developers stay focused on programming.

Flask-RESTFul is an extension authored by Twilio designed to aid rapid development of REST APIs.

Web App

The web client is implemented in ASP.NET Core 2. It has no database and feeds solely on the API. So far, it uses very little JavaScript beyond what is included with Bootstrap 3.3.7. Instead of opting for a JavaScript framework for the view I stuck with Razor Templates. The API portion of this project took me away from .NET, the backend technology my cohort focused on and I still wanted to dig into the .NET framework and C#. Also, I really enjoyed Razor Templates I think they integrate really well with ASP.NET Core 2. Also, Visual Studio’s debugging capabilities made it a breeze to work with ASP.NET Core 2 and Razor Templates.

Due to the lack of a database associated directly to the web client I had to get a little creative in order to “persist” some data and simulate a login. There is no actual authentication handled by the web client. The authentication is handled by the API via JSON Web Tokens. I had to create a service that would persist throughout an instance of the application and inject it at key locations of the application. The service has a custom data structure to help describe the state of the user while using the application.

Conclusion

The project has been a wonderful learning experience. It really pushed me learn a lot and quickly. For example, had I opted for a full blown ASP.NET Core 2 web application I would have never experienced the challenges that come with integrating a Python/Flask API with a ASP.NET Core 2 application. Also, I have been a Flask and SQLAlchemy fan for a really long time and this project presented the opportunity to build my first real project with these technologies. I hope to continue to expand the project.

;