Giter VIP home page Giter VIP logo

mecitsemerci / go-todo-app Goto Github PK

View Code? Open in Web Editor NEW
27.0 1.0 8.0 31.05 MB

Go + Angular Todo App, This repository is a todo sample go and angular web project built according to Clean Architecture.

Home Page: https://mecitsemerci.github.io/go-todo-app/

Go 61.90% Dockerfile 2.76% Shell 0.46% Makefile 1.05% JavaScript 2.69% TypeScript 24.26% HTML 5.35% SCSS 1.53%
golang clean-architecture ddd swagger gin-gonic angular11

go-todo-app's Introduction

Go

Go + Angular Todo APP Project Template

This repository is a todo sample go and angular web project built according to Clean Architecture.

Technologies

Web UI Preview

GitHub Logo

Open API Doc Preview

GitHub Logo

Layers and Dependencies

cmd (application run)

Main application executive folder. Don't put a lot of code in the application directory. The directory name for each application should match the name of the executable you want to have (e.g., /cmd/myapp). It's common to have a small main function that imports and invokes the code from the /internal and /pkg directories and nothing else.

internal (application codes)

Private application and library code. This is the code you don't want others importing in their applications or libraries.

  • core includes application core files (domain objects, interfaces). It has no dependencies on another layer.
  • pkg includes external dependencies files and implementation of core interfaces.

test (integration tests)

Application integration test folder.

web (web ui)

Web application specific components: static web assets, server side templates and SPAs.

docs (openapi docs)

open api (swagger) docs files. Swaggo generates automatically.

swag init -g ./cmd/api/main.go -o ./docs

Usage

Open your terminal and clone the repository

git clone https://github.com/mecitsemerci/go-todo-app.git

The application uses mongodb for default database so run makefile command

make docker-mongo-start

This command builds all docker services so if it's ok check that application urls.

Application URL Purpose
Angular UI http://localhost:5000 Todo APP Project
Swagger UI http://localhost:8080/swagger/index.html Todo API OpenAPI Docs
Jaeger UI http://localhost:16686 Opentracing Dashboard

By the way the application supports redis, if you use redis run that command

make docker-redis-start

This command builds docker services so if it's ok check same application urls.

Local Development

Configuration

The application uses environment variables. Environment variable names and values as follows by default.

  # MONGO
  MONGO_URL=mongodb://127.0.0.1:27017
  MONGO_TODO_DB=TodoDb
  MONGO_CONNECTION_TIMEOUT=20
  MONGO_MAX_POOL_SIZE=10
  
  # REDIS
  REDIS_URL=127.0.0.1:6379
  REDIS_TODO_DB=0
  REDIS_CONNECTION_TIMEOUT=20
  REDIS_MAX_POOL_SIZE=10
  
  # JAEGER
  JAEGER_AGENT_HOST=localhost
  JAEGER_AGENT_PORT=6831
  JAEGER_SAMPLER_PARAM=1
  JAEGER_SAMPLER_TYPE=probabilistic
  JAEGER_SERVICE_NAME=go-todo-app
  JAEGER_DISABLED=false

Dependency Injection

The project uses google wire for compile time dependency injection. The project is set for MongoDB by default. Docker compose files generates automatically wire_gen.go in containers but, it must be created manually for local development.

Wire dependency file is /internal/wired/wire_gen.go

make wire-redis

This command generates wire_gen.go with redis provider. When wire_gen.go file is checked, the following change will be seen.

// Injectors from redis.go:

func InitializeTodoHandler() (handler.TodoHandler, error) {
    client, err := redisdb.ProvideRedisClient()
    if err != nil {
        return handler.TodoHandler{}, err
    }
    todoRepository := redisdb.ProvideTodoRepository(client)
    idGenerator := redisdb.ProvideIDGenerator()
    todoService := services.ProvideTodoService(todoRepository, idGenerator)
    todoHandler := handler.ProvideTodoHandler(todoService)
    return todoHandler, nil
}

The following command can be run for MongoDB again

make wire-mongo

All changes can be observed in /internal/wired/wire_gen.go

Swagger

The command that generates the open api document to /docs folder.

make swag

Tests

Existing tests are for demonstration purposes only

Unit Test run command

make unit-test

Integration Test run command

make integration-test

go-todo-app's People

Contributors

dependabot[bot] avatar mecitsemerci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.