# README
Segment3D Backend
This project is a part of the backend service for the Segment3D App. It is built using Go, a statically typed, compiled programming language designed for simplicity and performance. The API provides core functionality for both the Segment3D Mobile and Web applications. For database management, the project uses PostgreSQL, and it leverages Docker for containerization, ensuring consistency across different development and production environments. Additionally, the project utilizes Air for live reloading during development, streamlining the development process by automatically restarting the server on code changes.
Table of Contents
Getting Started
Prerequisites
Ensure you have the following tools installed on your machine:
- Go v1.21.6
- Docker and Docker Compose
- Scoop (for Windows) or Homebrew (for macOS) (to install additional tools like
golang-migrate
) - Air (for live reloading during development)
Installation
-
Clone the repository:
git clone https://github.com/segment3d-app/backend.git cd backend
-
Install dependencies:
go get -u ./...
-
Install
golang-migrate
: The golang-migrate package is a CLI tool that you can use to run migrations. You can easily install it on various operating systems such as Linux, Mac and Windows by using package managers like curl, brew, and scoop, respectively.- using curl
curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey| apt-key add - echo "deb https://packagecloud.io/golang-migrate/migrate/ubuntu/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/migrate.list apt-get update apt-get install -y migrate
- using homebrew
brew install golang-migrate
- using scoop
scoop install migrate
Configuration
-
Create RabbitMQ Container simply by running the Makefile script:
make run-rabbitmq make rabbitmq-up
-
Create and run PostgreSQL Container simply by running the Makefile script:
make run-postgres make postgres-up
-
Create Database Schema:
make create-db
-
Run Migrations:
make migrate-up
-
Copy the
.env.example
file to.env
:cp .env.example .env
Usage
Running the Server
make server-dev
Running with Docker Compose
You can also run the entire application using Docker Compose. This will set up the necessary containers for the backend and any other services you may have.
-
Build and start the application using Docker Compose:
docker-compose up --build
This command will build the Docker image and start the containers, and you can access the API at
http://localhost:8080
. -
Stop the application:
To stop the running containers, use:
docker-compose down
Running All Services
If you want to run all services, you can visit Deployment Master Services
API Documentation
To access the API documentation, visit the Swagger documentation at http://localhost:8080/swagger/index.html
after starting the server.
License
This project is licensed under the MIT License.