Skip to content

navindu-sachintha/booker_go

Repository files navigation

Booker 📚

| Technologies | Getting Started | API Endpoints |

Backend API for Booksore powered with golang

Visit the Project

💻 Technologies

  • Go toolchain
  • goose (for database migration)
  • SQLC (For generate Go codes to queries)
  • POSTGRE SQL
  • Docker (For database instance & containorize app)
  • GIN for web framework

🚀 Getting started

Here you describe how to run your project locally

Prerequisites

Here you list all prerequisites necessary for running your project. For example:

Cloning

git clone https://github.com/navindu-sachintha/booker_go.git

Config .env variables

Use the .env.example as reference to create your configuration file .env with your environment variables in root

DB_URL=postgresql://<your_username>:<your_password>@localhost:5432/<your_db_name>?sslmode=disable

Edit docker-compose.yml file

Make sure to replace `docker-compose.yml` with your database info
environment:
      POSTGRES_USER: your_username
      POSTGRES_PASSWORD: your_password
      POSTGRES_DB: your_database_name

Starting

How to start your project

cd booker_go

# Execute docker postgres instance
docker compose run db

cd /sql/schema

# Run Database migration
goose postgres DB_URL up

cd ../../

# Download dependencies
go mod download
go mod tidy && go mod vendor

cd /cmd/main

# Build go Application
go go build -o ../../bookstoreapp

cd ../../
./bookstoreapp

📍 API Endpoints

route description
POST /book Create book in database
GET /books Get all available books
GET /book/:id Get Book by its ID
PUT /book/:id Update Book name according to id
DELETE /book Delete book by it's id

Since it using docker volume data will be not removed even after container removed