The CSV dataset was taken from this GitHub Gist.
In the first deliverable I have implemented a simple Web API that reads from pokemon.csv and exposes the following endpoints:
/pokemon/{id}: Returns a pokemon's data by id, if exists/pokemon: Returns all pokemons' data
I've also implemented a proposal of the Clean Architecture by dividing code in the following packages:
entity: Entities layerusecase: Use cases layeradapter: Interface adapters layerdataandhttpapi: Framework and drivers layer
For the HTTP framework, I decided to use Gin, mainly because of its popularity and ease of use.
In the second deliverable I have:
- Implemented a
/comments/{id}endpoint that fetches data from the/comments/{id}endpoint of the JSON Placeholder API. Whenever a comment is fetched, it is saved in the localcomment.csvfile. The next time a user requests that particular comment, it will be loaded from the CSV instead of the JSON Placeholder API, for faster response times. - Created a custom HTTP client for making simple GET requests to any URL.
- Wrote more documentation for functions and methods.
- Created test cases for the
usecase,adapterandentitylayers. I'm usingtestifyas testing toolkit. - Refactored the codebase:
- Separated controller logic and route logic into their own packages.
- Created a router group to have API versioning. Currently the
/v1is supported. - Moved configuration logic to its own package in
config.
In the final deliverable I have:
-
Implemented a
/pokemons/type/{parity}/items/{items}/items_per_worker/{items_per_worker}endpoint that returns a JSON array of pokemons filtered by the parity (even or odd) of their ID. This endpoint uses the worker pool pattern to filter the pokemons.The
{items}parameter specifies how many pokemons must at least appear in the array, although if{items}is greater than the amount of total even or odd pokemons, all filtered pokemons will be returned.The
{items_per_worker}parameter specifies at most how many pokemons each worker will process.The amount of workers that are spawned is computed with the following formula:
#workers = ceil(items / items_per_worker)The endpoint is also limited to spawn up to 20 workers. If the amount of workers computed is greater than 20, then the endpoint will return a 400 HTTP error suggesting that the client should decrease the amount of
{items}or increase the amount of{items_per_worker}. -
Wrote documentation for the new logic.
-
Created test cases for the new logic.
Everything below this line is the original README.
Thank you for participating in the Golang Bootcamp course! Here, you'll find instructions for completing your certification.
The purpose of the challenge is for you to demonstrate your Golang skills. This is your chance to show off everything you've learned during the course!!
You will build and deliver a whole Golang project on your own. We don't want to limit you by providing some fill-in-the-blanks exercises, but instead request you to build it from scratch. We hope you find this exercise challenging and engaging.
The goal is to build a REST API which must include:
- An endpoint for reading from an external API
- Write the information in a CSV file
- An endpoint for reading the CSV
- Display the information as a JSON
- An endpoint for reading the CSV concurrently with some criteria (details below)
- Unit testing for the principal logic
- Follow conventions, best practices
- Clean architecture
- Go routines usage
These are the main requirements we will evaluate:
- Use all that you've learned in the course:
- Best practices
- Go basics
- HTTP handlers
- Error handling
- Structs and interfaces
- Clean architecture
- Unit testing
- CSV file fetching
- Concurrency
To get started, follow these steps:
- Fork this project
- Commit periodically
- Apply changes according to the reviewer's comments
- Have fun!
If you are interested in filing the Go Bootcamp in your WizelineOS profile, please contact Academy to assign you a mentor who can review you comply with your capstone project.
We provide the delivery dates so you can plan accordingly; please take this challenge seriously and try to make progress constantly.
For the final deliverable, we will provide some feedback. If you are struggling with something, contact the mentors and peers to get help on time. Feel free to use the slack channel available.
Based on the self-study material and mentorship covered until this deliverable, we suggest you perform the following:
- Create an API
- Add an endpoint to read from a CSV file
- The CSV should have any information, for example:
1,bulbasaur
2,ivysaur
3,venusaur- The items in the CSV must have an ID element (int value)
- The endpoint should get information from the CSV by some field (example: ID)
- The result should be displayed as a response
- Clean architecture proposal
- Use best practices
- Handle the Errors (CSV not valid, error connection, etc)
Note: what’s listed in this deliverable is just for guidance and to help you distribute your workload; you can deliver more or fewer items if necessary. However, if you deliver fewer items at this point, you have to cover the remaining tasks in the next deliverable.
Based on the self-study material and mentorship covered until this deliverable, we suggest you perform the following:
- Create a client to consume an external API
- Add an endpoint to consume the external API client
- The information obtained should be stored in the CSV file
- Add unit testing
- Update the endpoint made in the first deliverable to display the result as a JSON
- Refator if needed
Note: what’s listed in this deliverable is just for guidance and to help you distribute your workload; you can deliver more or fewer items if necessary. However, if you deliver fewer items at this point, you have to cover the remaining tasks in the next deliverable.
- Add a new endpoint
- The endpoint must read items from the CSV concurrently using a worker pool
- The endpoint must support the following query params:
type: Only support "odd" or "even"
items: Is an Int and is the amount of valid items you need to display as a response
items_per_workers: Is an Int and is the amount of valid items the worker should append to the response
-
Reject the values according to the query param type (you could use an ID column)
-
Instruct the workers to shut down according to the query param items_per_workers collected
-
The result should be displayed as a response
-
The response should be displayed when:
- The workers reached the limit
- EOF
- Valid items completed
Important: this is the final deliverable, so all the requirements must be included.
For submitting your work, you should follow these steps:
- Create a pull request with your code, targeting the master branch of your fork.
- Fill this form including the PR’s url
- Stay tune for feedback
- Do the changes according to the reviewer's comments
- Go Tour
- Go basics
- Git
- Tool to practice Git online
- Effective Go
- How to write code
- Go by example
- Go cheatsheet
- Any talk by Rob Pike
- The Go Playground
- Golang Docs
- Constants
- Variables
- Types
- For Loops
- Conditional statements: If
- Multiple options conditional: Switch
- Arrays and Slices
- Clean Architecture
- Maps
- Functions
- Error Handling
- Structures
- Structs and Functions
- Pointers
- Methods
- Interfaces
- Interfaces
- Packages
- Failed requests handling
- Modules
- Unit testing
- Go tools
- More Go tools
- Functions as values
- Concurrency (goroutines, channels, workers)