Giter Club home page Giter Club logo

hexabi's Introduction

hexabi

Intro

This is a game I'm building, complete work in progress, using a bunch of new stuff.

It has in it...

  • React for the rendering
  • Redux for the data flow
  • Redux-router for the routing
  • Express for the Server
  • GraphQL for the Api
  • PostgreSQL for the DB
  • Bookshelf & knex for the Models
  • CSS modules for css
  • webpack for bundling
  • postcss for not writing css.

I've mashed it together from a lot of demo's and brute force. And there are few hacks. But at the time of writing it's bang up to date with the latest versions of everything.

Getting Started

  • Install node
  • Install postgreSQL Server
  • create a DB called hexabi
  • git clone https://github.com/alexFaunt/hexabi.git
  • cd hexabi
  • npm install
  • Create a server-config.js from the example-server-config.js which connects to your db
  • npm run-script db-create
  • npm run-script db-pop

To run + dev

npm start

This will create the server and client bundles for you, then run the node server. When changes are made it will automatically rebuild the server + re-run it. Or automatically rebuild the client-bundle. No hot reloading - I hate it.

When you are done, kill the process, and the server will remain running.
npm stop
To finally kill it.

dev Server

You might want server logs. I've not sorted the scripts for this properly yet, I just use npm run-script watch, and npm run-script serve in a separate tab.

Structure

  • server.js: express server creation & configuration.
  • api/ - defining the api
    • database.js: knex config to connect to db
    • models: bookshelfjs models attached each represents a table in the DB
    • mutations: graphQL mutation definitions
    • query: graphQL query definitions
    • schema: GraphQL schema (basically graphQL's version of the models above
    • tables: PostgreSQL queries, just for me - could be used to generate DB in future
  • app/ - front end app
    • index.html: index file for rendering into
    • index.js: entry point on client side
    • actions: redux action declarations
    • components: react components
    • containers: react containers - attached to redux-router via @connect
    • content: probably temporary, contains static declarations
    • middleware: run between actions + reducers allowing async operations to be fired (including all api calls)
    • reducers: redux reducers - essentially the stores representing the data in the app
    • routes: contains redux-router declarations, getRoutes in particular
    • services: async services for any need
    • stores: store creation utils for server and client
    • styles: global style declarations for importing into any component's css module
    • utils: helper methods re-used across the app
  • server/ - express server
    • config: config for server
    • endpoints: endpoint handlers for express routes
    • middleware: middleware called pre-endpoint handler
    • utils: helper methods re-used across server

Example flows

First visit

  • user hits domain
  • redux-router decides what route the url represents, and therefore what Containers are needed
  • Containers are checked for required actions
  • All actions are fired
  • First action is always initSession, contributed by the Server Container (server side only)
  • Actions fired go through middleware, including api + auth calls
  • Upon all actions completing content is rendered + returned to user.
  • index.js takes over and loads page.
  • On transition to any page, the next page's required actions are fired to populate it

Login

  • Login action is fired
  • On auth async complete Login success action is fired
  • session store is updated, change emitted
  • Client container wrapper is listening to this.props.isLoggedIn
  • Container decides to navigate

TODO

So much stuff.

  • Sort out authentication

  • Sort out an SSL

  • CRUD for users

  • CRUD for games

  • DB scripts for knex

  • Spin off at this point as boilerplate example

  • BUILD GAME...

hexabi's People

Contributors

alexfaunt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.