Giter Site home page Giter Site logo

jobsssss / golang-clean-web-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from naeemaei/golang-clean-web-api

0.0 0.0 0.0 1.39 MB

Golang Clean architecture REST API example with a comprehensive real project. It uses docker, docker compose, redis, elasticsearch, kibana, filebeat, postgresql, prometheus, grafana. also use gin, gorm, viper, zerolog, zap, validator, dynamic search, swagger and JWT

License: MIT License

Shell 3.68% Go 95.77% Dockerfile 0.55%

golang-clean-web-api's Introduction

Golang Clean Web API (Dockerize) with a full sample project (Car Sale project)

System Design Diagram

Golang Web API System Design Diagram

Database Design Diagram

Golang Web API System Design Diagram

Give a Star! โญ

If you like this repo or found it helpful, please give it a star. Thanks!

Used Tools

  1. Gin as web framework
  2. JWT for authentication and authorization
  3. Redis for caching
  4. Elasticsearch for logging database
  5. Beat for log shipping
  6. Kibana as log viewer
  7. Postgresql as main database engine
  8. PgAdmin as database management tool
  9. Prometheus for metric database
  10. Grafana for metric dashboards
  11. Validator for endpoint input Validation
  12. Viper for configurations
  13. Zap for logging
  14. Zerolog for logging
  15. Gorm as ORM
  16. Swagger for documentation
  17. Docker compose for run project with all dependencies in docker

How to run

Docker start

docker compose -f "docker/docker-compose.yml" up -d --build

Web API

Run local manually http://localhost:5005
Run in docker http://localhost:9001
Token Url: http://localhost:5005/api/v1/users/login-by-username
Username: admin
Password: 12345678

Kibana

Username: elastic
Password: @aA123456

Grafana

Username: admin
Password: foobar

PgAdmin

Username: [email protected]
Password: 123456

Postgres Server info:

Host: postgres_container
Port: 5432
Username: postgres
Password: admin

Prometheus

Docker Stop

docker compose --file 'docker/docker-compose.yml' --project-name 'docker' down

Linux

  1. build Project and copy configuration
/src > go build -o ../prod/server ./cmd/main.go
/src > mkdir ../prod/config/ && cp config/config-production.yml ../prod/config/config-production.yml
  1. Create systemd unit
sudo vi /lib/systemd/system/go-api.service
  1. Service config
[Unit]
Description=go-api

[Service]
Type=simple
Restart=always
RestartSec=20s
ExecStart=/home/hamed/github/golang-clean-web-api/prod/server
Environment="APP_ENV=production"
WorkingDirectory=/home/hamed/github/golang-clean-web-api/prod
[Install]
WantedBy=multi-user.target
  1. Start service
sudo systemctl start go-api
  1. Stop service
sudo systemctl stop go-api
  1. Show service logs
sudo journalctl -u go-api -e

Project preview

Swagger

Golang Web API preview

Grafana

Golang Web API grafana dashboard

Kibana

Golang Web API grafana dashboard

golang-clean-web-api's People

Contributors

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