Giter VIP home page Giter VIP logo

dankstats-api's Introduction

dankstats-api

Project Overview

This is a project aimed improving my skills in both Go and JavaScript. The frontend is built with Next.js (react) that talks to a Go API. Be sure to look at the frontend

The backend is a simple wrapper for Helix. Provided you have twitch api credentials, Helix will take those and will authorize your app by retrieving an AppAccessToken. This token refreshes every 60 days and thats something I need to account for. Ideally the token get refreshed and swapped out automatically without service interuption.

My initial thought was to simply wrap the Helix methods in an API handler and expose it in an endpoint. I’ve implemented that for top-games and top-channels. Howevver, there were two obvious problems that occurred to me when I implemented this:

  1. Each page load is going out and grabbing data from the API. You can see how images are loading fairly slowly. I should proxy the request and data should be stored in something like redis so that images load faster.

  2. Rate limiting. The Twitch API docs give about 800 points per minute (point being a request). I suspect this would go pretty quickly if the site gained any traffic. I would rather use those 800 points to do some scanning for data collection.

So what I have to do now is think of a way to proxy requests so that users can hit my API as much as they want, without it affecting my API access to Twitch. This also means that API requests are going to retrieve data from my database, rather than straight from the twitch api.

Twitch does not provide any historical data, so any charting is impossible unless I start archiving the data myself. This means I need to setup a database and try to mock data based on their API. I need to figure out what data I want to collect. Lastly, how does this collection/scanning happen? What triggers it? How often? Being at my level in Go, this seems quite complicated but I am determined to figure it out.

Project structure

I'm keeping the project layout as flat as possible until it makes sense not to. When I start to break things up I will likely just add a pkg and cmd directory. All other files can live in the project root.

Developing

To get started developing, all you need at this moment is Go, and Twitch API credentials.

make run is all you need to run the project. make tidy will run go mod tidy & go mod vendor.

To get running with docker-compose, you'll first need to build the image locally.

make create && make up

You can spin everything down by running make down

TODO

  1. Top priority is wiring up the config variables. I'm using flags, but a config file can be used for API credentials. Wrapping my brain around that now...
  2. Implement database
  3. ...more to come

dankstats-api's People

Contributors

jonleopard avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.