klever.io_challenge

command module
v0.0.0-...-f5427db Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2022 License: MIT Imports: 1 Imported by: 0

README

Be Klever!.

Klever Technical Challenge

About the challenge

The Technical Challenge consists of creating an API with Golang using gRPC with stream pipes that exposes an Upvote service endpoints. The API will provide the user an interface to upvote or downvote a known list of the main Cryptocurrencies (Bitcoin, ethereum, litecoin, etc..).

Technical requirements:

(Keep the code in Github)

  • The API must have a read, insert, delete and update interfaces.
  • The API must have a method that stream a live update of the current sum of the votes from a given Cryptocurrency
  • The API must guarantee the typing of user inputs. If an input is expected as a string, it can only be received as a string.
  • The API must contain unit test of methods it uses
  • You can choose the database but the structs used with it should support Marshal/Unmarshal with bson, json and struct

Extra:

  • Deliver the whole solution running in some free cloud service
  • Job to take snapshots of the votes every hour and plot a graph

Project Detais

Type Detail
Server Language Go
Client Language Go
Type gRPC + API
Database SqLite
Frontend .Net6 Web MVC
Cloud Host -

Installation

Project requirement:

Plugins

Plugin Readme
gRPC Web UI https://github.com/fullstorydev/grpcui
Go SQLite3 https://github.com/mattn/go-sqlite3
Protobuf File NEEDED OPTIONS
Golang Version must add this
option go_package = "github.com/kainbr3/klever.io_challenge/protobuf;protobuf"; 

C# Version must add this
option csharp_namespace = "KleverGrpcClient";
gRPC Files Generation: (Golang)
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative protobuf/service.proto

service.pb.go => Responsible to Serialize and Deserialize the messages defined in service definitions service.grpc.pb.go => Contains the auto generated Client and Server Code that we need to implement in our own Client and Server programs

gRPC Files Generation: (C# - CSharp)
Point the service.proto in the src/protobuf fold and it will be generated when you run/build the donet project

If you want to use the manual command to generate the files, use this
protoc --proto_path=. --csharp_out=library=service_pb,binary:protobuf --grpc-web_out=import_style=commonjs,mode=grpcwebtext:. protobuf/service.proto
Dedepndencies and Package Go (Golang)

From \SRC Folder:

go mod tidy
Dedepndencies and Package C# (CSharp)

From /SRC/FRONTEND Folder:

dotnet restore
dotnet build

Starting the Server

From /ROOT Folder:

go run main.go

server ip: Port grpcui -plaintext localhost:50051

Starting the CLient

From /ROOT Folder:

go run src/command/server/client.go

Starting the FRONT END

From /SRC/FRONTEND Folder:

dotnet run
<Command with Hot Reload Support>
dotnet watch run

Project Structure

📦klever.io_challenge
 ┣ 📂.git
 ┣ 📂.vscode
 ┣ 📂src
 ┃ ┣ 📂command
 ┃ ┃ ┣ 📂client
 ┃ ┃ ┃ ┗ 📜client.go
 ┃ ┃ ┗ 📂server
 ┃ ┃ ┃ ┗ 📜server.go
 ┃ ┣ 📂frontend
 ┃ ┃ ┗ 📂kleverchallenge
 ┃ ┃ ┃ ┣ 📂Controllers
 ┃ ┃ ┃ ┃ ┣ 📜CryptoController.cs
 ┃ ┃ ┃ ┃ ┗ 📜HomeController.cs
 ┃ ┃ ┃ ┣ 📂Models
 ┃ ┃ ┃ ┃ ┣ 📜CryptoViewModel.cs
 ┃ ┃ ┃ ┃ ┗ 📜ErrorViewModel.cs
 ┃ ┃ ┃ ┣ 📂Properties
 ┃ ┃ ┃ ┃ ┗ 📜launchSettings.json
 ┃ ┃ ┃ ┣ 📂Views
 ┃ ┃ ┃ ┃ ┣ 📂Crypto
 ┃ ┃ ┃ ┃ ┃ ┣ 📜Add.cshtml
 ┃ ┃ ┃ ┃ ┃ ┣ 📜Delete.cshtml
 ┃ ┃ ┃ ┃ ┃ ┣ 📜List.cshtml
 ┃ ┃ ┃ ┃ ┃ ┗ 📜Update.cshtml
 ┃ ┃ ┃ ┃ ┣ 📂Home
 ┃ ┃ ┃ ┃ ┃ ┗ 📜Index.cshtml
 ┃ ┃ ┃ ┃ ┣ 📂Shared
 ┃ ┃ ┃ ┃ ┃ ┣ 📜Error.cshtml
 ┃ ┃ ┃ ┃ ┃ ┣ 📜_Layout.cshtml
 ┃ ┃ ┃ ┃ ┃ ┣ 📜_Layout.cshtml.css
 ┃ ┃ ┃ ┃ ┃ ┗ 📜_ValidationScriptsPartial.cshtml
 ┃ ┃ ┃ ┃ ┣ 📜_ViewImports.cshtml
 ┃ ┃ ┃ ┃ ┗ 📜_ViewStart.cshtml
 ┃ ┃ ┃ ┣ 📂wwwroot
 ┃ ┃ ┃ ┃ ┣ 📂css
 ┃ ┃ ┃ ┃ ┃ ┗ 📜site.css
 ┃ ┃ ┃ ┃ ┣ 📂img
 ┃ ┃ ┃ ┃ ┃ ┣ 📜404.png
 ┃ ┃ ┃ ┃ ┃ ┣ 📜AXS.png
 ┃ ┃ ┃ ┃ ┃ ┣ 📜BTC.png
 ┃ ┃ ┃ ┃ ┃ ┣ 📜DVK.png
 ┃ ┃ ┃ ┃ ┃ ┣ 📜ETH.png
 ┃ ┃ ┃ ┃ ┃ ┣ 📜KLV.png
 ┃ ┃ ┃ ┃ ┃ ┣ 📜TRX.png
 ┃ ┃ ┃ ┃ ┃ ┗ 📜USDT.png
 ┃ ┃ ┃ ┃ ┣ 📂js
 ┃ ┃ ┃ ┃ ┃ ┗ 📜site.js
 ┃ ┃ ┃ ┃ ┣ 📂lib
 ┃ ┃ ┃ ┃ ┗ 📜favicon.ico
 ┃ ┃ ┃ ┣ 📜appsettings.Development.json
 ┃ ┃ ┃ ┣ 📜appsettings.json
 ┃ ┃ ┃ ┣ 📜kleverchallenge.csproj
 ┃ ┃ ┃ ┗ 📜Program.cs
 ┃ ┣ 📂infra
 ┃ ┃ ┗ 📂database
 ┃ ┃ ┃ ┗ 📜kleverchallenge.db
 ┃ ┣ 📂package
 ┃ ┃ ┣ 📂model
 ┃ ┃ ┃ ┗ 📜model.go
 ┃ ┃ ┣ 📂repository
 ┃ ┃ ┃ ┗ 📜repository.go
 ┃ ┃ ┗ 📂tool
 ┃ ┃ ┃ ┗ 📜tool.go
 ┃ ┗ 📂protobuf
 ┃ ┃ ┣ 📜service.pb.go
 ┃ ┃ ┣ 📜service.proto
 ┃ ┃ ┗ 📜service_grpc.pb.go
 ┣ 📜.gitignore
 ┣ 📜go.mod
 ┣ 📜go.sum
 ┣ 📜LICENSE
 ┣ 📜main.go
 ┣ 📜Makefile
 ┗ 📜README.md

TODO List

  • Create Server and Client Go Applications
  • Organize all the reusable and shared data in Tool Package
  • Create and Configure a Database
  • Create a Repository Package to handle the Database Persistence
  • Create the Protobuf (Contract) file and generate the PB and gRPC Service
  • Create a Frontend Application to consume the gRPC Services
  • Test the Marshal/Unmarshal support
  • Create New gRPC Services, including a Streaming to show Crypto Votes in Real Time
  • Add more views in the Frontend Application to iterate with the new gRPC Services
  • Create the Unit Tests

TODO List - EXTRA

  • Deploy the Solution in a free Coud Service
  • Configure the Cloud Host Machine Snapshots
  • Create a Graph to show Host Snapshots

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
src

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL