Importer

A file importer for a database (postgres), proposed by the company enube as a form of technical challenge.

MIT License

Stars
0
Committers
2

Enube-challenge

Enube-Challenge is a file import application developed in Golang. This project follow good software development practices and features robust functionalities, including user authentication with JWT tokens, CI/CD pipelines for seamless integration, and data management using PostgreSQL. Designed to handle and import supplier data, the application provides endpoints for user authentication, creation and retrieval of user information, and supplier management.

Techs

Endpoints

Authentication

  • POST /api/v1/authentication/sign-in: Log in a user and generate a token access

Users

  • POST /api/v1/users/ : Create a new user
  • GET /api/v1/users/:email : Get a user By email

Suppliers

  • POST /api/v1/suppliers/ : Import all suppliers from a file
  • GET /api/v1/suppliers : Get all suppliers with pagination
  • GET /api/v1/suppliers/:id : Get a suppliers by id

Docs api (Github pages)

Running this project

Environment Setting

  1. Clone the repository
git clone https://github.com/hebertsanto/Enube-challenge
cd Enube-challenge

2 Set the environment variables

USER_DATABASE="your_user_database"
USER_PASSWORD="your_password"
DATABASE="your_database"
PORT="port_database"
HOST="host_databse"
SECRET_JWT="secret_jwt"

3 Install dependencies

go mod tidy

4 Run the application

go run cmd/api/main.go

Pipeline

This project includes a pipeline configured to deploy the application to Docker Hub. The pipeline is configured to build and push the Docker image whenever there are changes to the repository.

# Use the official Golang image as a parent image
FROM golang:1.22.0-alpine

# Set the working directory inside the container
WORKDIR /app

# Copy go.mod and go.sum files and download dependencies
COPY go.mod go.sum ./
RUN go mod download

# Copy the rest of the application code to the container
COPY . .

# Build the Go application
RUN go build -o enube-challenge ./cmd/api/main.go

# Expose port 8080 to the outside world
EXPOSE 8080

# Define the command to run the application
CMD ["./enube-challenge"]

The entire deployment process is automated with a GitHub Action, streamlining integration and deployment to various services.

Design patterns

1 Dependency injection

2 Dependency inversion

3 Data Transfer Objects

Postman collection

Conclusion

I really enjoyed doing this challenge, I learned a lot of important concepts about the language and new ways of solving problems, it was a great experience.

  • Processing xlsx

It was a really cool challenge to process this file, I learned several language features, the data was processed in 3 minutes as shown in the image

In short, I loved participating in this process, I believe it was very good for my growth and learning.