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.
- Signup and signin
- Session management
- Reset password
- Email notifications
EmailService.sendEmail()
- Queues and jobs
WorkerService.addJob
- Cron jobs
WorkerService.addCronJob
- 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 tohtml.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
Folder structure
app.js
- The main file that spawns the serverroutes
- You may call it controller as well. The purpose of this code is to route requests to appropriate service after validationmiddleware
- Different routes want to apply some common logic before the request is processed e.g. "is this a request from an authenticated user?". This folder contains code for those common things you want to do before the request is processed. If you know express, you know this already. If not, checkroutes/auth.js
to see how you can call a middleware on a route.services
- The purpose of this code is to make request to database or external APIs. Controllers(routes
) and other services use the services available hereviews
- Frontend html code. We useejs
here as the templating langugageviews/email-templates
- All the email templates written inmjml
and then exported toejs
public
- Frontend side assets including styles and javascript codeconfig
- The configurations, you'll likely want to change to suit your project
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
Checklist for production deployment
- Update the config for production (
config/production.env
) - 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