How does the tech stack sandwich work?

I’m working on my final year project and right now I’m building the frontend and it’s going great but I’m stuck on figuring out how the backend would fit into this.

The project is to make a web app that allows the admin to add new teachers and subjects and it’s timings into the database and the app should automatically send an email notification to the teacher assigned to a particular subject 10 minutes before the class is scheduled to start.

I have no idea what the framework is going to be for this project, which tools to use, API’s, ExpressJs, NodeJs, server-side functions. I’m totally confused what tools or packages I need to build this and how it all comes together.

Thank you for reading this far. I apologise for this messed up confusion.

Express is a Node.js framework, which you can use to write an API, which could serve as your back-end. This would probably help:

1 Like

Hi @basicallyababy !

For the email functionality, you can use nodemailer.
You can also use node-cron to set a schedule to send emails every weekday 10 minutes before class.

https://nodemailer.com/about/

Hope that helps!

1 Like

These requirements can be deceivingly complex, to “show stopper” if you aren’t used to managing things done over time. As most tutorials, and curriculum (like freeCodeCamp) usually go over “user event driven” setups, where the user does something (creates something), and that goes through the “whole stack”.

In this case, you actually have another flow. Namely the reminder email sent 10 minutes before a class is scheduled to start.

I’ll leave the above resources for getting the idea of “what a back-end does”, and provide some context around the single requirement of sending reminder emails.


Sending reminder emails based on time before an event.

So there are a few ways to do this. All of them are based around a concept called a job schedule, like a cron job.

Depending on where your application is setup, you could setup an actual cron job, or setup some configuration with your runtime/cloud provider to call an endpoint on a given schedule. This will be how your program “checks” for reminder emails to send. Depending on how classes could be setup, you could be running this job schedule every 10 minutes, to every 1 hour, to even possibly every minute. Less is better, as you don’t want to run computations too much or your just wasting.

The next part is letting the code that is ran on that schedule to know what emails to send, and to who. This is where you usually have some pre-set data saved in your database that says “send an email at 2:15pm” that is easily found. This should be setup ahead of time, and not calculated on the fly, as date-time calculations can get nasty.

The advantage of this approach is its flexible in whatever ops you have. You can’t just use setTimeout and set the reminder in the far future, as if your program deactivates/restarts it loses those variables. So you must save the state of when to send the emails in your database.

Dealing with dates and times can be annoying as well, there’s also the possibility you need to deal with different timezones. All in all this sort of feature can get finicky fast so plan out extra time to iron out the kinks.

Hopefully that helped at least get an idea of what you need to do.

Good luck, keep building, keep learning :+1:

1 Like

Thank you so much. Thankkkkkkkkkk You. Tbh I can’t thank you enough. You are awesome

Thank youuuuuuuuuuuuu so muchhhhhhhhh. I’m spamming at this point but thank you so much for helping me out.

So all this code will form a part of the backend right?

Node and express would be the backend portion of the site.
Scheduling the emails with node-cron is backend.

1 Like

OK the fogs getting clearer in my head. Among all of this, will I also need to create an api? If yes, then where does it fit in?

I started watching the API for beginners course on the freeCodeCamp youtube channel so it’s getting a bit clear of what an api is.

Thank you so much for all the help

Maybe I need to figure out a different approach to this. It sounds like it’s about to get nasty for finishing the entire project in 2 months. By I won’t give up this easy. Thank you so much for helping me out.

If you have 2 months to learn and implement these requirements, you’d be cutting it very close.

As not only are you learning how to build a back-end, you also need to know how to secure it. Which also includes authentication/authorization, among other security measures.

You also will need to handle the deployment or “ops” side, such as deployment, scaling, hosting, etc. As you can program your app just fine, but if you can’t access it, then it isn’t useful in the real world.

Finally, there is the actual nature of doing the “time” feature itself. Dealing with time and dates is tricky for any developer, to the point it’s generally considered something you just should avoid doing yourself most of the time. This is why I specifically said to setup a cron job, or leverage your environment’s internal tools if they are available. This wont remove all the possible pain points, but it should remove most.

It’s a lot to learn in little time, and then take what you learn and built what you need.

1 Like

Aye Aye captain. There’s so much to learn, and it’s exciting. What I’m thinking is to build it in a way that the admin has to click on the “Start the class” button which would send email notification to all the teachers with their respective class timing.

Later as I keep learning, I will improve it little by little, implementing the job scheduling, security and other measures.

I would still try to implement the “time” feature before the final submission date.
Thank you again so muchhhhh. :pleading_face: :pleading_face:

1 Like

You will be creating your api on the backend.
The frontend will fetch that data.

The backend is the logic of the application.
The frontend is what the user interacts with.

There are a lot of good tutorials and articles on creating your own rest apis.
Programming with Mosh has a one hour crash course to get you started.

1 Like

Thank you so much. :pleading_face:

This is a very informative thread! Definitely bookmarking this one for later. :slight_smile:

1 Like