Skip to content

vangav/vos_whatsapp_worker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

why? whatsapp is a vangav backend template covering: service oriented architecture, worker service, multi-entry-point api, basic authentication and multi-keysapce database

whatsapp worker

whatsapp backend design

prerequisite

functionality

  • handles user signup and authentication
  • sending messages
  • fetching messages and users' info
  • dispatching analytics writing to whatsapp worker
  • handles writing analytics into the database
  • handles fetching users' and messages' analytics

overview

  • this service is based on vangav backend's whatsapp template
  • this service has the 90+% of the vangav backend's generated code + the 10-% of the logic code needed to complete the service

try this service

  1. for first timers - follow the steps in the system requirements tutorial
  2. for first timers - follow the steps in the workspace initialization tutorial
  3. download vos_whatsapp.zip, vos_whatsapp_worker.zip and vos_whatsapp_analytics.zip projects (from the green clone or download button) inside the workspace directory created previously (my_services) and unzip them
  4. rename unzipped directories, remove the -master from their names
  5. in the terminal cd to vos_whatsapp/cassandra/cql/
  6. execute ./_start_cassandra.sh to start cassandra
  7. cd to vos_whatsapp/cassandra/cql/drop_and_create/
  8. execute the commands ./_execute_cql.sh wa_....cql to initialize the services' database tables; repeat this step for all the .cql files
  9. cd to vos_whatsapp_worker and execute ./_run.sh to start the whatsapp worker service on port 8000
  10. cd to vos_whatsapp_analytics and execute ./_run.sh 7000 to start the whatsapp analytics service on port 7000
  11. cd to vos_whatsapp and execute ./_run.sh to start the whatsapp service on port 9000
  12. from your prefered client (we recommned postman) start trying the service; refer to the features and service references sections for reference
  • at the end to stop the services: press control + d in the terminal session where each service was started in (9, 10 and 11)
  • to stop cassandra: execute ps auwx | grep cassandra to get cassandra's (pid) then kill -9 (pid) to stop cassandra

eclipse

  • follow the following steps to import the downloaded backend service in eclipse
  1. cd to the service's directory and execute the ./_eclipsify.sh script
  2. file > import > general > existing projects into workspace > next > set "select root directory" to my_services > under projects make sure that vos_calculate_sum is selected > finish
  3. double check the java version used for compiling the project: right click the project > properties > java compiler > enable project specific settings > compiler compliance level > 1.7 or 1.8

covered topics

  • generate multiple services (main + worker + analytics) to work together in a service oriented architecture
  • generate a multi-keyspace database
  • basic authentication

features

controller(s) feature
signup handles new users' signup using phone numbers
send message handles sending a message
get messages and get user info handles getting new messages and users' info (id, name, ...)
controllers feature
get users count and get messages count handles fetching analytics data (total counts and count per-day)

service references

reference explanation
routes api routes
controllers.json api request/response's elements
wa_auth.keyspace wa_auth is the keyspace used for all authentication-related tables
wa_users.keyspace wa_users is the keyspace used for all users-info-related tables
wa_chat.keyspace wa_chat is the keyspace used for all chat-related tables
wa_blobs.keyspace wa_blobs is the keyspace used for all blobs-related tables
wa_analysis.keyspace wa_analysis is the keyspace used for all analysis-related tables
common handles controllers' common operations like authentication
controllers api implementation
wa_auth wa_auth cassandra's keyspace client
wa_users wa_users cassandra's keyspace client
wa_chat wa_chat cassandra's keyspace client
wa_blobs wa_blobs cassandra's keyspace client
wa_analysis wa_analysis cassandra's keyspace client
reference explanation
routes api routes
controllers.json api request/response's elements
wa_analysis.keyspace wa_analysis is the keyspace used for all analysis-related tables
controllers api implementation
wa_analysis wa_analysis cassandra's keyspace client

change log

  • this section lists the 10-% code added after vangav backend generated 90+% of the code
file/dir change
common added common controllers' operations like authentication
controllers added the implementation of request processing logic under controller_name/HandlerControllerName.java classes and nested response json structures under controller_name/response_json packages
file/dir change
controllers added the implementation of request processing logic under controller_name/HandlerControllerName.java classes and nested response json structures under controller_name/response_json packages

error codes

  • following are the error codes of whatsapp services
class code : sub_code explanation
CommonPlayHandler
300 : 1 user not signed up
300 : 2 wrong password
HandlerSignup
301 : 1 user has no password
301 : 2 wrong password
HandlerGetUserInfo
302 : 1 user not registered
302 : 2 didn't find user's info
HandlerSendMessage
303 : 1 can't send message(s) to yourself
303 : 2 message's recieving user isn't registered
HandlerGetMessages
304 : 1 didn't find message's blob (content)
class code : sub_code explanation
HandlerGetMessagesCount
400 : 1 to-date is smaller than from-date
HandlerGetUsersCount
401 : 1 to-date is smaller than from-date

notes

share

facebook share twitter share pinterest share google plus share linkedin share

free consulting

vangav's consultant