E-Mail MicroService (EMS)

An Alternative Open Source to AWS SES
Open Source Technologies
- TypeScript
- MongDB
- NodeJS
EMS Objectives
- Import CSV Users List
- Relationship CSV User List with TAG
- Send automatic message for one or many TAGs
Business Rules
- for TAGs
- for users
- Na importação, se a tag não existir ela deve ser criada
- Na importação, se o usuário já existir, só vamos veicular com a tag
- Multiples Tags per users
Integration
- AWS SES
Infrastructure
- MongoDB
- Express
- Kafka
Requisitos Funcionais — RF
- Importar uma lista em CSV e relacionar ela com uma tag
- Enviar mensagem para uma ou mais tags
- Listar inscritos em uma ou mais tag
- Visualização do Progresso de Envio (Concluido/ não concluido)
Requisitos Não Funcionais — RNF
- Utilizar o Amazon SES ($1 => 10.000 emails sents)
- Utilizar MongoDB
- Utilizar Express
- Serviço de Mensageria (REDIS, KAFKA)
Regras de Negócios — RN
- Na importação, se a TAG não existir ela deve ser criada
- Na importação, se o usuário já existir, só vamos veicula-lo com a tag
- A importação deve permitir múltiplas tags
Minimum Value Product — MVP
- 1 semana
Project Structure
- yarn init -y
- yarn add nodemon sucrase -D
- yarn add express
- Install TypeScript
- yarn add typescript ts-node-dev @types/express -D
- yarn add [@typescript](http://twitter.com/typescript "Twitter profile for @typescript")-eslint/eslint-plugin -D
- yarn add @typescript-eslint/parser -D
- yarn add eslint -D
- yarn add eslint-config-airbnb-base -D
- yarn add eslint-config-prettier -D
- yarn add eslint-import-resolver-typescript -D
- yarn add eslint-plugin-import -D
- yarn add eslint-plugin-prettier -D
- yarn add prettier -D
- yarn add tsconfig-paths -D
Coding

Production Dependencies
- yarn add mongoose
- yarn add @types/mongoose -D
Install MongoDB with Docker

- docker pull mongo
- docker run -d -p 27017:27017 -p 28017:28017 -e MONGODB_PASS=”admin” mongodb
- docker run -d -p 27017:27017 -e MONGODB_PASS=”admin” -e MONGODB_USER=”admin” mongo

Test Driven Development — TDD


- yarn add jest -D
- yarn add @types/jest -D
- yarn jest — init
yarn add ts-jest -D
yarn test

- yarn test — watchAll

Functionals Tests
- HTTP Client for Requisitions
- Database Mock => MongoDB Fake
- MongoDB Memory Server
- jest-mongodb
[GitHub - shelfio/jest-mongodb: Jest preset for MongoDB in-memory server
Jest preset to run MongoDB memory server $ yarn add @shelf/jest-mongodb --dev Make sure mongodb is installed in the…github.com](https://github.com/shelfio/jest-mongodb "https://github.com/shelfio/jest-mongodb")
$ yarn add @shelf/jest-mongodb --dev
Jest with MongoDB Setup
[Using with MongoDB · Jest
With the Global Setup/Teardown and Async Test Environment APIs, Jest can work smoothly with MongoDB.jestjs.io](https://jestjs.io/pt-BR/docs/mongodb "https://jestjs.io/pt-BR/docs/mongodb")




