msupply-foundation / unified-codes

Provides a curated, searchable list of pharmaceutical products, each with an immutable code. A GraphQL API, a REST API and website are available for interaction with the database.
https://codes.msupply.foundation
2 stars 0 forks source link

Refactor repo as nx monorepo #58

Closed wlthomson closed 4 years ago

wlthomson commented 4 years ago

Idea of this issue is to get a discussion going and decide how we might want to organise are project in a way that makes managing our front-end and multiple back-end dependencies a bit easier.

Expected Behavior

Some of the things I think we could benefit from:

Current Behavior

Currently we manage all our projects separately. This has already been a bit tricky (e.g. setting up tests), and I think this could get a bit messy as we scale. Thinking is that we could benefit a lot from having some tools to speed things up and to keep things nice and tidy (would also be a good chance to research monorepo toolkits for omsupply).

Possible Solution

A few possible options:

Of these, nx stands out to me as the most comprehensive and best documented... but feedback welcome!

wlthomson commented 4 years ago

@mark-prins @katherine-sussol Any thoughts?

kat-ms commented 4 years ago

Initial thoughts: Have had an initial look at nx and created a sample workspace.

Default structure (created with nx CLI commands) looks a bit like this:

<workspace_name>\
  apps\
    app1\
      src\
          app\
            file1.ts
            file2.ts
          assets\
          environments\
    app2\
      src\
          app\
          assets\
          environments\
  libs\
  dist\
    <transpiled versions of apps>
  tools\

For initial refactor, current thinking/approach is just grabbing everything we currently have as a 'folder' under unified-codes and adding it as an app in the nx workspace (using nx generate) E.g

We can then look at what can be split out into a lib or shared code (already with this approach base versions of config files now live in the parent folder rather than under individual apps folders - which can be overridden in the specific app directories)

These plugins have their own default builder commands for building/testing/linting/serving applications (replacing the existing npm scripts we have per project). E.g for api:

wlthomson commented 4 years ago

@katherine-sussol Nice!

Don't have much to add, just to mention that we will also need to add auth-service (using @nrwl/node), which is currently under data-service.