A boilerplate for SaaS with features such as authentication, email service, etc.

Overview

Web SaaS Starter Kit - Node.js, Express

Boilerplate for a web app with common features that every SaaS(Software as a Service) needs

Every time, I wanted to build a new web app, I used to code everything from scratch. Login, signup, session management, email notifications, and whatnot. Eventually, when I had found the right tools and code for everything, I kept that as a starter template for myself so I wouldn't need to solve the challenges that I had already solved.

Am I the only person who needs these features for a new project? Or does everyone needs the same features in their web-based SaaS tool? Why not open-source this and let everyone bootstrap their projects with this template!

I hope, this saves some time and helps you invest your time and energy in making system design and programming decisions that are unique to your SaaS web app. Start a project a little ahead of the starting line, where some common features are already implemented and well tested.

Features

  • Signup and signin
  • Session management
  • Email notifications
  • Reset password
  • Feature flagging
  • Single file to configure features(e.g. API keys, settings)

Made to last long

For most of these features, I have used other stable and well-maintained open-source projects. So you don't need to rely on me to keep this starter kit up-to-date(well, except updating once in a while, which I can certainly find time for).

Get started

  • Clone this repo
  • npm install
  • Update the config for development (config/development.env)
  • For email templates, we use MJML. To update them, update the views/email-templates/**/html.mjml file and export it to html.ejs in the same folder. For which you can either use editor plugins such as vscode-mjml or mjml javascript library
  • Make your changes to the code
  • npm start

Configuration

  • Update them at config/development.js or config/production.js
  • SITE_DOMAIN_URL
  • SITE_TITLE
  • REPO_URL
  • SUPERTOKENS_CORE_URI
  • SUPERTOKENS_CORE_API_KEY

Folder structure

  • app.js at the root is the main file that spawns express server
  • views contains all the frontend html code. We use ejs here as templating langugage.
  • views/email-templates contains all the email templates written in mjml and then exported to ejs
  • services contains all code that can be separated as an independent service. Controller and other services use thes services.
  • public contains all the frontend side assets including styles and javascript code
  • routes contains all the business logic for different routes
  • config contains the configurations. Change them for your usage.

Checklist for production deployment

  1. Update the config for production (config/production.env)
  2. Make sure to run the server with NODE_ENV=production (e.g. node app.js --prod)

Made with awesome open-source projects 👉 express, cors, morgan, nodemailer, mjml, supertokens and more

License - MIT

Comments
  • feat: job queue

    feat: job queue

    • Added worker queues
    • Jobs - WorkerService.addJob
    • Cron Jobs - WorkerService.addCronJob
    • EmailService now has option to add email to queue EmailService.sendEmail(emailCategory, { addToQueue: true })
    opened by makeitcount 2
  • build(deps): bump ejs from 3.1.6 to 3.1.7

    build(deps): bump ejs from 3.1.6 to 3.1.7

    Bumps ejs from 3.1.6 to 3.1.7.

    Release notes

    Sourced from ejs's releases.

    v3.1.7

    Version 3.1.7

    Commits
    • 820855a Version 3.1.7
    • 076dcb6 Don't use template literal
    • faf8b84 Skip test -- error message vary depending on JS runtime
    • c028c34 Update packages
    • e4180b4 Merge pull request #629 from markbrouwer96/main
    • d5404d6 Updated jsdoc to 3.6.7
    • 7b0845d Merge pull request #609 from mde/dependabot/npm_and_yarn/glob-parent-5.1.2
    • 32fb8ee Bump glob-parent from 5.1.1 to 5.1.2
    • f21a9e4 Merge pull request #603 from mde/mde-null-proto-where-possible
    • a50e46f Merge pull request #606 from akash-55/main
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Email notifications APIs

    Email notifications APIs

    Easy to use javascript APIs to send transactional notifications to users via Email

    • [x] Functions to sendEmail(notificationCategory, contextData, { to, text, from })
    • [x] Testing using ethereal
    • [x] Templates
    • [x] Managing notification categories with respective templates
    • [x] Email branding - logo/color, header, footer, social links
    enhancement 
    opened by makeitcount 0
  • Fix the error during user/profile refresh

    Fix the error during user/profile refresh

    How to reproduce - After login, head over to /user/profile, check the server logs, you'll see following error

    GET /user/profile 302 17.288 ms - 148
    Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
        at new NodeError (node:internal/errors:371:5)
        at ServerResponse.setHeader (node:_http_outgoing:576:11)
        at ServerResponse.header (/home/johndoe/Projects/supertokens/example/saas-express-starter-kit/node_modules/express/lib/response.js:767:10)
        at ServerResponse.send (/home/johndoe/Projects/supertokens/example/saas-express-starter-kit/node_modules/express/lib/response.js:170:12)
        at done (/home/johndoe/Projects/supertokens/example/saas-express-starter-kit/node_modules/express/lib/response.js:1004:10)
        at tryHandleCache (/home/johndoe/Projects/supertokens/example/saas-express-starter-kit/node_modules/ejs/lib/ejs.js:280:5)
        at View.exports.renderFile [as engine] (/home/johndoe/Projects/supertokens/example/saas-express-starter-kit/node_modules/ejs/lib/ejs.js:491:10)
        at View.render (/home/johndoe/Projects/supertokens/example/saas-express-starter-kit/node_modules/express/lib/view.js:135:8)
        at tryRender (/home/johndoe/Projects/supertokens/example/saas-express-starter-kit/node_modules/express/lib/application.js:640:10)
        at Function.render (/home/johndoe/Projects/supertokens/example/saas-express-starter-kit/node_modules/express/lib/application.js:592:3)
    
    bug 
    opened by makeitcount 0
  • Change in config management

    Change in config management

    There are two improvements that can further make the config management robust

    • [ ] Use one config file only (remove dev vs prod config, just one file instead)
    • [ ] A mechanism that ensures no config is missing from sample config (can use dotenv-safe for this)
    enhancement good first issue 
    opened by makeitcount 0
  • Project goals

    Project goals

    Goal

    Boilerplate code to speed up development of a new SaaS app

    Principles

    Broadly, we can follow these principles to make the project useful with a good developer experience

    1. Must have some Complete Features: These features are ready to use (these features do not expect much different implementations in different use cases e.g. auth)
    2. Must have some Abstract APIs: These APIs(functions/services) help in building some of the most frequently used features in SaaS (where implementation vary a lot based on the use case e.g. email service, user roles, etc.)
    3. Changes should be easy
      • Changes in Complete Features should be driven by configuration changes (e.g. replacing email/password login with passwordless login)
      • Changes in Abstract APIs should be driven by changing or extending the code
      • Abstract APIs should be documented
      • No styling opinion, a frontend without styling
      • Code Smells - If a dev needs to remove code or change the code structure in order to build their use case
      • Keep it lean

    Agree? Give it a thumbs up :+1: Have feedback for goal/principles? Comment your thoughts

    opened by makeitcount 0
  • Themes : Customize element styles

    Themes : Customize element styles

    For now, we use no CSS at all, but real world application wouldn't do that. We did that to make sure we do not make any opinions on the design because we expect that the end user is going to change the design to match their brand and choice anyway. So changing an already opinionated design system will be harder than to start from element without any design at all. But how can we even make this work easier?

    Answer: Provide a sample css theme that can be dropped in public/stylesheets folder and that should automatically change the design for the whole app. We still adhere to the rule that we don't add any opinion about the design elsewhere in the code (i.e. no element styles in html inline, no reference to any other external css.

    enhancement 
    opened by makeitcount 0
  • Email service api support for different vendors

    Email service api support for different vendors

    Make it easier for people to add their choice of email transporter from following

    • [ ] Amazon SES
    • [ ] Mailgun
    • [ ] Mailchimp
    • [ ] Postmark
    • [ ] SendGrid
    • [ ] SparkPost

    Resource - https://nodemailer.com/transports/

    enhancement 
    opened by makeitcount 0
Releases(v1.4.0)
  • v1.4.0(Aug 4, 2022)

    What's Changed

    • Added worker queues
    • Jobs - WorkerService.addJob
    • Cron Jobs - WorkerService.addCronJob
    • EmailService now has option to add email to queue EmailService.sendEmail(emailCategory, { addToQueue: true })

    Full Changelog: https://github.com/makeitcount/saas-express-starter-kit/compare/v1.3.0...v1.4.0

    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Jul 21, 2022)

    • Released new feature - reset password
    • Improved authentication by using supertokens-web-js and removing supertokens-website SDK
    • Updated README and homepage to reflect the new changes

    Full Changelog: https://github.com/makeitcount/saas-express-starter-kit/compare/v1.1.2...v1.3.0

    Source code(tar.gz)
    Source code(zip)
  • v1.1.2(Jun 20, 2022)

  • 1.1.1(Jun 20, 2022)

  • v1.0.3(Jun 5, 2022)

  • v1.0.1(May 24, 2022)

Owner
Make It Count
Coding for greater good of the society and open internet. #CodeForGood Follow @codeforgood-official and https://twitter.com/_codeforgood
Make It Count
React Native Boilerplate - The Boilerplate contains all the basic packages, common components and, prebuilt code architecture

The Boilerplate contains all the basic packages, common components and, prebuilt code architecture. It will save developer's project setup time.

MindInventory 36 Dec 26, 2022
Solana Boilerplate - Lightweight boilerplate for Solana dapps. Allows quick building and prototyping.

Lightweight boilerplate for Solana dapps. Allows quick building and prototyping. Feel free to contribute or fork this repository. Make it yours! Leave us a ⭐️ if this repo helped you.

null 21 Nov 15, 2022
A few simple, but solid patterns for responsive HTML email templates and newsletters. Even in Outlook and Gmail.

Cerberus Responsive Email Patterns Coding regular emails is hard enough by itself. Making them responsive shouldn’t add to the headache. A few simple,

Ted Goas 4.6k Dec 28, 2022
Next.js + Tailwind CSS + TypeScript starter packed with useful development features

?? ts-nextjs-tailwind-starter Next.js + Tailwind CSS + TypeScript starter packed with useful development features. Made by Theodorus Clarence Features

Cornelius Denninger 7 Nov 12, 2022
An upgradable boilerplate for Progressive web applications (PWA) with server side rendering, build with SEO in mind and achieving max page speed and optimized user experience.

React PWA v2 A highly scalable, Progressive Web Application foundation,boilerplate, with the best Developer Experience. Demo: https://demo.reactpwa.co

Atyantik 2.5k Dec 26, 2022
A boilerplate for Node.js web applications

Hackathon Starter Live Demo: https://hackathon-starter.walcony.com Jump to What's new? A boilerplate for Node.js web applications. If you have attende

Sahat Yalkabov 34k Dec 28, 2022
React Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, React.js, Babel, PostCSS, Webpack, Browsersync)

React Starter Kit — "isomorphic" web app boilerplate React Starter Kit is an opinionated boilerplate for web development built on top of Node.js, Expr

Kriasoft 21.7k Jan 1, 2023
React + Redux starter kit / boilerplate with Babel, hot reloading, testing, linting and a working example app built in

A comprehensive starter kit for rapid application development using React. Why Slingshot? One command to get started - Type npm start to start develop

Cory House 9.8k Jan 3, 2023
DDD/Clean Architecture inspired boilerplate for Node web APIs

Node API boilerplate An opinionated boilerplate for Node web APIs focused on separation of concerns and scalability. Features Multilayer folder struct

Talysson de Oliveira Cassiano 3k Dec 30, 2022
A boilerplate for building production-ready RESTful APIs using Node.js, Express, and Mongoose

By running a single command, you will get a production-ready Node.js app installed and fully configured on your machine. The app comes with many built-in features, such as authentication using JWT, request validation, unit and integration tests, continuous integration, docker support, API documentation, pagination, etc. For more details, check the features list below.

Hagop Jamkojian 5k Dec 31, 2022
A MERN boilerplate repository with RBAC feature, following all production best practices.

Welcome to the RBAC MERN Boilerplate project A MERN boilerplate repository with RBAC feature, following all production best practices. In this reposit

Foyzul Karim 268 Dec 27, 2022
NextJS, TypeScript and Styled Components project boilerplate

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Mateus 2 Sep 21, 2021
A boilerplate to kick off any Gatsby project.

A boilerplate to kick off any Gatsby project. This starter ships with: - Gatsby v4 - Material UI v5 with light/dark mode and a custom theme - Emotion JS (with access to Material UI custom theme) - React redux (with reduxjs/toolkit) - React intl for multilingual support - React helmet for SEO

Mario Duarte 1 Jul 6, 2022
Jekyllist - Modern Boilerplate on Jekyll

Jekyllist - Modern Boilerplate on Jekyll Jekyllist is a production ready boilerplate for humans who wants to build simple websites (portfolio sites, b

Atakan Oz 2 Jul 21, 2022
Very minimalistic boilerplate to start most Typescript Express projects. Includes Mongodb connection via Mongoose with a sample post model.

Minimalist express-typescript-boilerplate Available Scripts - `tsc' - builds the tsc project to the dist folder - `build` - cleans the previous build

Black Axe 16 Dec 13, 2022
Express typescript boilerplate using @types/node, @types/express

Express framework boilerplate in typescript.

Harris Gurung 3 Sep 21, 2022
Vite Electron Builder Boilerplate

This is template for secure electron applications. Written following the latest safety requirements, recommendations and best practices.

Harry Hopkinson 4 Dec 15, 2022
Teaching boilerplate for teachers that are learning how to program with React

React course: react4teachers-zero2hero Teaching boilerplate for teachers that are learning how to program with React. Course offered by Conselleria d'

Alberto Soto 2 Jun 6, 2022
Next Boilerplate with TypeScript, Redux Toolkit and Styled-Component.. For now

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Ibrahim Yaacob 2 Feb 17, 2022