This repository contains my solution for the coding challenge during the onboarding process as a Go developer for Schwarz IT. It aims to address various code smells and security issues identified in the original code.
The repository is organized into the following subfolders:
cmd
: Contains themain.go
file that initializes and starts the server.internal
: Contains the core server code, including routing and middleware.tests
: Contains integration test files for validating the application functionality.
The backend is structured into three main layers:
-
API Layer (
api
):- Responsible for server configuration and defining request handlers.
-
Service Layer (
service
):- Contains the business logic of the application, ensuring separation of concerns.
-
Repository Layer (
repository
):- Manages data storage. This implementation currently uses an in-memory storage solution.
To run the application using the Makefile, follow these steps:
- Clone the repository:
git clone https://github.com/Yousef-Hammar/go-code-review cd go-code-review
- Create a .env file containing the following line:
ADDR=8080
- Run the application with Docker:
make docker-run
This command will build the Docker image and run the server, using the environment variables specified in the .env file.
To run tests using the Makefile, you have two options:
1. Run Unit Tests:
make run-unit-tests
2. Run Integration Tests:
make run-integration-tests
These commands will execute all unit tests and integration tests, respectively, providing detailed output.