Coder Social home page Coder Social logo

desafio-padawan-go's Introduction

Padawan Challenge Repository

This repository is about my implementation of the Padawan Challenge Vacancy

Requirements

Make sure you have the following tools installed on your system:

Configuration and Execution

  1. Clone this repository to your system:
git clone https://github.com/richardnfag/desafio-padawan-go.git
  1. Navigate to the project directory:
cd desafio-padawan-go
  1. Execute the following command to create and start the Docker containers:
docker-compose up -d

This will create and start the necessary containers for the project, including a container for the database.

  1. After the database and application containers are running, execute the database migrations:
docker-compose run --rm web make migrate
  1. After the containers are initialized and the migrations are applied, the API will be accessible at localhost:8000.
    Access: http://localhost:8000/exchange/10/BRL/USD/4.50 The response should follow the following format:
    {
      "valorConvertido": 45,
      "simboloMoeda": "$"
    }
    
  2. To run the tests, use the following command:
docker-compose run --rm web make test

Challenge Resolution

The following conversions were requested:

Another request was to retain the history for future queries. To view the history, use the following command:

QUERY="SELECT c.amount, f.code AS from_currency, t.code AS to_currency, c.rate, c.result
       FROM conversions c
       INNER JOIN currencies f ON c.from_currency_id = f.id
       INNER JOIN currencies t ON c.to_currency_id = t.id"

docker-compose run --rm db mysql -u exchange -h db -pexchange -Dexchange_db -e "$QUERY"

Design and Architecture Decisions

Technologies Used

Go: The chosen programming language for the project.

GORM: An Object-Relational Mapping (ORM) framework for Go, used to simplify interaction with the database.

ATLAS: A migration manager that helps control changes in the database schema.

Docker: A platform that enables packaging the application, its dependencies, and configurations in an isolated environment.

Ports and Adapters (Hexagonal Architecture)

For this project, the Ports and Adapters architecture, also known as Hexagonal Architecture, was used. It aims to clearly separate core application concerns from external concerns, such as user interfaces, external services, and databases. This approach promotes a more cohesive organization and facilitates independent evolution of different parts of the system.

Testability and Evolution

The Ports and Adapters architecture promotes testability and continuous evolution of the system, allowing core parts to be tested independently and adapters to be replaced with new implementations without affecting the core of the application.

Flexibility and Maintenance

The clear separation between the core application and the adapters provides flexibility in choosing technologies and facilitates system maintenance over time. Changes in external components can be accommodated without affecting the internal functioning of the application.

Directory Structure

.
├── Dockerfile # Dockerfile is the configuration file of the application
├── Makefile # Makefile is the automation script of the application
├── README.md 
├── atlas.hcl # Atlas is the configuration file of the application
├── bin # Bin is the output directory of the application
├── cmd # Cmd is the entrypoint of the application
│   └── main.go
├── coverage # Coverage is the directory of the coverage report
├── docker-compose.yml # Docker-compose is the configuration file of the application
├── go.mod # Go.mod is the dependency manager of the application
├── go.sum 
├── internal # Houses the core application logic, including use cases, domain models, and business rules.
│   ├── adapters # Adapters are the implementation of the ports
│   │   ├── database
│   │   │   ├── gorm_conversion_repository.go
│   │   │   ├── gorm_conversion_repository_test.go
│   │   │   ├── gorm_currency_repository.go
│   │   │   └── gorm_currency_repository_test.go
│   │   └── http
│   │       ├── http_handler.go
│   │       └── http_handler_test.go
│   ├── entities # Entities are the representation of the domain
│   │   ├── conversion_entity.go
│   │   └── currency_entity.go
│   ├── ports # Ports are the interfaces that define the contract of the adapters
│   │   ├── conversion_repository.go
│   │   └── currency_repository.go
│   └── services # Services are the use cases of the application
│       ├── conversion_service.go
│       └── conversion_service_test.go
└── migrations # Migrations are the database migrations
    ├── 20230816135044.sql
    ├── 20230816135153_add_currencies.sql
    └── atlas.sum # Atlas.sum is the summary of the migrations


# Note: The test files are organized adjacent to their respective targets with the _test suffix for improved maintainability.

desafio-padawan-go's People

Contributors

lfoliveir4 avatar medeirosfalante avatar richardnfag avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.