A simple service for managing user points which allows receiving point based on the activity type i.e. add review, invite friend and these points can be spent or shared with other users as well.
- mysql
- gorm
- google.golang.org/grpc
- github.com/kelseyhightower/envconfig
- bin: contains executable file(s)
- cmd: server and client main functions
- docker: contains all docker files
- internal:
- api: implement grpc server methods
- types: include environment struct and action type
- models: database models (user, activity)
- pb: generated code from proto using the following command:
make generate
- pkg: emtpy reserved for reusable packages
- proto: contains protobuf files
Build and run docker containers using this command:
make up
To run database migration type this on terminal:
make migrate
Stop and remove docker containers using this command:
make down
To run the test client with default parameters:
make client
it should print something like that:
2023/04/01 12:31:02 balance: 219.500000
2023/04/01 12:31:02 successfully shared points: 5.500000
2023/04/01 12:31:02 user points: 214.000000
2023/04/01 12:31:02 recipient points: 66.000000
We can use JWT token to authenticate user by adding interceptor function to grpc and get token metadata. This way we can get current user's data.