project-layout icon indicating copy to clipboard operation
project-layout copied to clipboard

What is the best project structure for a multi language monorepo?

Open kitgary opened this issue 6 years ago • 2 comments

I am building a microservices project with services written in Go, Python and JavaScript for the frontend, what is the best way to structure a multi language monorepo?

kitgary avatar Aug 27 '18 09:08 kitgary

@kitgary short answer - it depends :-)

If you have a web app with the backend part of it in go then you can use this layout as-is. The JavaScript for your frontend would go under /web/app and your static web assets would be in /web/static.

If you have a web app with the core business logic in your Go service and you have a small web server in python (which talks to your Go service for the actual business logic) then you can put your python web server code under /web/server.

If you have a mono-repo with lots of different services and applications (and in several different languages) then this project layout will need to be adjusted a bit. If this is what you have then you probably don't care about the project being go gettable, etc. Put the /cmd, /internal, /pkg, /vendor (and potentially the /third_party) directories under the top level /<your_go_service_or_subsystem_name> directory (or you can just call it /go if you don't care that the name is very descriptive or if all that code is tightly coupled and used together anyways). If you do that then you'll also need to set $GOPATH explicitly to point to that /<your_go_service_or_subsystem_name> directory (you might be able to avoid it if you are willing to experiment with the latest Go version and its features, but some of the Go tools may or may not work). If you want to still with the traditional $GOPATH model you can put your other non-Go backend code in the /tools directory (or another top level directory if you don't like the name) instead of moving the /cmd, /internal, /pkg and /vendor directories. The /tools directory is meant for the supporting tools, applications and services.

kcq avatar Sep 03 '18 19:09 kcq

@kitgary were you able to find a solution? I'm also facing a similar situation as you. Or do you have a sample repo I could tkae a look at?

rlam3 avatar Oct 31 '20 14:10 rlam3