This repository contains the source code for the Integra Coding Assessment project, which includes a Go backend and an Angular frontend. The project uses Docker to manage dependencies and run services in a containerized environment.
integra-coding-assessment/
├── .gitignore
├── .env
├── go-backend/
│ ├── Dockerfile
│ ├── go.mod
│ ├── go.sum
│ ├── main.go
│ ├── db/
│ │ ├── db.go
│ │ ├── migrations/
│ │ │ ├── 001_create_users_table.up.sql
│ │ │ ├── 001_create_users_table.down.sql
│ ├── handlers/
│ │ └── user_handler.go
│ ├── models/
│ │ └── user.go
│ └── docs/
│ └── swagger.go
├── angular-frontend/
│ ├── Dockerfile
│ ├── src/
│ ├── package.json
│ └── ...
└── docker-compose.ymlEnsure you have the following installed on your system:
-
Clone the Repository:
git clone https://github.com/sedmo/integra-coding-assessment.git cd integra-coding-assessment -
Create the
.envFile:-
In the root directory of your project, create a
.envfile:POSTGRES_USER=yourusername POSTGRES_PASSWORD=yourpassword POSTGRES_DB=yourdatabase DATABASE_URL=postgres://yourusername:yourpassword@postgres:5432/yourdatabase?sslmode=disable API_URL=http://localhost:1323
-
-
Build and Run the Docker Containers:
docker-compose up --build -d
-
Verify the Setup:
Ensure all containers are running:
docker-compose ps
The Go backend runs on port 1323 and connects to a PostgreSQL database.
- Dockerfile:
go-backend/Dockerfile - Service Definition:
docker-compose.ymlunderbackendservice
The Angular frontend is built using Node.js and served using Nginx. It runs on port 80.
- Dockerfile:
angular-frontend/Dockerfile - Service Definition:
docker-compose.ymlunderfrontendservice
A PostgreSQL database is used for data storage. It runs on port 5432.
- Service Definition:
docker-compose.ymlunderpostgresservice - Volume:
postgres_datafor data persistence
API Documentation with Swagger Swagger is used to generate and serve API documentation for the Go backend.
Swagger UI: http://localhost:1323/swagger/index.html
To generate Swagger documentation, use the swag CLI tool:
Install swag CLI:
go get -u github.com/swaggo/swag/cmd/swagGenerate Swagger Documentation:
swag init -g main.goRunning Migrations Applying Migrations Migrations are used to manage database schema changes.
Up Migrations:
Migrations are applied automatically when the backend service starts.
Down Migrations:
To roll back the latest migration:
docker-compose run backend ./main -migrate-downRunning Tests Go Backend Tests To run the tests for the Go backend:
Navigate to the go-backend Directory:
cd go-backendRun the Tests:
go test ./...Angular Frontend Tests To run the tests for the Angular frontend:
Navigate to the angular-frontend Directory:
cd angular-frontendInstall Dependencies:
npm installRun the Tests:
npm testAccessing the Application Backend API: http://localhost:1323 Frontend Application: http://localhost
Stopping the Application To stop the running Docker containers:
docker-compose downCleaning Up To remove all Docker containers, networks, and volumes associated with the project:
docker-compose down -v