Git Product home page Git Product logo

cake-store-be-test's Introduction

๐Ÿฐ Cake Store API

โš™๏ธ Specifications

Written in Go version : 1.19

๐Ÿ“š Repo Structure

โ”œโ”€โ”€ handler
โ”œโ”€โ”€ libs
โ”‚   โ”œโ”€โ”€ logger
โ”‚   โ””โ”€โ”€ util
โ”œโ”€โ”€ logs
โ”œโ”€โ”€ migrations
โ”œโ”€โ”€ repository
โ”œโ”€โ”€ schema
โ”œโ”€โ”€ server
โ”‚   โ””โ”€โ”€ middleware
โ””โ”€โ”€ service
  • handler contains go package layer to handle requests from http (request layer)
  • libs contains shared code that can be used on each packages
  • logs contains logging file
  • migrations contains migrations file
  • repository contains go package layer to serve a requests from service (source data layer)
  • schema contains shared code that can be used on other packages in context entity structure
  • server contains a go http server and middleware
  • service contains go package layer to serve a requests from handler (business logic layer)

๐Ÿ”ง Running Locally

To run this project you need some preparation :

  • create database 'cake-store'
  • installing migrator tools download from golang migrate in release page
  • migrate -path ./migrations -database "mysql://root:secret@tcp(localhost:3306)/cake-store" -verbose up run this command to up a migration (you can look from Makefile)
  • go mod tidy installing a module
  • go run . run it

To test api you can use a OpenApi extension from vs code. Open API on VSCode

If you want easily to run this project, use with docker compose and run a migration (install migrator tools first) :

docker compose up -d
migrate -path ./migrations -database "mysql://root:secret@tcp(localhost:3306)/cake-store" -verbose up

If you wanna change a environment you can change in docker-compose.yml.

Then to run the project locally, the default port is 3000 you can change a port hard code :

go mod tidy
go run .

๐Ÿ“ฐ Info

This project using a distroless for image, you can freely switch between a production and development :

Development : gcr.io/distroless/static-debian11:debug use this image you can access a shell iinteractive Production : gcr.io/distroless/static-debian11:latest use this image you only can access logs from docker

This project has tracker_id to provide developer finding a error in log file easily, to look a logs file you can looking in docker volume and inspect it other information in docker compose file, or if you run manually with go run . you can open ./logs/logging.log and open with text editor.

๐Ÿ”ง Deploying

  1. Install docker
  2. Run docker compose
docker compose up -d

๐Ÿ“ฆ Go Library

Using Go Chi as router for building HTTP services, looking a Docs.

๐Ÿ“ฐ Go Article

Download Golang Binnary

How to install Go in PC / Laptop / Server

๐Ÿ“š Go Book

Go Tutorial - Bahasa

๐Ÿ’ก Go Command

CMD List Golang

๐Ÿงท Recommended IDE

Visual Studio Code

๐Ÿ”ง Recommended Extension Visual Studio Code

OpenAPI on VSCode

GO Extension on VSCode

cake-store-be-test's People

Contributors

alizufan avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.