A sample web API in GO (with GIn) under a domain driven architecture.

Golang Sample API


Domain Driven Design Pattern


1. About

This sample project presents a custom made domain driven API architecture in Golang using the Gin Web Framework. This domain driven architecture can be extended into other web frameworks as well. Under this architecture every domain acts a separate web application. The design is modular and with a great separation of concerns, making it ideal for large and complex project in which oftentimes there is the need to extend, replace or remove parts of the application.

2. Project Layout

  • The app folder acts an orchestrator. It provides the structures and the factories to run the whole API and it collects the endpoints from the available domains.
  • The domains folder contains all the folders that correspond to the API endpoints. Each inside the domains folder is named based on a domain and it contains the code related only to that domain. Each folder inside the domains folder can be though of as a separate web application - meaning that every folder inside the domains folder can fully run a service completely independently (if needed it can also have dependencies to other domains, but that is not the rule).
  • The settings folder contains some global configurations for convenience and structure.
  • The utils folder contains utilities that can be useful into more than one domains - to avoid code duplication and to create modularity and extra separation of concerns.

3. Project Setup

  1. Clone the project's repository
  2. Change directory to the projects root directory
  3. Execute on terminal: make run
  4. If you have postman you can import the postman collection present in docs folder and send requests to the API endpoints.
    • Alternatively, you can try the following commands on a separate terminal window:
      • curl --location --request GET 'http://localhost:8080/healthcheck'
      • curl --location --request POST 'http://localhost:8080/greetme' --header 'Content-Type:application/json' --data-raw '{"name": "George","title": "Mr."}'
  5. During the development process, you can also run: make test or make coverage to test you code and get a coverage report.
Owner
George Batagiannis ⚡
Software engineer ​📡 ​💻​ 🌐​ Python, Go and more...
George Batagiannis ⚡
Similar Resources

Simple forwarding a unix domain socket to a local port.

WaziApp Proxy WaziApp proxy is a simple http proxy that is intended to listen on the WaziApp unix socket /var/lib/waziapp/proxy.sock and forwards to a

Nov 18, 2021

Extract domain from SSL Information

Extract domain from SSL Information

Dec 7, 2022

Go package provides a fast lookup of country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name,

IP2Location Go Package This Go package provides a fast lookup of country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, co

Jan 8, 2023

Golang tool to parse netblocks and domain names from SPF and get information about ASN

Golang tool to parse netblocks and domain names from SPF and get information about ASN

gospf Example Install go get github.com/incogbyte/gospf # get from releases ht

Nov 14, 2022

Assanlab - JSON input data with counts on how many times you showed an ad on each individual domain

JSON input data with counts on how many times you showed an ad on each individua

Dec 31, 2021

Remake of the original sqlifinder but in GOlang, and allows for listed targets, domain crawling, and tor connections

Remake of the original sqlifinder but in GOlang, and allows for listed targets, domain crawling, and tor connections

_______ _____ _____ _______ _____ __ _ ______ _______ ______ |______ | __| | | |______ | | \ | | \ |______ |_____/

Jan 4, 2023

JPRQ Customizer is a customizer that helps to use the JPRQ server code and make it compatible with your own server with custom subdomain and domain

JPRQ Customizer is a customizer that helps to use the JPRQ server code and make it compatible with your own server with custom subdomain and domain

JPRQ Customizer is a customizer that helps to use the JPRQ server code and make it compatible with your own server with custom subdomain and domain.You can upload the generated directory to your web server and expose user localhost to public internet. You can use this to make your local machine a command center for your ethical hacking purpose ;)

Jan 19, 2022

Whereis - Displays management information for IPs associated with the domain

Whereis - Displays management information for IPs associated with the domain

"whereis" is Displays management information for IPs associated with the domain.

Jan 7, 2023

Go Domain Drived Design / Service repository pattern

Go Domain Drived Design / Service repository pattern Simple api domain drived design / service repository pattern API Overview every api (for each dom

Nov 28, 2022
webrpc is a schema-driven approach to writing backend services for modern Web apps and networks
webrpc is a schema-driven approach to writing backend services for modern Web apps and networks

webrpc is a schema-driven approach to writing backend servers for the Web. Write your server's api interface in a schema format of RIDL or JSON, and t

Jan 7, 2023
Transparent TLS and HTTP proxy serve and operate on all 65535 ports, with domain regex whitelist and rest api control

goshkan Transparent TLS and HTTP proxy serve & operating on all 65535 ports, with domain regex whitelist and rest api control tls and http on same por

Nov 5, 2022
Sample program of GCP pub/sub client with REST API

GCP pub/sub sample using REST API in Go GCP pub/sub publisher and subscriber sample programs. These use REST API and don't use pub/sub client library

Oct 12, 2021
llb - It's a very simple but quick backend for proxy servers. Can be useful for fast redirection to predefined domain with zero memory allocation and fast response.

llb What the f--k it is? It's a very simple but quick backend for proxy servers. You can setup redirect to your main domain or just show HTTP/1.1 404

Sep 27, 2022
Support for Unix domain sockets in Go HTTP clients

unixtransport This package adds support for Unix domain sockets in Go HTTP clients. t := &http.Transport{...} unixtransport.Register(t) client := &h

Dec 21, 2022
Proxy your Go Module`s Import Path from your own domain to a public host (e.g. github.com).

Go Modules Remote Import Path Proxy Proxy your Go Module`s Import Path from your own domain to a public host (e.g. github.com). For example Uber (buil

Nov 2, 2021
🛡 Several domain lists compiled into a database file used by V2Ray.

Domain list database This project is pulled from v2fly/domain-list-community, with only its data changed to use several blocklists. Purpose of this pr

May 22, 2022
Serve traffic (HTTP/gRPC) over SSH using Domain Sockets

Serve On SSH Introduction There is often a need to offer services for administrative purposes on servers or even for microservices that are running on

Nov 10, 2022
Automatically register a list of domain names, add them to Cloudflare and set DNS records.

NameCannon Automatically register a list of domain names, add them as zones on Cloudflare, then add DNS records. Usage $ ./NameCannon --namesiloSecret

Jan 26, 2022
A quick and dirty but useful tool to download each text/html page from the wayback machine for a specific domain and search for keywords within the saved content

wayback-keyword-search A quick and dirty but useful tool to download each text/html page from the wayback machine for a specific domain and search for

Dec 2, 2022