SogiMood is a projects' mood manager. It helps you to monitor your projects's health by showing the evolution of three variables: customer's mood, team's mood and the financial health.
It has been developed for and by Sogilis.
SogiMood comes in two parts: backend is a ligh Go application, frontend is developed with React.
First, you must install Go.
Then, install the dependencies and build the application:
$ go get -u ./...
$ go buildIt should create the server binary: ./sogimood.
Before running it, you must install a Redis base. For Fedora:
$ sudo dnf install redis
$ sudo systemctl start redisThese commands must be adapted depending on your current Gnu/Linux distribution.
There are three environment variables you can set:
REDIS_URL="redis://:@127.0.0.1:6379"
PORT=8081
ACCESS_TOKEN=""ACCESS_TOKEN is used to protect the API access.
The frontend has been created through create-react-app.
You need to have NPM installed on your computer. For Fedora:
$ sudo dnf install npmOr you may find useful to use NVM which is able to manage several versions of NodeJS/NPM at a time.
Next, you need to download all the crapy-JS-dependencies:
$ cd client
$ npm installDepending if you develop the back or the front, the workflow will be slightly
different. We provide some scripts to help. Under the hood, they are mainly
reusing go build and create-react-app's commands (npm start and npm run build).
It compiles both frontend and backend and moves front files under ./dist so
the backend is able to serve them. If you want to develop for the backend only,
you may find useful to run this command first. Then you can simply rebuild the
binary with go build and run the binary with ./sogimood.
It's a shortcut to get the backend's dependencies, build the binary and run it. It doesn't touch to the frontend.
It is useful when you want to develop for the frontend. It executes the previous script in background to have the backend running on localhost:8081 and start a small NodeJS server able to do hot reloading. It means the frontend will open on localhost:3000 and each time you change a JS file, it will automatically reload the page.
All the JSON requests are automagically proxified to the backend so you don't have to worry about CORS issues.
When accessing localhost:3000 at the first time, an error could happen if the backend is not running yet. Just wait for it and reload the page.
What are the available API routes?
GET /api/projects
DELETE /api/project?id={uuid}
# Either specify an ID if you want to update, or leave it blank if you want the
# server to create a new entry.
POST /api/project
Body: [project to insert]
# id refers to the project id, of course.
POST /api/mood?id={uuid}&weekNo={weekNo}
Body: [mood to upsert]
Why the frontend is not able to access the API?
Did you set the Access-Token and Content-Type headers?
Access-Token: <token>
Content-Type: application/json
How do I know the API models?
Please refer to ./api.go.
Sogimood is actually deployed on Heroku.
First, you should have a running Heroku app, configured with a Redis database
and the ACCESS_TOKEN should be set (unless you want your Sogimood in free
access!)
Add your Heroku app's Git repository as a remote of your local repo:
$ git remote add heroku https://git.heroku.com/sogimood.gitNow we're done, there's a last script we didn't explain in the previous
section: scripts/deploy.sh.
This script builds the frontend, commits the generated ./dist folder, push
force the code on Heroku and reverts the last commit. Yeah, it's a bit dirty
but I have no better solution in mind yet. Feel free to contribute! :)
Dependencies are handled by Godep. First, install it:
$ go get github.com/tools/godepThen, simply run from the root of the project:
$ godep saveTo finish, do not forget to commit these new dependencies.
For the moment, tests are available for the frontend only:
$ cd client
$ npm install # if not done yet
$ npm testWe use Jest as the test runner. The
configuration comes from the react-scripts so please refer to
create-react-app repository
if you want more information about how it works.
We also use enzyme to test React components and fetch-mock to mock the fetch API.