Mail_Out is a MERN fullstack web app that helps companies to create email campaigns and get customer feedback in a simple 'yes/no' format, the feedbacks are recorded and summarized in the company dashboard. Users buy credits to their account which is used on the email service which they send.
The tech stack mainly comprises of MongoDB, Express, React, and Node.js and deployed to Heroku. Other services include Google OAuth for authentication, Stripe for payments, and SendGrid for mailing out survey campaigns. Materialize CSS for minor styling.
The app is already deployed on Heroku here.
PS : Use credit card number "4242 4242 4242 4242" and CVC security code with future expiration date to test payment.
- free developers accounts from Stripe for handling (test) payments, Heroku for cloud hosting, MongoDB for backend database hosting, sendGrid for sending of email campaigns, and Google for OAuth authentication (e.g. latest developers link.
Create a file "dev.js" in /config and paste the following configuration keys with appropriate values.
module.exports = {
googleClientID: 'YOUR_GOOGLE_PLUS_ID',
googleClientSecret: 'YOUR_GOOGLE_PLUS_SECRET_KEY',
mongoURI:'YOUR_MONGODB_URI',
cookieKey:'YOUR_COOKIE_KEY',
stripePublicKey: 'YOUR_STRIPE_PUBLIC_KEY',
stripeSecretKey: 'YOUR_STRIPE_SECRET_KEY',
sendGridKey: 'YOUR_SEND_GRID_API_KEY',
redirectDomain:'YOUR_LOCAL_DEVELOPMENT_SERVER_ADDRESS'
};
npm install && npm install --prefix client
In the project top level 'server' directory, the following script will run the app in development mode by initiating both the client and backend server: To start the app, run the following command.
npm run dev
Make sure the right content type like Content-Type: application/json; charset=utf-8
is correctly returned.
{
"user": {
"googleId": "iefbeiveievbjbevjklmwnn"
}
}
{
"user": {
"googleId": "iefbeiveievbjbevjklmwnn",
"credits": 2
}
}
{
"title": "customer feedback request",
"body": "Thank you for the purchase of our service, we would love to get a review from you. ",
"subject": "Do you love our service and will you recommend it to your friends?",
"recipients": [{"email": "[email protected]", "responded": true}, {"email": "[email protected]", "responded": false}],
"yes": 3,
"no": 1,
"_user": "huweffioiq7yufweghokqdwgfuiw",
"dateSent": "22-10-2020",
"lastResponded": "22-10-2020"
}
{
"recipients": [
{
"email": "[email protected]",
"responded": true
},
{
"email": "[email protected]",
"responded": false
}
],
}
If a request fails any validations, expect a 422 and errors in the following format:
{
"errors":{
"body": [
"can't be empty"
]
}
}
401 for Unauthorized requests, when a request requires authentication but it isn't provided
403 for Forbidden requests, when a request may be valid but the user doesn't have permissions to perform the action e.g "Insufficient credits. Please add credits."
404 for Not found requests, when a resource can't be found to fulfill the request
GET "/auth/google",
No authentication required
GET "/api/logout",
Authentication required
GET "/api/surveys",
Authentication required, returns the credits and list surveys of logged in user.
POST "/api/surveys",
Example request body:
{
"title": "customer feedback request",
"body": "Thank you for the purchase of our service, we would love to get a review from you. ",
"subject": "Do you love our service and will you recommend it to your friends?",
"recipients": [{"email": "[email protected]", "responded": true}, {"email": "[email protected]", "responded": false}],
"_user": "huweffioiq7yufweghokqdwgfuiw",
"dateSent": "22-10-2020",
}
Authentication required, 1 credit required.
Required fields: title
, body
, subject
, recepient
, user
.
POST "/api/surveys/:surveyId/:choice"
Example request body:
{
"_id": "surveyId",
"recipients": {
"$elemMatch": { "email": "[email protected]", "responded": false },
},
},
{
"$inc": { "choice": 1 },
"$set": { "recipients.$.responded": true },
"lastResponded": "20-10-2020",
}
No authentication required.
POST "/api/stripe"
Example request body:
{
"amount": 500,
"currency": "usd",
"source": "tok_visa", //prev req.body.id
"description": "5 survey credits for $5"
}
Authentication required.
Required fields: amount
, currency
, source
, description