DEV Community

Itachi Uchiha
Itachi Uchiha

Posted on

E-Commerce Microservices with Golang

Hi everyone. I want to show my GitHub project. It's a basic microservices project. I'm using Go to develop it. It's not completed yet.

You can check it out here

https://github.com/aligoren/go_ecommerce_microservice

I'm not good at microservices or Golang. So, I hope I'll better understand Golang and Microservices with this project. It would be nice If I finish this project.

I need to feedbacks to improve my project :)

Thanks :)

Top comments (6)

Collapse
 
apapsch profile image
Aljosha Papsch

Hi there.

You are creating some components for which there is production-ready stuff out there. It may be tempting to just implement it yourself, but using the available stuff frees you to do the thing at hand: creating an ecommerce experience. For example, your broker looks like a reverse proxy, which Traefik is quite good for.

If possible avoid custom authentication logic. It is prone to security errors and another thing to maintain. The current standard is OAuth2, which is a request-response flow between your application (client) and an authentication provider (server). There are providers out there making integration into your app very easy, like Auth0 or Ory. But you can also create a custom OAuth server based on available libraries (quite a time sink).

There is the User struct and its managed by an ORM library, but there's also code that creates SELECT statements with hard coded column names. That makes schema changes laborious. There should only be a single source of truth (the struct). Use the powers of ORM library to construct SELECT. (My personal preference is towards document database, which makes ORM redundant.)

Names and structures should correspond to the domain at hand. For example Customer would be more fitting than User. The struct is very bare bones, expand it as necessary, e.g. invoice and delivery addresses. Eric Evans like to make a science of it, see "Domain Driven Design".

Another book that I've enjoyed in the past is "Clean Code" by Robert C. Martin. But books aren't all. It seems like you have learned quite a bit in your junior position. Though with a senior at your side (not the web), who would be able to do a thorough review and criticism, I promise there would be a great leap in your expertise.

Happy hacking!

Collapse
 
itachiuchiha profile image
Itachi Uchiha

Omg, that's a very nice feedback to me. Really, I liked.

I didn't use Traefik before and actually, you know, I didn't even think about OAuth2 before. But, yes this will be much better than others.

Should I buy Domain Driven Design? Yes, I should :)

I worked for one company before. And, they don't use any architecture and don't allow you to use these kinds of architectures. A little bit old fashion :)

I'll apply your suggestions. Thank you very much. You made me happy

Collapse
 
apapsch profile image
Aljosha Papsch

Keep on looking for better companies. If there are no good ones in your vicinity, consider a full time remote job, you can find them on Indeed and maybe even LinkedIn. But it's hard if you're on the lookout. On Xing.com (popular in German market) there are quite a few head hunters, which makes it easier. Dunno how it is from Turkey.

Thread Thread
 
itachiuchiha profile image
Itachi Uchiha

Currently, I started a new job 2 weeks ago. This company really good for these kinds techs. There are many good software architects here.

But, I'm looking for a full time remote job. Actually, remote working isn't required for me. I like to working from office. I'm a little bit social person :/)

Collapse
 
danilovmy profile image
Maxim Danilov

please can you remove compile data from repository? i can do it myself.

User model, if you have Email or FirstName unique, you do not need id.
If you have a logging service, you don't need CreatedAt and UpdatedAt either. They are already in the logs.

The auth baseUrl seems strange. If it is not defined, you should throw an error.

Collapse
 
itachiuchiha profile image
Itachi Uchiha

Thank you very much. I'm creating local issues for myself to do that.

I'm so sorry I think I couldn't find compiled data. Where is it? I'll remove it :) Thank you very much