RFC: FEM packages structure #5089
Replies: 12 comments 17 replies
-
zooniverse.org is a web site, not an app. Why not build it as a web site, rather than a JavaScript app? |
Beta Was this translation helpful? Give feedback.
-
Would separate apps for different services be a third structure or would that be structure 2? I think I'm getting confused by the use of "packages" when I equate that with libraries, but importing all the major services as libraries into a root app (structure 2?) I'm not sure is much different than structure 1? I thought an option would be individual apps (like we have app-projects and app-content now) for other services like talk, lab (could include project admin), users (could include user admin) and a (as small as possible as it'd be the homepage) root app. |
Beta Was this translation helpful? Give feedback.
-
I think the problem that @mcbouslog is describing, and the problem that this discussion is trying to solve, is the problem of common layout components across Zooniverse pages eg. the repeated user and localisation logic between the two current NextJS apps. That problem is solved by layouts in the new NextJS app router. |
Beta Was this translation helpful? Give feedback.
-
Regarding client-side routing with the /pages router, how do we envisage that working for individual projects? This still isn't clear to me. We've discussed how URLs are routed on our servers, but what's the plan for routing when Is the plan to ignore In PFE we maintain a list of projects that should client-side redirect to our CDN: When a client-side route loads one of those projects, we force the browser to reload the page, requesting that URL from our CDN. How will this work in the browser when client-side routing for all projects is handled by the NextJS /pages router, rather than React router in PFE? Will |
Beta Was this translation helpful? Give feedback.
-
That's fine as long as your library is intended only to be used inside a NextJS app (so you couldn't import them inside the Zooniverse React Components lib, or the classifier, both of which are designed to work outside of NextJS.) |
Beta Was this translation helpful? Give feedback.
-
This isn't true. All the libraries must use the same version of React and MobX as the root NextJS app. That's why we declare React, MobX etc. as peer dependencies in our libraries. |
Beta Was this translation helpful? Give feedback.
-
This is a disadvantage. Your mental model, and the store state, has to expand from a single project and workflow to all available projects plus Talk, user stats and anything else that's kept in the global store. I'd recommend keeping contexts small and scoped to where they're needed. Since React 16, React is designed to support multiple context providers. |
Beta Was this translation helpful? Give feedback.
-
We have individual Express servers, with Express middleware, for each app at the moment. In addition, the project app has NextJS middleware to rewrite project URLs. Will there be any problems consolidating those into a single server? They aren’t mentioned in either option 1 or option 2. |
Beta Was this translation helpful? Give feedback.
-
@eatyourgreens and @mcbouslog I've updated the Discussion overview to describe two distinct options. As mentioned in the Action Items sections, the goal is to document FEM's overarching plan and set a precedent for how new pages should be added to the monorepo. Thanks for you patience since we can't ask the original FEM authors. I'm doing my best to use context clues and develop an understanding of the big picture implications for how we develop FEM going forward. |
Beta Was this translation helpful? Give feedback.
-
Option 3 Discussed at ZTM 2023At ZTM this week we discussed a third option for FEM's app and lib structure, and will work toward this third option as follows (also see project board: https://github.com/orgs/zooniverse/projects/41/). app-root
app-project --> lib-project
app-content-pages --> lib-content-pages
lib-users
Existing packages that do not need refactoring:
Bonus idea: |
Beta Was this translation helpful? Give feedback.
-
Connecting some documentation:The initial creation of app-root has been merged: #5423 Important takeaways from PR 5423:
|
Beta Was this translation helpful? Give feedback.
-
"About Zooniverse" pages (content pages)The About Zooniverse pages currently exist in app-content-pages, a Next.js 13 app using the Pages Router. There are new designs for the About Zooniverse pages (Figma) that need to be implemented in FEM. In order to move FEM toward the app-root structure, we plan to simultaneously develop app-root, but also split app-content-pages into two packages:
Note that PFE's router.jsx contains redirect functions for zooniverse.org/about/team and zooniverse.org/about/publications to FEM because those two pages are in FEM's app-content-pages. There will likely be an interim period when PFE's router is used to redirect more pages (/about/resources, /about/faq) to FEM, and then eventually all /about pages. Relevant project board: https://github.com/orgs/zooniverse/projects/40 |
Beta Was this translation helpful? Give feedback.
-
Overview
This is a discussion stemming from a Slack convo about PFE's structure as a single page app (SPA) and avoiding a similar fate in FEM. Some of the disadvantages to building a SPA are it being an large, unwieldy codebase for developers to maintain, and being forced to use client-side routing. A note from @eatyourgreens : Client-side routing immediately makes the site harder to use with assistive technology, so it would be raising, rather than lowering, barriers to participation.
There's a lack of documentation about how to move forward when adding more pages to FEM, for instance by adding more app packages to the monorepo or consolidating pages into one Next.js app. I think it's pertinent to document the discussion because the
/user
stats pages are being developed in FEM this year.Research
Prior to opening this discussion I searched for existing documentation on the topic, but couldn't find any conclusions about the planned structure of app and lib packages in FEM. I looked in Github Issues, Discussions, PRs, ADRs, and the #fem Slack channel (which began after FEM's repo was created).
Some relevant PRs, but they don't document an overarching plan:
Discussions:
Context
For context, here’s a helpful diagram created by @mcbouslog that illustrates zooniverse.org’s pages. The current pages in FEM are:
Pages that will eventually be “moved over from PFE” by being built into FEM are:
Proposed Option 1
Pages are their own separate apps in FEM
Continuing with the pattern of /about being in app-content-pages while /projects is contained in app-project, new pages should be built in their own app package. For instance, /lab will be built as app-lab. This way, a volunteer visiting a route like /lab will not be required to download all of the Javascript bundles needed for unrelated pages such as /about.
This strategy would not require major refactoring of the current structure. However, we are currently on outdated versions of React and Next.js, and I think upgrading FEM to the latest of each should be required before adding a new app package.
We use mobx for state management so, each app package will have their own store.
Each app will have their own Express server and middleware as needed.
Each app will need to be run locally separately when developing new features.
Proposed Option 2
Eventual combination of all pages into one Next.js app package in FEM:
The existing app-project and app-content-pages packages would be combined into one big app package, and all other pages added later on would go into that app.
This option would put FEM in the same position as PFE - one large SPA.
It would require refactoring of the current structure:
Action Items
The goal here is to document FEM’s overarching plan - specifically how new pages should be added. The upcoming user stats pages can be set as a precedent for future additions. Documenting this goal will educate future Zooniverse developers and managers.
I plan to follow-up on this topic with more documentation after ZTM meetings about PFE/FEM routing and the zooniverse.org homepage!
Beta Was this translation helpful? Give feedback.
All reactions