Trip management at it's best for Andela.
Tembea is the our solution for making trip request, scheduling, reporting and analytics very easy at Andela.
/api/v1/slack
: our slack integration is our MVP
/docs/v1/
| /docs/v2/
: Swagger API documantation
-
NodeJS - A JavaScript runtime environment
-
Express - A web application framework for NodeJS
-
PostgreSQL - A relational database management system that extends SQL
-
Redis - A in-memory data structure store, used as a database, cache and message broker.
-
Sequelize - A promise-based ORM for NodeJS
-
Google Map API - Node.js client library for Google Maps API Web Services
-
Andela Auth Service - Andela Authentication service
-
AIS - Andela AIS API
-
Mailgun - Powerful Transactional Email APIs that enable you to send, receive, and track emails, built with developers in mind
-
Twilio - Twilio allows software developers to programmatically make and receive phone calls, send and receive text messages, and perform other communication functions using its web service APIs
Follow these steps to set up the project in development mode
-
Install Nodejs
-
Install and setup PostgreSQL
-
Clone the repository by running the command
git clone https://github.com/andela/tembea.git
-
Run
cd tembea
to enter the application's directory -
Install the application's dependencies by running the command
yarn install
-
Create the
.env
or.env.development
file by runningcp .env.sample .env
orcp .env .env.development
-
Populate the env file created above by using instructions provided in this README and actual .env.sample file.
-
Setup the database and migrations (see database setup)
-
Start the application by running
yarn run start:dev
The application should now be running at
http://127.0.0.1:5000
-
Create a database in
PostgreSQL
and name ittembea
-
Set the following environment variables in
.env
(to be created in theenv
directory):DATABASE_USERNAME
- this is the database usernameDATABASE_PASSWORD
- this is the database password. Ignore if you don't have a database passwordDATABASE_NAME
- set this totembea
-
Run database migrations
yarn run db:migrate
-
Check the database and confirm that the
users
table has been created
- Create your slack workspace goto
https://slack.com
> Your Workspaces > Create Workspace - Create Slack App go to
https://api.slack.com
> Your Apps > Create New App provides app name eg:tembea
then select workspace created above - Go to basic information and notes the followings:
- Client ID -> SLACK_CLIENT_ID
- Client Secret -> SLACK_CLIENT_SECRET
- Signing Secrent -> SLACK_SIGNING_SECRET
- Go to Incomming Webhooks > activate Incomming webhooks > turn it on
- You need live url to interact with slack API servers you can use ngrok or pagekite etc..
download ngrok and start it.
$ mv ngrok /usr/local/bin
start ngrok and copy https url
$ ngrok http 5000
-
head back to
https://api.slack.com
and select your app then > Interactive Components > enable it
Then adds Request URL
eg:https://ee01aae4.ngrok.io/api/v1/slack/actions
-
Go to Slash Command > Create New Command
- command : adds
/tembea
- Request URL: adds
eg:
https://ee01aae4.ngrok.io/api/v1/slack/command
- adds optional description eg:
Launches tembea
- command : adds
-
Go to OAuth & Permissions
- Redirect URLs > add new URL
eg:https://ee01aae4.ngrok.io/slackauth
- OAuth Tokens & Redirect URLs > Install App to Your Workspace. > select channel tembea will be posting in
- then note the following env variables
OAuth Access Token -> SLACK_BOT_ACCESS_TOKEN
- Redirect URLs > add new URL
-
Go to Bot Users > click add bot user
After setting up your .env
from the template provided in the env/.env.sample
file;
to use these environment variables anywhere in the app, simply:
process.env.MY_ENV_VARIABLE
NOTE: Make sure no service is running on port 5000 and ensure there is a
.env
file with all the necessary environment variables.
To run the application just type: make start
this would run your application inside a container which you can easily access using localhost:5000
.
To stop the application, you can just hit ^c
.
To delete the containers: make stop
WARNING: Running below command will make you loose all your data including data in the database!
To cleanup all the containers + volumes: make clean
NOTE: The below commands should be run when the application is running inside container
To migrate database: make migrate
To seed database: make seed
To rollback migrations: make rollback
To get inside the container: make ssh
HINT: To use docker, ensure that your .env file does not contain DATABASE_URL
as it conflicts with the value in docker-compose.yml
Jest is used as the testing framework for both the unit tests and integration tests. To execute all tests, run the command
yarn test or make test
TODO - add deployment commands