Skip to content

sedmo/integra-coding-assessment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Integra Coding Assessment

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.

Project Structure

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.yml

Prerequisites

Ensure you have the following installed on your system:

Setting Up the Project

  1. Clone the Repository:

    git clone https://github.com/sedmo/integra-coding-assessment.git
    cd integra-coding-assessment
  2. Create the .env File:

    • In the root directory of your project, create a .env file:

      POSTGRES_USER=yourusername
      POSTGRES_PASSWORD=yourpassword
      POSTGRES_DB=yourdatabase
      DATABASE_URL=postgres://yourusername:yourpassword@postgres:5432/yourdatabase?sslmode=disable
      API_URL=http://localhost:1323
  3. Build and Run the Docker Containers:

    docker-compose up --build -d
  4. Verify the Setup:

    Ensure all containers are running:

    docker-compose ps

Services

Go Backend

The Go backend runs on port 1323 and connects to a PostgreSQL database.

  • Dockerfile: go-backend/Dockerfile
  • Service Definition: docker-compose.yml under backend service

Angular Frontend

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.yml under frontend service

PostgreSQL Database

A PostgreSQL database is used for data storage. It runs on port 5432.

  • Service Definition: docker-compose.yml under postgres service
  • Volume: postgres_data for 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/swag

Generate Swagger Documentation:

swag init -g main.go

Running 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-down

Running Tests Go Backend Tests To run the tests for the Go backend:

Navigate to the go-backend Directory:

cd go-backend

Run the Tests:

go test ./...

Angular Frontend Tests To run the tests for the Angular frontend:

Navigate to the angular-frontend Directory:

cd angular-frontend

Install Dependencies:

npm install

Run the Tests:

npm test

Accessing the Application Backend API: http://localhost:1323 Frontend Application: http://localhost

Stopping the Application To stop the running Docker containers:

docker-compose down

Cleaning Up To remove all Docker containers, networks, and volumes associated with the project:

docker-compose down -v

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published