Skip to content

The Go Library is an application that uses Go, with the purpose to achieve my goal which is to work at Dialog💚. The API saves 6.8M authors in Postgres DB, and makes available a Books' CRUD. Made with Go, Postgres,Fiber, Docker and pgx.

License

Notifications You must be signed in to change notification settings

leonardo-jesus/go-library-crud

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Library 💚

Must-Have   |    Improvement Points   |    Resources   |    Technologies   |    Project   |    Requirements   |    How to Run   |    Work Environment   |    How to contribute   |    License

PRs welcome! License


✅ Must-Have

✔️ You should implement an application for a library to store book and authors data(This application must provide an HTTP REST API to attend the requirements).
✔️ Receive a CSV with authors and import to database. Given a CSV file with many authors (authors.csv), you need to build a command to import the data into the database.
✔️ You need to store the authors' data to complement the book data that will be stored
✔️ Expose authors' data in an endpoint. This endpoint needs to return a paginated list with the authors' data. Optionally the authors can be searched by name.
✔️ CRUD (Create, Read, Update and Delete) of books.
✔️ To retrieve a book we can filter by 4 fields (name, publicationYear, edition and author). But these 4 filters are optional. It must be possible to navigate all the books' data without any filter.
✔️ To create a book, the user should be able to send a field author, with the book's authors' ids.
✔️ Provide a working environment with your project (eg. Heroku).
✔️ Application must be written in Go.
✔️ Every text or code must be in English.
✔️ Write the project documentation containing:
✔️ Provide API documentation (in English);

💪 Improvement Points

Due to the tight deadline, it was not possible to accomplish everything I had planned initially. I originally intended to follow the Pub/Sub Pattern, where a REST API would handle incoming requests, and for heavier tasks such as creation and updating, it would send them to a RabbitMQ queue to be consumed by a Go consumer. This is why the API is located inside the go-rest-api folder. However, due to time constraints, I ended up simplifying the implementation significantly and having only one API handle everything.

  • Pub/Sub pattern implementation to store and retrieve data (eg. RabbitMQ)
  • Microservices architecture (Gateway -> Message Boker -> Consumer)
  • Redis caching to frequent GET requests
  • Goroutine implementation to insert bulk data into database
  • Unit and integration tests

📦 Resources

🚀 Technologies

This project was developed with the following technologies:

💻 Project

The Go Library is an application that uses Go, with the purpose to achieve my goal which is to work at Dialog💚. The API saves 6.8M authors in Postgres DB, and makes available a Books' CRUD. Made with Go, Postgres, Fiber, Docker and pgx.

🔧 Requirements

To run this Go application, you will need to have only Docker and Docker Compose on your computer.

🐳 Docker allows you to create and manage containers that encapsulate your application and its dependencies.

Docker Compose is a tool that allows you to define and manage multi-container Docker applications. Docker Compose usually comes bundled with Docker, so if you have installed Docker using the official installer, Docker Compose should be included. You can verify its installation by running the command docker compose version or docker-compose --version in your terminal.

🏃 How to Run

  1. Make a clone;
  2. Open the project on your terminal;
  3. Run cd ./go-rest-api
  4. Run cp .env.example .env to copy environment variables
  5. Run docker compose run --rm api go mod tidy to install Dependencies;
  6. Run docker compose --profile tools run migration to create the tables on database
  7. Run docker compose up to run the server;
  • By default the server will run at localhost:3333 and the Postgres DB at localhost:5432.

More informations at API's Documentation or import the Postman Collection.

⚙️ Work Environment

  • AMD Ryzen 5 3600, 16GB RAM, GTX 1660
  • WSL 2 (Ubuntu 22.04.2 LTS)
  • Visual Studio Code
  • Docker version 23.0.5
  • Docker Compose version v2.17.3
  • Go 1.20.4 linux/amd64
  • DBeaver Community Edition 23.0.5
  • Postman 10.15.4
  • Git version 2.34.1

🤔 How to contribute

  • Make a fork;
  • Create a branch with your feature: git checkout -b my-feature;
  • Do commit with your changes: git commit -m 'feat: My new feature';
  • Do a push for your branch: git push origin my-feature.

After the merge of your pull request was made, you can delete your branch.

📝 License

This project is under License MIT. See the documentation LICENSE for more details.


Developed by Leonardo Jesus ©️

About

The Go Library is an application that uses Go, with the purpose to achieve my goal which is to work at Dialog💚. The API saves 6.8M authors in Postgres DB, and makes available a Books' CRUD. Made with Go, Postgres,Fiber, Docker and pgx.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 98.4%
  • Dockerfile 1.6%