All Projects → jojoarianto → go-ddd-api

jojoarianto / go-ddd-api

Licence: other
API with domain driven design approach using golang, gorm, and mysql

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-ddd-api

QuerySpecification
Abstract package for building query specifications in your domain model.
Stars: ✭ 18 (-86.76%)
Mutual labels:  ddd
clean-gin
Implementation of clean architecture in Go, Gin with dependency injection.
Stars: ✭ 181 (+33.09%)
Mutual labels:  gorm
go-echo-server-sandbox
A scaffold of golang web server using labstack/echo
Stars: ✭ 12 (-91.18%)
Mutual labels:  gorm
kuu
Modular Go Web Framework based on GORM and Gin.
Stars: ✭ 15 (-88.97%)
Mutual labels:  gorm
educational-platform
Modular Monolith Java application with DDD
Stars: ✭ 124 (-8.82%)
Mutual labels:  ddd
archimedes-js
Archimedes's implementation for JavaScript and TypeScript
Stars: ✭ 34 (-75%)
Mutual labels:  ddd
eventcatalog
Discover, Explore and Document your Event Driven Architectures powered by Markdown.
Stars: ✭ 392 (+188.24%)
Mutual labels:  ddd
MonolithicArchitecture
This repository presents an approach on how to build an application using Monolithic architecture, ASP.NET Core, EntityFrameworkCore, Identity Server, CQRS, DDD
Stars: ✭ 18 (-86.76%)
Mutual labels:  ddd
awesome-talks
Awesome talks about event sourcing, cqrs, microservices, funcional programming ...
Stars: ✭ 23 (-83.09%)
Mutual labels:  ddd
nested-set
Nested Set is an Go implementation of the Nested set model for Gorm.
Stars: ✭ 44 (-67.65%)
Mutual labels:  gorm
LinqSpecs
A toolset for use the specification pattern in LINQ queries.
Stars: ✭ 161 (+18.38%)
Mutual labels:  ddd
ego
Go微服务.A simple and component-based microservice kit for go.
Stars: ✭ 765 (+462.5%)
Mutual labels:  gorm
eventuous
Minimalistic Event Sourcing library for .NET
Stars: ✭ 236 (+73.53%)
Mutual labels:  ddd
e-shop
Sample Spring Cloud microservices e-shop.
Stars: ✭ 48 (-64.71%)
Mutual labels:  ddd
city-codes
Brazilian city names and official codes, IBGE, LexML and others
Stars: ✭ 39 (-71.32%)
Mutual labels:  ddd
kingdom-python-server
Modular, cohesive, transparent and fast web server template
Stars: ✭ 20 (-85.29%)
Mutual labels:  ddd
jobofferbackend
This project is a real-world example of DDD in a backend application It applies the concept of Entity, Value Object, Root, Aggregate, Services, Repositories and Ubiquitous Language.
Stars: ✭ 15 (-88.97%)
Mutual labels:  ddd
QrF.Core
基于.net core 2.2 的微服务框架
Stars: ✭ 19 (-86.03%)
Mutual labels:  ddd
grails-audit-logging-plugin
The Grails Audit Logging Plugin
Stars: ✭ 49 (-63.97%)
Mutual labels:  gorm
firebase-event-sourcing
Event Sourcing + CQRS + DDD for Firebase
Stars: ✭ 14 (-89.71%)
Mutual labels:  ddd

GO DDD API

Kumparan Backend Technical Assessment, create REST API with domain driven approach (DDD) using Golang, GORM (Object Relational Mapping), and MySQL

Demo get all news api https://go-ddd-api.appspot.com/api/v1/news

Installation & Run

First, Make sure you have set up $GOPATH.

# Download this project
go get github.com/jojoarianto/go-ddd-api

# It's take several minute to download project

Set project environment and run

# move to project directory
cd $GOPATH/src/github.com/jojoarianto/go-ddd-api

# copy and rename config.toml.example
cp config.toml.example config.toml

# set config.toml to your env
user="your_db_username"
password="your_db_password"
host="your_db_host"
port="your_db_port"
dbname="your_db_name"

# run golang project
go run main.go

# API Endpoint : http://localhost:8000/api/v1/

Design

  • Application
    • Write business logic
      • news.go (GetNews, GetAllNews, &...)
      • topic.go (GetTopic, GetAllTopic, &...)
  • Domain
    • Define interface
      • repository interface for infrastructure
    • Define struct
      • Entity struct that represent mapping to data model
        • news.go
        • topic.go
  • Infrastructure
    • Implements repository interface
      • news_repository.go
      • topic_repository.go
  • Interfaces
    • HTTP handler

Required Features

  • Manajement news user can manage data news (CRUD)
  • Manajement topic user can manage data topic (CRUD)
  • Relational model betwean news & topic many to many (one news can contains multiple topic, one topic has multiple news)
  • filter by news status filter news by it's status ['draft', 'deleted', 'publish']
  • filter by news topic filter news by a topic (forinstance: politik)

URL ENDPOINT

/api/v1/news

  • GET : Get all news
  • POST : Create a news

/api/v1/news/{news_id}

  • GET : Get a news by id
  • PUT : Update a news by id
  • DELETE : Delete a news by id

/api/v1/topic

  • GET : Get all topic
  • POST : Create a topic

/api/v1/topic/{news_id}

  • GET : Get a topic by id
  • PUT : Update a topic by id
  • DELETE : Delete a topic by id

/api/v1/news?status={status}

  • GET : Get all news filter by news.status

/api/v1/news/{topic-slug}

  • GET : Get all news filter by topic

/api/v1/news?limit={limit}&page={page}

  • GET : Get all news with pagination limit and page

Usage Examples

Documentation api with insomnia https://intip.in/InsomniaApiKumparanTa

Get all news, URL GET /api/v1/news

curl --request GET \
  --url https://go-ddd-api.appspot.com/api/v1/news

Get all news filter by status['draft', 'publish', 'deleted'], URL GET /api/v1/news?status={status}

curl --request GET \
  --url https://go-ddd-api.appspot.com/api/v1/news?status=draft

Get all news filter by topic, URL GET /api/v1/news/{topic-slug}

curl --request GET \
  --url https://go-ddd-api.appspot.com/api/v1/news/liputan-khusus

Get all news with pagination, URL GET /api/v1/news?limit={limit}&page={page}

curl --request GET \
  --url https://go-ddd-api.appspot.com/api/v1/news?limit=2&page=1

Get all topics

curl --request GET \
  --url https://go-ddd-api.appspot.com/api/v1/topic

Create a topic, URL POST /api/v1/topic

curl --request POST \
  --url https://go-ddd-api.appspot.com/api/v1/topic \
  --header 'content-type: application/json' \
  --data '{
	"name":"Liputan Khusus",
	"slug":"liputan-khusus"
}'

Create a news, URL POST /api/v1/news

curl --request POST \
  --url https://go-ddd-api.appspot.com/api/v1/news \
  --header 'content-type: application/json' \
  --data '{
	"title": "Bonnie Triyana: TNI Razia Buku Upaya Desukarnoisasi",
	"slug": "memberangus-buku-memberangus-ilmu-1547439849539914993",
	"content": "30 November 1957, kunjungan Presiden Sukarno di Perguruan Cikini, Jakarta, atas undangan guru mendadak jadi tragedi. Hujan granat mendarat ketika ia berjalan keluar dari sekolah dua anaknya itu, Megawati Soekarnoputri dan Guruh Soekarnoputra. Dua pengawal, Oding Suhendar dan Sudiyo, merangkul Sukarno pergi menyelamatkan diri. Kedua anak Sukarno sudah lebih dulu diamankan.",
	"status": "publish",
	"Topic": [
		{
			"ID": 2,
			"CreatedAt": "2019-01-19T03:12:32Z",
			"UpdatedAt": "2019-01-19T03:12:32Z",
			"DeletedAt": null,
			"name": "Liputan Khusus",
			"slug": "liputan-khusus",
			"News": null
		}
	]
}'

Delete a news, URL DELETE /api/v1/news/2

curl --request DELETE \
  --url https://go-ddd-api.appspot.com/api/v1/news/2

Delete a topic, URL DELETE /api/v1/topic/2

curl --request DELETE \
  --url https://go-ddd-api.appspot.com/api/v1/topic/3

Update a news, URL PUT /api/v1/topic/2

curl --request PUT \
  --url https://go-ddd-api.appspot.com/api/v1/news/2 \
  --header 'content-type: application/json' \
  --data '{
	"title": "[draft] Memberangus Buku, Memberangus Ilmu",
	"slug": "memberangus-buku-memberangus-ilmu-1547439849539914993",
	"content": "Buku-buku yang disita itu berjudul Kronik ‘65: Catatan Hari Per Hari Peristiwa G30S Sebelum dan Sesudahnya, Jasmerah: Pidato-pidato Spektakuler Bung Karno Sepanjang Massa, dan Mengincar Bung Besar: Tujuh Upaya Pembunuhan Bung Karno. Tak ada satu pun judul buku yang memuat kata “PKI” atau “komunis” seperti yang dituduhkan",
	"status": "draft",
	"Topic": [
		{
			"ID": 2,
			"CreatedAt": "2019-01-19T03:12:32Z",
			"UpdatedAt": "2019-01-19T03:12:32Z",
			"DeletedAt": null,
			"name": "Liputan Khusus",
			"slug": "liputan-khusus",
			"News": null
		}
	]
}'

Update a topic, URL PUT /api/v1/topic/2

curl --request PUT \
  --url https://go-ddd-api.appspot.com/api/v1/topic/3 \
  --header 'content-type: application/json' \
  --data '{
	"name":"Sepak Bola Nasional",
	"slug":"sepak-bola-national"
}'

Product Items Backlog

  • Mandatory: Create REST API News & Topic CRUD
    • News
      • Get all
      • Get by id
      • Create
      • Update
      • Delete
    • Topic
      • Get all topic
      • Get by id
      • Create
      • Update
      • Delete
  • Mandatory: Create Filter
    • Filter by status news
    • Filter by topic
  • Mandatory: API Functional Test
  • Opsional: Deploy to (heroku/aws/azure/digital ocean)
  • Opsional: Database setup migration schema DB

References & Library

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].