Code Monkey home page Code Monkey logo

myapp's Introduction

Learning Cloud Native Go - myapp

Cloud Native Application Development is a one way of speeding up building web applications, using micro-services, containers and orchestration tools.

As the first step, this repository shows How to build a Dockerized RESTful API application using Go.

๐Ÿ’ก Refer learning-cloud-native-go.github.io or commit messages and step- branches for a step by step guild.

Points to Highlight

๐Ÿ’ญ Hope to use Wire for Compile-time Dependency Injection in the future.

Endpoints

endpoints

Docker Image Sizes

  • DB: 229MB
  • App
    • Development environment: 728MB
    • Production environment: 21.8MB

๐Ÿ’ก Building Docker image for production docker build -f docker/app/prod.Dockerfile . -t myapp_app

Design Decisions & Project Folder Structure

  • Store Docker related files inside the docker folder. But keep the docker-compose.yml file in the project root.
  • Store executable packages inside the cmd folder.
  • Store database migrations inside the migrations folder.
  • Store main application code inside the app folder.
  • Store reusable packages like configs, utils, models and repositories in separate folders. This will be helpful if you are adding more executable applications to support web front-ends, publish/subscribe systems, document stores and etc.
.
โ”œโ”€โ”€ docker
โ”‚  โ””โ”€โ”€ app
โ”‚     โ”œโ”€โ”€ bin
โ”‚     โ”‚  โ”œโ”€โ”€ init.sh
โ”‚     โ”‚  โ””โ”€โ”€ wait-for-mysql.sh
โ”‚     โ””โ”€โ”€ Dockerfile
โ”œโ”€โ”€ docker-compose.yml
โ”‚
โ”œโ”€โ”€ cmd
โ”‚  โ”œโ”€โ”€ app
โ”‚  โ”‚  โ””โ”€โ”€ main.go
โ”‚  โ””โ”€โ”€ migrate
โ”‚     โ””โ”€โ”€ main.go
โ”‚
โ”œโ”€โ”€ migrations
โ”‚  โ””โ”€โ”€ 20190805170000_create_books_table.sql
โ”‚
โ”œโ”€โ”€ app
โ”‚  โ”œโ”€โ”€ app
โ”‚  โ”‚  โ”œโ”€โ”€ app.go
โ”‚  โ”‚  โ”œโ”€โ”€ book_handler.go
โ”‚  โ”‚  โ”œโ”€โ”€ health_handler.go
โ”‚  โ”‚  โ””โ”€โ”€ index_handler.go
โ”‚  โ”œโ”€โ”€ requestlog
โ”‚  โ”‚  โ”œโ”€โ”€ handler.go
โ”‚  โ”‚  โ””โ”€โ”€ log_entry.go
โ”‚  โ””โ”€โ”€ router
โ”‚     โ”œโ”€โ”€ middleware
โ”‚     โ”‚  โ”œโ”€โ”€ content_type_json.go
โ”‚     โ”‚  โ””โ”€โ”€ content_type_json_test.go
โ”‚     โ””โ”€โ”€ router.go
โ”‚
โ”œโ”€โ”€ config
โ”‚  โ””โ”€โ”€ config.go
โ”‚
โ”œโ”€โ”€ adapter
โ”‚  โ”œโ”€โ”€ db
โ”‚  โ”‚  โ””โ”€โ”€ db.go
โ”‚  โ””โ”€โ”€ gorm
โ”‚     โ””โ”€โ”€ gorm.go
โ”‚
โ”œโ”€โ”€ util
โ”‚  โ”œโ”€โ”€ logger
โ”‚  โ”‚  โ”œโ”€โ”€ logger.go
โ”‚  โ”‚  โ””โ”€โ”€ logger_test.go
โ”‚  โ””โ”€โ”€ validator
โ”‚     โ””โ”€โ”€ validator.go
โ”‚     โ””โ”€โ”€ validator_test.go
โ”‚
โ”œโ”€โ”€ model
โ”‚  โ””โ”€โ”€ book.go
โ”œโ”€โ”€ repository
โ”‚  โ””โ”€โ”€ book.go
โ”‚
โ”œโ”€โ”€ go.mod
โ””โ”€โ”€ go.sum

๐Ÿ’ก About app/app/app.go; Some prefer app/server/server.go or http/app/app.go

Form Validation

Form validation

Logs

Logs in app init Logs in crud

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.