universal-keystone-boilerplate icon indicating copy to clipboard operation
universal-keystone-boilerplate copied to clipboard

Boilerplate Architecture

Open ninjasort opened this issue 9 years ago • 13 comments

I thought it might be good to look at the boilerplate structure/architecture in an issue. Would it be possible to describe more of what this will look like and what the process might look like for someone getting started with a keystone project?

ninjasort avatar Jan 04 '16 01:01 ninjasort

Sure.

Server routing is handled by the component router -- which is something we could encapsulate inside Keystone. We could create a new Keystone config option that takes component routes and hooks them up similar to how it's done in source/routes/index.js:

    app.use('/', componentRouter);

Then users could define a componentRoutes module and pass it into their keystone config. That looks something like this:

import React from 'react';
import { Route } from 'react-router';
import createTeams from 'components/teams';

const Teams = createTeams(React);

export default (
  <Route path='/teams' component={ Teams }>
  </Route>
);

That is very simplified, of course, but you should get the gist. Later on, we may come up with a good pattern for managing app state with Redux, and then we may consider using Redux simple router, but it's essentially the same. Relies on react-router under the hood, either way.

ericelliott avatar Jan 04 '16 01:01 ericelliott

Okay, what about the components themselves. Will the flux implementation be redux?

ninjasort avatar Jan 04 '16 01:01 ninjasort

I am definitely interested in using Redux. @JedWatson has also mentioned GraphQL. It's not clear yet how we'll integrate GraphQL and manage the app state on client + server.

ericelliott avatar Jan 04 '16 02:01 ericelliott

That would be amazing. @JedWatson what are you thinking in terms of GraphQL?

ninjasort avatar Jan 04 '16 21:01 ninjasort

Would you like to help? I stumbled a bit yesterday. https://github.com/ericelliott/universal-keystone-boilerplate/issues/32

ericelliott avatar Jan 04 '16 23:01 ericelliott

Sure, I can take a look.

ninjasort avatar Jan 05 '16 00:01 ninjasort

Overall, this issue was supposed to be more about the structure of the project as a whole vs just the routing. If it's a boilerplate, where would a developer put each part of the code, and what's the workflow for how they might scale up a project?

ninjasort avatar Jan 05 '16 00:01 ninjasort

Still working on that. For now, this project is really about adding universal routing + rendering to Keystone.

In other words, we're in the "make it work" phase. We'll worry about making it work right later. =)

ericelliott avatar Jan 05 '16 00:01 ericelliott

Gotcha. Could we scoop anything from here

ninjasort avatar Jan 05 '16 02:01 ninjasort

Universal routing & render have been merged into Keystone, so the component router now lives inside Keystone core.

Here's a documentation screenshot from the new Keystone.JS Getting Started guide:

screen shot 2016-01-06 at 8 36 00 pm

Now I'm in the process of working on a standard way to supply data to the universal React components. I would love your feedback.

ericelliott avatar Jan 13 '16 01:01 ericelliott

wow! great work! I would love to try this out. Is there any working example with universal react, es6 compiling and keystone? thx

joernroeder avatar May 03 '16 23:05 joernroeder

@ericelliott what is the status of the universal react integration? Can't find this in the docs. Was it pulled? Im looking to start a small app with keystone and react, got a good starting point (even if it isnt official)?

danielmahon avatar Jun 08 '16 14:06 danielmahon

@danielmahon did you figure this out? I would like to do the same thing

sebastiancarlsson avatar Jul 08 '16 09:07 sebastiancarlsson