Coder Social home page Coder Social logo

mdsohelmia / doctor-appointment-api-golang-hexagonal-architecture Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sayeed1999/doctor-appointment-api-golang-hexagonal-architecture

0.0 0.0 0.0 17.69 MB

In this golang project, I tried to apply all the enterprise level software design practices that I know e.g hexagonal architecture, onion architecture, clean architecture, CQRS, DDD, generic repository pattern..

License: Apache License 2.0

JavaScript 1.78% Go 40.51% TypeScript 42.23% CSS 0.90% HTML 10.75% TSQL 3.84%

doctor-appointment-api-golang-hexagonal-architecture's Introduction

Golang Enterprise Project Structure | Hexagonal Architecture - Onion Architecture - Generic Repository Pattern

Doctor Appointment Api

To run the project from your pc,

  • first, you have to get golang installed on your system
  • second, git clone it, then run go mod tidy which installs all dependencies
  • third, run go run main.go in terminal from root dir
  • since, i have removed config.yaml file in git repo, you have to create ./config/config.yaml file and write it matching the Config struct in ./config/config.go file

In this golang project, I tried to apply all the enterprise level software design practices that I know e.g hexagonal architecture, onion architecture, clean architecture, CQRS, DDD, generic repository pattern..


Golang Packages used:-

  • gorm (ORM to communicate with the database)
  • gin/gonic (golang framework to build apis)
  • gomail (golang package for sending emails from your gmail)
  • go-redis (golang package which implements redis)

Architectures targeted:-

  • Generic repository pattern (centralizes a common repository for database operations)
  • Onion architecture (segregates a monolith project into controller layer, buisness layer, data access layer, domain/entity layer)
  • Hexagonal architecture

Project architecture explained:-

  • go.mod & go.sum file are responsible for all the dependencies of the project
  • Program execution starts from main.go
  • /internal/core package is the core of the project which contains all buisness logic and is loosely coupled to the rest of the application via ports-adapters pattern
  • First, the configuration files are initialized from ./config dir
  • Second, a channel for sending mails gets created and a new goroutine is fired that keeps listening for mail sending tasks
  • Third, the central generic repository gets initialized which is responsible for database transactions
  • Fourth, redis server gets initialized which is responsible for the caching of data
  • Fifth, the service layer gets initialized which calls on the repository layer for the database transactions and does caching, mail sending
  • Sixth, the handlers are initialized which is the controller layer of this project. the client requests data from the handlers via http requests & the handlers communicate back and forth with the service layer.
  • Seventh, gin router is created with default middlewares
  • Eighth, middlewares are initialized
  • Ninth, routes are initialized
  • Tenth, the server is run on localhost:8080 until an error occurs..

Any more suggestions please let me know.. :)

doctor-appointment-api-golang-hexagonal-architecture's People

Contributors

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