Giter Site home page Giter Site logo

email-messaging-app's Introduction

Hi, Ramdan here, this is simple application to send a happy birthday message to users on their birthday at exactly 9 am on their local times. This app is a task for coding test at surya digital teknologi

What I have accomplished

Created a scheduler to send birth day message ✅

Scheduler will running every hour and get users list to check if there are users need to be send a birthday message. Next scheduler will only running if previous scheduler finished the job, this will prevent race condition.

Created a scheduler to re-send unsuccessfull messages ✅

Scheduler will running every hour and get list of messages that failed to be sent, try re-send the message and update the message status to success if it's successfully sent.

Create simple API for user management ✅

POST /user to create new user, DELETE /user to delete a user and PUT /user to update user. API doc can be found at localhost:3000/api-docs/

Created simple email service ✅

POST /send-mail to mimic sending email service, POST /send-mail will return 10% error 500 and 10% server timeout. API doc can be found at localhost:3001/api-docs/

Abstracted code as possible ✅

Isolate and make code as modular as possible so it will be easy for unit testing

Most of the functions are tested ✅

Implemented testable code, most of the funcions is tested. Resulting in code coverage for statements 96% for database-service and 90% for email-service excluded file that have less to no logic and library generated files.

Dockerize the application ✅

Implemented simple microservice architechture for scalability and consistency when deploying the sistem

Added eslint and prettier ✅

Added these two library to support consistencies on code writing

Requirement to run the app

  1. Docker Desktop
  2. Docker Compose

How to run the app

Verifiying send birthday message behaviour

I have a users seeder that will populate users table with fake data and set their birthday month and date to today month and date (Asia/Jakarta). We need to set SENT_BIRTHDAY_AT_HOUR current hour, after that the scheduler should send the message to every user

Verifiying message log

When scheduler start sending message the log will be available in sendMessagesStatus table, we can check with below query

SELECT 
	u.id, u.firstName, log.userId, 
	log.messageId, log.sentStatus, log.sentTime,
	log.descriptions
FROM users as u
INNER JOIN sendingMessagesStatus as log
	ON u.id = log.userId

Verifiying duplicate message

To check if any duplicate message was sent we can use below query to see if there is more than one message is sent to the same user.

SELECT 
	userId,
	COUNT(userId) as totalUser
FROM sendingMessagesStatus as log
GROUP BY userId
HAVING count(userId) > 1;

Verifiying scheduler to resend message

To check if scheduler able to resend failure message we can regulary check the message log table (sendMessagesStatus) and see the sentStatus colum at some point there will be no more message with sentStatus = error.

SELECT 
	u.id, u.firstName, log.userId, 
	log.messageId, log.sentStatus, log.sentTime,
	log.descriptions
FROM users as u
INNER JOIN sendingMessagesStatus as log
	ON u.id = log.userId

Verifiying the users and email service endpoint

Please go the api docs for more detail, users endpoint api docs, email service endpoint api docs

email-messaging-app's People

Contributors

mramdanf avatar

Watchers

 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.