An example of how to use Go + Echo, AppEngine, MySql, Redis and an approach of clean architecture.
- The DNA analyzed are saved on Mysql.
- While a DNA is analyzed the counters are saved on Redis. Why ? see: storing-counters-in-redis.
- The stats are retrieved from Redis.
- The project was deployed on App Engine Standard.
- Post Mutant Sequence Diagram ⏱
- Get Stats Sequence Diagram ⏱
- Internal Architecture Diagram 🏠
- Cloud Architecture Diagram 🏛
to run this project just you need:
- Docker and docker-compose
- Go 1.15*
the reason, this project uses MySql, Redis and Go, with docker and docker-compose you don't need manual installations
- Go is necessary in case you want to run the tests
docker-compose up
Note: You need Go and the dependencies of the project.
TODO: run tests with docker exec
go test ./... -v
Mutants is a service for looking for if a human either is a mutant or not. This is a Rest project, is not restful.
You could test either in local or directly in production.
Api Production URL: https://mutants-fer.uc.r.appspot.com/
Service Off
Just use the Api URL instead of localhost in the below examples.
POST http://localhost:5007/api/v1/mutant
Auth required : NO
Request POST Example
This is a DNA of a Mutant because it has at least 1 sequence of 4 equal letters. These sequences can be horizontally, vertically or in the diagonal.
{
"dna": [
"ATGCGA",
"CAGTGC",
"TTATGT",
"AGAAGG",
"CCCCTA",
"TCACTG"
]
}
Response HttpStatus If the human is a mutant
200
Response HttpStatus If the human is a real human
403
GET http://localhost:5007/api/v1/stats
Auth required : NO
Request No Body
Response Number of humans and mutants.
{
"count_mutant_dna": 2,
"count_human_dna": 3,
"ratio": 0.6666667
}
If you want to re-generate the mocks. See Dependency
mockery --all --keeptree
If you want to deploy.
gcloud app deploy
Rename the app.yaml.example
to app.yaml
and fill out the environment variables.