https://github.com/jeffotoni/growth
Simple CRUD example to store data coming from JSON in memory. In several languages.
https://github.com/jeffotoni/growth
go golang hacktoberfest kotlin nodejs nodejs-api python rust typescript
Last synced: 6 months ago
JSON representation
Simple CRUD example to store data coming from JSON in memory. In several languages.
- Host: GitHub
- URL: https://github.com/jeffotoni/growth
- Owner: jeffotoni
- License: mit
- Created: 2021-07-09T06:00:21.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-05-16T19:02:51.000Z (9 months ago)
- Last Synced: 2025-06-08T16:03:18.608Z (8 months ago)
- Topics: go, golang, hacktoberfest, kotlin, nodejs, nodejs-api, python, rust, typescript
- Language: Go
- Homepage:
- Size: 51.2 MB
- Stars: 44
- Watchers: 5
- Forks: 17
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# API Growth π πΏοΈ π π¦
This repository was created to make projects available in various programming languages ββfor educational purposes and to collaborate with the developer community. A joke that was born on social media and materialized in this repository β€οΈ.
Programming languages βββ€οΈ are tools and should be used to solve specific problems than what they were proposed to solve. But we know that it goes far beyond this π, in this equation we have to add a pinch of LOVE π and when you have this combination things start to get even more interesting ππ.
---
The scope of the project is to create a rEST API, a CRUD and persist it in memory and place it in a docker image. The size of this docker image could not exceed 6Mb, but we are aware of the limitations that each language has and in this regard you can send a larger image, try to make it as small as you can and very lean βΊοΈ.
Your POST will receive a JSON of 1mb or 3mb and persist it in memory.
Below is an example and description of what you will need to implement in the API.
The entire repo was organized by programming languages, feel free to collaborate by sending us a pull request, below we will leave the documentation on how to make a PR.
What we will send to [POST] will be a 1Mb or 3Mb json with more than 40k lines and the body of the json is below:
```bash
[
{
"Country":"BRZ",
"Indicator":"NGDP_R",
"Value":183.26,
"Year":2002
},
{
"Country":"AFG",
"Indicator":"NGDP_R",
"Value":198.736,
"Year":2003
}
]
```
## Pull Request
You can organize your directory like the examples below:
```bash
grow.go/
βββ jeffotoni
βββ grow.fiber
βΒ Β βββ README.md
βββ grow.standard.libray
βββ Dockerfile
βββ go.mod
βββ main.go
βββ main_test.go
βββ README.md
```
You can organize your project by choosing the language you will implement and then your github user and within your directory you can create and organize your contributions.
Check out more examples:
```bash
grow.python/
βββ cassiobotaro
βββ Dockerfile
βββ main.py
βββ README.md
βββ requirements.txt
```
```bash
grow.rust
βββ marioidival
βββ actix
βββ Cargo.toml
βββ src
βββ main.rs
```
## Docker
You can use Docker or Podman to create your images, remembering that the smaller the better, so try to make the smallest images possible.
We will execute the following command:
```bash
$ docker build --no-cache -f Dockerfile -t growth/:latest .
```
And then we will run it:
```bash
$ docker run --rm -it -p 8080:8080 growth/
```
Feel free to play with the possibilities, you can use docker-compose too, you can use the scale option if you want space for creativity is always welcome π.
## Tests Stress
We will be stress testing your project, so be sure to take this into consideration. We will be using V6 and Locust for the tests and they are located in the root of the repository with the installation and configuration manual. With our example ready and beautiful, just run it π.
## Endpoints to be implemented
The endpoints that must be implemented are listed below, we will follow the same pattern for all projects:
#### POST
Creating our database in memory, this request is asynchronous and will run in the background, but only implement this feature if your language provides support.
```bash
$ curl -i -XPOST -H "Content-Type:application/json" \
localhost:8080/api/v1/growth -d @3mb-growth_json.json
{"msg":"In progress"}
```
#### GET
With this endpoint we can view the status of the processing we sent in [POST]
```bash
$ curl -i -XGET -H "Content-Type:application/json" \
localhost:8080/api/v1/growth/post/status
{"msg":"complete","test value"":183.26, "count":42450}
```
#### GET
This endpoint searches memory to return the result.
```bash
$ curl -i -XGET -H "Content-Type:application/json" \
localhost:8080/api/v1/growth/brz/ngdp_r/2002
{"Country":"BRZ","Indicator":"NGDP_R","Value":183.26,"Year":2002}
```
#### PUT
This endpoint will update the database in memory, if the data does not exist it will create a new one.
```bash
$ curl -i -XPUT -H "Content-Type:application/json" \
localhost:8080/api/v1/growth/brz/ngdp_r/2002 \
-d '{"value":333.98}'
```
#### GET
Making a request to check if what we changed or created new is in the database.
```bash
$ curl -i -XGET -H "Content-Type:application/json" \
localhost:8080/api/v1/growth/brz/ngdp_r/2002
{"Country":"BRZ","Indicator":"NGDP_R","Value":333.98,"Year":2002}
```
#### DELETE
This endpoint will remove the data from our memory database.
```bash
$ curl -i -XDELETE -H "Content-Type:application/json" \
localhost:8080/api/v1/growth/brz/ngdp_r/2002
```
#### GET
This endpoint will return the size of our database in memory.
```bash
$ curl -i -XGET -H "Content-Type:application/json" \
localhost:8080/api/v1/growth/size
{"size":42450}
```