Giter VIP home page Giter VIP logo

myapp's Introduction

Learning Cloud Native Go - myapp

๐ŸŒฑ Cloud Native Application Development is one way of speeding up the building of web applications using microservices, containers, and orchestration tools.

This repository shows how to build a Dockerized RESTful API application in Go for a simple bookshelf.

๐Ÿ”‹ Batteries included

  • The idiomatic structure based on the resource-oriented design.
  • The usage of Docker, Docker compose, Alpine images, and linters on development.
  • Healthcheck and CRUD API implementations with OpenAPI specifications.
  • The usage of Goose for the database migrations and GORM as the database ORM.
  • The usage of Zerolog as the centralized Syslog logger.
  • The usage of Validator.v10 as the form validator.
  • The usage of GitHub actions to run tests and linters, generate OpenAPI specifications, and build and push production images to the Docker registry.

๐Ÿš€ Endpoints

Name HTTP Method Route
Health GET /livez
List Books GET /v1/books
Create Book POST /v1/books
Read Book GET /v1/books/{id}
Update Book PUT /v1/books/{id}
Delete Book DELETE /v1/books/{id}

๐Ÿ’ก swaggo/swag : swag init -g cmd/api/main.go -o .swagger -ot yaml

๐Ÿ—„๏ธ Database design

Column Name Datatype Not Null Primary Key
id UUID โœ… โœ…
title TEXT โœ…
author TEXT โœ…
published_date DATE โœ…
image_url TEXT
description TEXT
created_at TIMESTAMP โœ…
updated_at TIMESTAMP โœ…
deleted_at TIMESTAMP

๐Ÿ“ฆ Container image sizes

  • DB: 241MB
  • API
    • Development environment: 655MB
    • Production environment: 28MB ; ๐Ÿ’กdocker build -f prod.Dockerfile . -t myapp_app

๐Ÿ“ Project structure

myapp
โ”œโ”€โ”€ cmd
โ”‚  โ”œโ”€โ”€ api
โ”‚  โ”‚  โ””โ”€โ”€ main.go
โ”‚  โ””โ”€โ”€ migrate
โ”‚     โ””โ”€โ”€ main.go
โ”‚
โ”œโ”€โ”€ api
โ”‚  โ”œโ”€โ”€ router
โ”‚  โ”‚  โ””โ”€โ”€ router.go
โ”‚  โ”‚
โ”‚  โ””โ”€โ”€ resource
โ”‚     โ”œโ”€โ”€ health
โ”‚     โ”‚  โ””โ”€โ”€ handler.go
โ”‚     โ”œโ”€โ”€ book
โ”‚     โ”‚  โ”œโ”€โ”€ api.go
โ”‚     โ”‚  โ”œโ”€โ”€ handler.go
โ”‚     โ”‚  โ”œโ”€โ”€ model.go
โ”‚     โ”‚  โ””โ”€โ”€ repository.go
โ”‚     โ””โ”€โ”€ common
โ”‚        โ””โ”€โ”€ err
โ”‚           โ””โ”€โ”€ err.go
โ”‚
โ”œโ”€โ”€ migrations
โ”‚  โ””โ”€โ”€ 00001_create_books_table.sql
โ”‚
โ”œโ”€โ”€ config
โ”‚  โ””โ”€โ”€ config.go
โ”‚
โ”œโ”€โ”€ util
โ”‚  โ”œโ”€โ”€ logger
โ”‚  โ”‚  โ””โ”€โ”€ logger.go
โ”‚  โ””โ”€โ”€ validator
โ”‚     โ””โ”€โ”€ validator.go
โ”‚
โ”œโ”€โ”€ .env
โ”‚
โ”œโ”€โ”€ go.mod
โ”œโ”€โ”€ go.sum
โ”‚
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ Dockerfile
โ”‚
โ”œโ”€โ”€ prod.Dockerfile
โ””โ”€โ”€ k8s
   โ”œโ”€โ”€ app-configmap.yaml
   โ”œโ”€โ”€ app-secret.yaml
   โ”œโ”€โ”€ app-deployment.yaml
   โ””โ”€โ”€ app-service.yaml

๐Ÿ“ธ Form validations and logs

Form validation

Logs in app init Logs in crud

myapp's People

Contributors

dumindu avatar josemukorivo avatar vsel avatar

Watchers

James Cloos 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.