π± π¦ π² πͺ Helping people buy good food at good prices, together.
Before we start, please
- install
node@8andnpm@5 - install Git LFS
- install and set up Postgres for your system
- create a database in Postgres named
cobuy_development(i.e. using a command likeCREATE DATABASE cobuy_development;inpsql)
git lfs install
git clone [email protected]:root-systems/cobuy
cd cobuy
npm run burnthemall # TODO npm install
# see 'How to get private development config' section below
npm run db migrate:latest
npm run db seed:run
npm run dev- Postgres
git-lfs
- Cobuy uses
dogstack - React and JSX for DOM stuff, as per, but also Hyperscript as an alternative to JSX
- Recompose in our React components for purity
- Files:
app/components/Navigation.js - PRs: https://github.com/root-systems/cobuy/pull/100/files
- Files:
- Fela to manage styles
- Files:
<any dumb component and its style file>
- Files:
- Material-UI for ready-styled components
- Files:
<any component that has buttons or text fields or sliders>
- Files:
- React-intl to manage internationalization
- Files:
app/locales/en.json,<any component with text> - #80
- Files:
- Storybook for developing and testing our dumb components easily
- Files:
.storybook/config.js,agents/stories/index.js,agents/stories/Profile.js - PRs: https://github.com/root-systems/cobuy/pull/51/files
- Files:
- Redux for state management, as per
- Redux-fp for 'updaters' instead of 'reducers'
- Files:
*/updaters/* - PRs: https://github.com/root-systems/cobuy/pull/103/files
- Files:
- Redux-observable for managing async operations
- Files:
ordering/epic.js, - PRs: https://github.com/root-systems/cobuy/pull/103/files
- Files:
- Redux-form to connect React forms to state
- Files:
agents/components/SignIn.js - PRs: https://github.com/root-systems/cobuy/pull/59/files
- Files:
- Reselect for our getters
- Files:
*/getters/* - PRs: https://github.com/root-systems/cobuy/pull/104/files
- Files:
- Ramda as our general utility library with a strongly functional flavour
- Files:
<almost any>
- Files:
- Feathers for our backend API layer
- PRs: #116
- Feathers-reactive
- Feathers-action-react
- Feathers-action to provide CRUD actions out of the box
- Files:
*/dux/*,*/services/*,*/containers/*,server.js, - PRs: #116
- Files:
- Knex for interfacing with DB
- Files:
db/migrations/* - PRs: https://github.com/root-systems/cobuy/pull/116/files
- Files:
- Dogstack-agents to manage users and credentials
- Files:
agents/containers/Register.js - PRs: https://github.com/root-systems/cobuy/pull/59/files
- Files:
- Dumb components
- components && style files
- components && their local state
- Higher-order components (HOC) or containers
- (container && getters && props && actions) && dumb component/s
- Dataflow within the client
- from state to components
- state -> getters -> HOC components (containers) -> dumb components
- from components to state
- dumb components -> HOC components (containers) -> actions -> updaters && epics -> state
- from components to state with redux-form
- dumb components -> redux-form -> redux-form state
- from state to components
- Dataflow between client and server
- actions -> services && hooks -> db
- services && hooks && db tables
Also see the Captain's Log for more epistolary notes
dogstack! πΆ πΆ πΆ
We're following the dogstack folder structure convention.
- root
- actions.js (combines all actions)
- client.js
- epic.js (combines all epics)
- layout.js
- package.json
- root.js
- routes.js
- server.js
- store.js (combines top-level epic and updater)
- style.js
- updater.js (combines all updaters)
topic(e.g.agents)- containers
- components
- helpers
- getters
- services
- dux
- styles
- stories
- util
Starts production server
npm startStarts development server
npm run devStarts storybook server
npm run storybookRuns ava tests
Can optionally take a glob
npm test -- './todos/**/*.test.js'Default glob is ./**/*.test.js ignoring node_modules
Checks for standard style
Can optionally take a glob
npm run lint -- './todos/**/*.js'default glob is ./**/*.js ignoring node_modules
Runs knex command, with any arguments.
npm run db migrate:latestnpm run db seed:runAnything that a developer working on Cobuy should know about.
TODO organize all the miscy mushy magic
Use a ~/.pgpass file to automate your passwords!
echo "localhost:5432:*:postgres:password" > ~/.pgpass
chmod 600 ~/.pgpassCreate your database with:
createdb cobuy_development -h localhost -U postgresDrop your database with:
dropdb cobuy_development -h localhost -U postgresConnect to your database with:
psql -h localhost -U postgres -d cobuy_developmentOur development config is stored in a private repository:
cd ../
git clone [email protected]:Enspiral-Pods-Swarm/cobuy-config
cp cobuy-config/*.js cobuy/configheroku run npm run db migrate:latest --app=cobuyAll models must have an assoicated JSON schema. See #118 for more info.
We're using json-schema-faker to fake data for tests and storybook.
How to storybook
So you want to tell a story about dumb React components, ey?
Start storybook with npm run storybook
The configuration for storybook lives in .storybook/.
The stories are in ${topic}/stories/index.js. The dumb components are in ${topic}/components/${name}.js
If you add a "story", please add your topic story to .storybook/config.js
Check out app/stories/index.js for example stories, which you can copy into a new topic.
NOTE: At the moment, hot-reload does not work when changing messages in app/locales/*.json.
All numbers should be represented as strings and manipulated with bigmath.
Developers should be using British spelling in the codebase
All assets (binary files) should be checked in using Git LFS:
git lfs add <file>They must also be manually added to our production OpenStack Object storage cobuy-assets container.
This can be found at: https://dashboard.cloud.catalyst.net.nz/project/containers/container/cobuy-assets
Ensure the name of the file is the same locally and remotely.
AGPL-3.0
Emoji artwork is provided by EmojiOne and is licensed under CC-BY 4.0