root-systems / catstack

[ON HOLD] :cat2: :cat2: :cat2: A modular mad science framework for teams working on production web apps.
https://catstack.herokuapp.com/
49 stars 4 forks source link

boilerplate -> neomonolith framework #84

Closed ahdinosaur closed 7 years ago

ahdinosaur commented 8 years ago

strawman:

// api.js
var Api = require('business-stack/api')

var api = Api({
  config: require('./config'),
  modules: [
    require('business-authentication/api'),
    require('./trees/api'),
  }
})
// app.js
var App = require('business-stack/app')

App({
  config: require('./config'),
  reducer: [
    require('business-authentication/reducer'),
    require('./reducer')
  ],
  router: require('./router')
})

/cc @iainkirkpatrick

ahdinosaur commented 8 years ago

we want fractal apps.

so maybe we want to follow the semantics of Redux reducers, where each fractal app exports an object describing the functionality of that app, which we can combine (reducers, routers, services) using something like combineReducers into a larger app, eventually passing into our top-level runner like createStore.

iainkirkpatrick commented 8 years ago

adding my current thoughts partly as a personal marker (something i can come back to later when i no doubt know better :D ):

i can see a couple of wins that struck me with staltz's article on fractal apps. each 'app' would have similar enter and exit interfaces, which gives a level of familiarity to the dev (whether that's Observables as with Staltz's Dialogues, or an Object of 'functionality', etc). feels like it should cut down on wastage of modules / result in less fiddling around the edges of modules to get compatibility with several apps.

(so i wonder, would a 'common' abstraction over Dialogues, functionality objects etc be a cool idea?)

another win that struck me was ideally the ability to create standalone 'apps', that are runnable, testable, everything-able in their own right, and can also be plugged in to higher-level apps (and are composed of lower-level apps?). in that way, as a dev I can clone an app, spin it up, poke around, see how it works (and what it 'looks' like), and then use it in a larger app if i want. chatting with @ahdinosaur i think i was over-thinking how this might work in practice with redux-like architectures... i.e. doesn't a redux app need a store created to reduce to? how will i test an app without including code in the app that creates a store, but when it comes time to 'plug it in' to higher-level apps I don't want it to have it's own store? but actually, i guess the repo for an app just has it's object of functionality that it exposes, and a separate file that creates a store, wires up etc if the app is RUN rather than COMPOSED. i think :)

any other fractal wins?

other questions:

justingreenberg commented 8 years ago

i just stumbled across this project, awesome work! i'm also loving this idea. my recent attempt at a simple fractal architecture, similar to what you guys currently have: https://github.com/davezuko/react-redux-starter-kit/pull/684

i would just suggest something more general than "reducers" for client app in your strawman example... such as a bundle of actions, reducers, and anything else that requires store... ie

// api.js
const Api = require('business-stack/api')

module.exports = Api({
  config: require('./config'),
  modules: [
    require('business-authentication/api'),
    require('./trees/api'),
  }
})
// app.js
const App = require('business-stack/app')

module.exports = App({
  config: require('./config'), // middleware / store enhancers (ie redux-saga)
  providers: [
    require('business-authentication'),
    require('./app')
  ],
  router: require('./router')
})
// app.js / business-authentication/index.js
module.exports = {
  actions: require('./actions'),
  reducers: require('./reducers'),
  sagas: require('./sagas')  // based on user config 
}
// sagas.js / business-authentication/sagas.js
module.exports = (store) => {
  store.sagaMiddleware.run(saga)
}
// reducers.js / business-authentication/reducers.js
module.exports = (store) => {
  store.injectReducer(reducer)
}

have you seen https://github.com/loggur/react-redux-provide? (interesting but a little heavy imo)

another concern with the current setup (which would be solved by this solution) is the lack of webpack for bundling/code-splitting, is there a reason you guys aren't using it? have you considered moving away from browserify?

ahdinosaur commented 8 years ago

hey @justingreenberg, your fractal app RFC looks awesome, thanks for sharing. :smile:

as soon as possible i'll try and write up a more complete RFC here, my initial strawman was just thrown together as a placeholder.

have you seen https://github.com/loggur/react-redux-provide?

nah, but indeed interesting.

lack of webpack for bundling/code-splitting, is there a reason you guys aren't using it? have you considered moving away from browserify?

i much prefer browserify over webpack, for these reasons. i'll make an issue to support code splitting via factor-bundle.

ahdinosaur commented 8 years ago

ooh, i stumbled on rill, which applies a pattern i've been meaning to try. could be a simple way to do fully isomorphic code across server and browser.

ahdinosaur commented 8 years ago

okay okay, new direction! :8ball:

cat-stack becomes a grab bag module of grab bag modules:

ahdinosaur commented 7 years ago

so... this happened.