This repo uses React Redux Starter Kit as start up.
- node
^6.6.0 - npm
^3.10.3 - mongodb
^3.4.3
- npm i & npm start
- start MongoDB
- Create training set:
curl http://localhost:3000/api/createTrain - Open up http://localhost:3000/ in your browser
The application structure is grouped primarily by file type rather than feature.
├── server # Express application that provides webpack middleware
│ ├── api # JSON Server api (deprecated)
│ ├── controllers # Server controllers
│ │ ├── controller.js # Routes entry point
│ │ ├── createTrainController.js # /api/createTrain
│ │ ├── guessWordController.js # /api/game/guessWord
│ │ ├── nextWordController.js # /api/game/nextWord
│ │ ├── startGameController.js # /api/game/startGame
│ │ └── tellMeController.js # /api/tellMe
│ ├── models # MongoDB Dcoument Schema
│ │ ├── Player.js # Document for every game player
│ │ ├── Train.js # Document for training set
│ ├── resources # Training Set
│ └── server.js # Server application entry point
└── src # Application source code
├── index.html # Main HTML page container for app
├── app.js # Application bootstrap and rendering
├── routes.js # Game route definition and async inject
├── store.js # Create and instrument redux store
├── components # Presentational Components
│ ├── CoreLayout # CoreLayout which receives children for each route
│ ├── FieldEditor # Field editor component which switch between input and div
│ ├── GameWrapper # Game content layout
│ ├── Header # Game header layout
│ ├── WingButton # Start button component
│ └── WordChip # Word chip component for every single word
├── containers # Container Components
│ ├── DevTools.js # Dev tools for observing the states of store
│ ├── GameContainer.js # Connect GameWrapper component to the store
│ ├── HeaderContainer.js # Connect Header component to the store
│ └── WordChipContainer.js # Connect WordChip component to the store
├── actions # Actions definitions
│ ├── actionTypes.js # All actions defined in the app
│ ├── autoPlayAction.js # Main action for the game
│ ├── gameAction.js # Base actions called by main action
│ ├── globalAction.js # User configuration related actions
│ └── routeAction.js # Action for routes
├── reducers # Reducers definitions
│ ├── gameReducer.js # Main game reducers
│ ├── globalReducer.js # Reducer for user info
│ ├── routeReducer.js # Reducer for routes
│ └── reducer.js # Combine reducers
├── utils # Common utility funtions
│ ├── asyncInjectors.js # Inject an asynchronously loaded reducer
│ └── request.js # Async fetch request for getting the Q&A
└── styles # Application-wide styles (generally settings)
- Create a training set which records position of its contained letters respectively.
- Words with same length will be in the same document.
- If the word contains repeat letter, record the last index.
- 0 stands for inexistence
- Request
/api/tellMefor a letter with following payload:
{
"include": ["a", "b"],
"exclude" : ["c", "d"],
"length": 5
"position": 1 //first letter, optional
}
- Aggregate query
- match the length
- match the include & exclude conditions
- project with condition from a-z
- group with the sum from a-z
- response with the most possible letter