Giter Site home page Giter Site logo

cloudblast-backend's Introduction

Cloud Blast Backend

System Overview

Cloud Blast backend system is designed using the microservices architecture.

The system consists of four main components:

  1. Main Service: It is responsible for hosting the HTTP server and starting the User, Tournament, and Leaderboard services. With Mux, it routes requests to handler functions that are responsible for forwarding the request to appropriate service and service responses to requesters.

  2. User Service: This service handles all user-related activities like user registration, login and level progress.

  3. Tournament Service: This service is responsible for managing tournaments, including their creation, updates, and player participation.

  4. Leaderboard Service: This service is responsible for maintaining the tournament rankings. It uses Redis as a data cache to store and quickly retrieve the tournament rankings.

  • The communication between these services and the Main Service is empowered by RabbitMQ, a highly efficient message broker. RabbitMQ queues are used to facilitate communication between services, ensuring decoupling of services and improving the system's scalability and maintainability.

  • As the persistent storage, Amazon DynamoDB is used to store "User", "Tournament" and "UserInTournament" (user records in different tournaments) tables.

  • CronJob is used to schedule tournaments daily.

Setup and Execution

Local execution

  1. Start RabbitMQ and Redis services. Configure AWS Cli credentials for cloud DynamoDB access.
go build -o cloudblast-backend cmd/main.go
./cloudblast-backend

Dockerized execution

  1. Set "AWS_ACCESS_KEY_ID" and "AWS_SECRET_ACCESS_KEY" variables on docker-compose.yaml file

docker-compose up --build

API Endpoints

  1. POST /api/tournament/StartTournament: Start a tournament - takes no parameter.

  2. POST /api/tournament/EndTournament: End the current tournament, decides winners of the tournament - takes no parameter.

  3. POST /api/user/CreateUser: Creates a new user - takes "username", "password" and "country" as parameters.

  4. GET /api/user/Login: Returns a JWT token checking the password - takes "username" and "password" as parameters.

  5. GET /api/user/SearchUser: Search for a user in the system - takes "username" as parameter.

  6. POST /api/user/UpdateProgress: Update the progress (+100 coins and +1 progress level) of a user in a tournament - takes "username" as parameter.

  7. POST /api/tournament/EnterTournament: Entering the current tournament as a participant - takes "username" as parameter.

  8. POST /api/tournament/UpdateScore: Increment the score of a user in a tournament, also increment the progress of the user - takes "username" as parameter.

  9. POST /api/tournament/ClaimReward: Claim rewards after the end of a tournament - takes "username" as parameter.

  10. GET /api/tournament/GetTournamentRank: Gt the rank of a user in a specific tournament - takes "username" as parameter.

  11. GET /api/tournament/GetTournamentLeaderboard: Get the leaderboard of a specific tournament, which includes the ranks and scores of all the participating users - takes "username" as parameter.

  12. GET /api/user/GetCountryLeaderboard: Get the leaderboard of users from a specific country - takes "username" as parameter.

  13. GET /api/user/GetGlobalLeaderboard: Get the global leaderboard of all the users in the database - takes "username" as parameter.

Dependencies

  • github.com/aws/aws-sdk-go: "v1.44.330"
  • github.com/gorilla/mux: "v1.8.0"
  • github.com/cespare/xxhash/v2: "v2.1.2" // indirect
  • github.com/davecgh/go-spew: "v1.1.1" // indirect
  • github.com/dgryski/go-rendezvous: "v0.0.0-20200823014737-9f7001d12a5f" // indirect
  • github.com/dgrijalva/jwt-go: "v3.2.0+incompatible"
  • github.com/go-redis/redis/v8: "v8.11.5"
  • github.com/google/uuid: "v1.3.1"
  • github.com/jmespath/go-jmespath: "v0.4.0" // indirect
  • github.com/robfig/cron: "v1.2.0"
  • github.com/streadway/amqp: "v1.1.0"
  • golang.org/x/crypto: "v0.12.0"
  • golang.org/x/net: "v0.14.0" // indirect

cloudblast-backend's People

Contributors

moghun avatar

Watchers

 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.