GithubHelp home page GithubHelp logo

gemini's Introduction

Overview

Pet project about how to connect to mongodb, work with gRPC and HTTP/REST. Code structure follows clean code (not fully, I guess :D).

Setup project

  1. clone .env.example and change its name to .env
  2. create mongodb database with event collection
  3. This project uses go dep to manage dependencies. So after install go dep run dep ensure.
  4. RUN go run cmd/main.go or go build cmd/main.go && ./main
  5. Use whatever you like to test RESTful API (I personally like using insomnia). For event api I create 2 endpoints:
    • curl -X GET 'http://localhost:8080/v1/event' (for event list)
    • curl -X POST 'http://localhost:8080/v1/event' -d '{"body": "test 3ewjrhewjfk"}' (for create)

Structure

pb

this folder contains our gRPC proto files. I use v1 folder for versioning api. Each *.proto file represents APIs relevant to an entity inside storage folder. After create an proto file run ./protoc-gen.sh {version} {entity} (ex: ./protoc-gen.sh v1 event) to generate others files.

storage

this is where our entities live. Each file declares entity struct and methods to interact with it.

service

If you familiar with repository-service pattern, this is where we write business logic.

handler

handler is api endpoints

cmd

main package, it calls run server gRPC and HTTP/REST

gemini's People

Contributors

quyennguyenvu 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.