Skip to content

Clean Architecture + Multiple Concurrent File upload server(order of output guaranteed) | used Postgresql, GCP storage as infra. (클린아키텍쳐를 구조로 한 비동기 순서보장 이미지, 영상 파일 다중 업로드 서버입니다.)

Notifications You must be signed in to change notification settings

terry960302/go-clean-media-upload-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go-Clean-Media-Upload-Server

A Table of Contents

  1. Media-uploader
  2. golang clean-architecture

1. Media-Uploader

Spec

  • Database : Postgresql version 14
  • Storage : GCP cloud storage
  • Framework : Echo, Gorm

Setup

GCP Storage

: should update 'create object access' to GCP storage.

  1. Navigate to 'IAM & Admin' > 'Service Account'

  2. Create service account

    a. Set 'Cloud Storage' > 'Storage Admin' access

  3. Click Manage Key

  4. Move to 'Key' tab

  5. Click 'Add Key' (JSON file will be generated)

  6. Copy JSON & Paste JSON under 'config' directory

ERD

image

2. Golang Clean-Architecture

reference

: made new architecture based on these references.

What is Clean Architecture?

image

Frameworks & Drivers -> Interface Adapter -> Application Business Rules -> Enterprise Business Rules

Frameworks & Drivers

= DB, Devices(Mobile, Desktop), Web

  • We call it infrastructure
  • End side of architecture
  • Handle raw data or APIs

Interface Adapters

= Controllers, Gateways, Presenters

  • We call it adapter
  • Controll the value between data source and business rule handler
  • Take role of adapter that connect outer data and business logic

Application Business Rules

= Use Cases

  • We call it usecase
  • Business logic handler
  • Show purpose of this server

Enterprise Business Rules

= Entities

  • We call it domain
  • 'Enterprise' == No one except our company shouldn't know

Directory Structure

Config

: store data of configuration

Domain(Entities)

: stand for 'Entities'

  • model

Infrastructure

: stand for 'Framework & Drivers'

  • datastore : create db instances
  • router : define routing requests

Interface(Interface Adapter)

: stand for 'Interface Adaper' which takes role of translator btw domain and infrastructure. data fit for usecases & entities -> data fit for DB & Web

  • presenter

    • format strings & dates
    • add presentation data like flags
    • prepare the data to be displayed in the UI
  • controller

    • handle API requests
    • receive the user input like DTO
    • validate user input
    • convert the user input into model that use in usecase
    • call the usercase and pass it

Usecase

: stand for 'Use cases' that define what this server for(objective functions) business logic located in here.

  • interactor : input port(입력값이 들어오는 구간)
  • presenter : output port(반환값이 통과하는 구간)
  • repository : store db handler as a gateway

About

Clean Architecture + Multiple Concurrent File upload server(order of output guaranteed) | used Postgresql, GCP storage as infra. (클린아키텍쳐를 구조로 한 비동기 순서보장 이미지, 영상 파일 다중 업로드 서버입니다.)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages