Skip to content

2110366-2566-2/suechaokhai-backend

Repository files navigation

Getting Started

Frontend

  1. Clone repository
git clone https://github.com/brain-flowing-company/psuechaokhai-backend.git
  1. Start backend server
docker-compose up -d --build --no-deps # note: frontend only
  1. pgAdmin is available at localhost:5050
Field Value
pgAdmin Username admin@admin.com
pgAdmin Password admin
Host name/address db
Port 5432
Username postgres
Password 123456

Backend

Prerequisite

  • Golang
  • Makefile (optional)
  • docker
  • git
  • swagger
  1. Clone repository
git clone https://github.com/brain-flowing-company/psuechaokhai-backend.git
  1. Copy .env.example to .env

  2. Get Swagger cli

go install github.com/swaggo/swag/cmd/swag@latest
  1. Run development server
docker-compose -f docker-compose.dev.yaml up -d --build --no-deps # note: backend only
# or
make up
  1. pgAdmin is available at localhost:5050
Field Value
pgAdmin Username admin@admin.com
pgAdmin Password admin
Host name/address db
Port 5432
Username postgres
Password 123456

Note: make sure you have Makefile before using make command

  • This will automatically start postgres database and development server with auto-reload.
  • Swagger (API docs) is at localhost:8000/docs *change port if your app is running on different port
  • If you've made any changes to API docs (comments above handler function), make sure you run this command to update API docs page.
swag init -g ./cmd/main.go -o ./docs/
# or
make docs

Project structures

  • cmd/ contains main.go
  • config/ contains env var loader
  • database/ contains database (postgres) connector
  • internal/
    • name folder by service name (snake_case)
    • .handler.go handles http request
    • .service.go holds core logic
    • .repository.go holds data fetcher (database queries or external api calls)

Contribution

  1. Make sure to pull the latest commit from dev branch
git pull origin dev
  1. Create new branch with your git GUI tools or use this command
git checkout -b <branch-name>
  1. Make sure you on the correct branch
  2. Craft your wonderful code and don't forget to commit frequently
git add <file-path> # add specific file
# or
git add . # add all files
git commit -m "<prefix>: <commit message>"

Note: check out commit message convention

  1. Push code to remote repository
  2. Create pull request on github

Commit message convention

git commit -m "<prefix>: <commit message>"
  • use lowercase
  • meaningful commit message

Prefix

  • feat: introduce new feature
  • fix: fix bug
  • refactor: changes which neither fix bug nor add a feature
  • chore: changes to the build process or extra tools and libraries

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages