I want to create front end app along with backend (and mongo). I use Express and I am wondering how to structure app. Should I create separate repo for back and front? I use Typescript so then I woulnd't have access to typing. So maybe in one repo two folders client and server ? But what then? In each folder should I create package.json ? Is it worth to separate this file?
I think it should be for modularity purposes although it may be a little confusing sometimes specially when you're creating a certain feature and you need to create a branch for both repos to implement it. Although it kinda makes it easier when debugging.
I have a similar project that I'm working on, with Express as the backend and Angular as the frontend. I've structured the project as a monorepo using Lerna. So there's a top-level folder with a packages/ folder that then contains several subprojects folders. Each subproject is itself an NPM package. Along with server and client projects, I have a common project for shared code.
Lerna has a
bootstrapcommand that wires up links between your subprojects. It also deals with shared NPM dependencies. The whole monorepo is committed to a single Git repository but each subproject is published as its own scoped NPM module (this is an optional step though).For a more advanced setup, you can also host each subproject using Docker. I have made each subproject that will act as a server into a Docker image. I then use Docker Compose to orchestrate setting up a stack containing each of the server.
nginxacts a proxy layer between all of the servers.├── monorepo │ ├── packages │ ├── api │ ├── Dockerfile │ └── package.json │ ├── common │ └── package.json │ ├── db │ ├── Dockerfile │ └── package.json │ ├── nginx │ ├── Dockerfile │ └── package.json │ └── ui │ ├── Dockerfile │ └── package.json │ ├── docker-compose.yml │ ├── lerna.json │ ├── package.json │ └── tsconfig.json