Build a full stack web application - OurApp (a social media app) using Node.JS, Express.Js, MongoDB, EJS (Template Engine for server side rendering) and deploying the application to Heroku.
Build a full stack web application - OurApp (a social media app) using Node.JS, Express.Js, MongoDB, EJS (Template Engine for server side rendering) and deploying the application to Heroku.
OurApp is a simple real world application where users can write short tweets, follow each other and also chat with each other. You can have a look at the final product's demo video before starting the project.
This project is best for those who want to dive deeper into full stack using Nodejs and MongoDB after learning HTML, CSS and JS. Building a full stack application single-handedly is a tough task, but learning and building such applications will help you master your skills.
Building this project will be a challenging task where you will get to learn and explore all about the MVC pattern, NoSQL Database (MongoDB) and much more.
We can divide the project based on the stack used:
Demo of the project:
Build a full stack web application - OurApp (a social media app) using Node.JS, Express.Js, MongoDB, EJS (Template Engine for server side rendering) and deploying the application to Heroku.
OurApp is a simple real world application where users can write short tweets, follow each other and also chat with each other. You can have a look at the final product's demo video before starting the project.
This project is best for those who want to dive deeper into full stack using Nodejs and MongoDB after learning HTML, CSS and JS. Building a full stack application single-handedly is a tough task, but learning and building such applications will help you master your skills.
Building this project will be a challenging task where you will get to learn and explore all about the MVC pattern, NoSQL Database (MongoDB) and much more.
We can divide the project based on the stack used:
Demo of the project:
First validate the idea by doing a low level implementation (Proof of Concept) of the components and architecture involved in the project.
This will help you to:
Further in this task you will be setting up the required environment for the application's development.
Frontend
section of Crio Bytes. You can check them out too, they are absolutely free of cost!If you have gone through the app's demo, you might have observed the layout of the pages. We can categorize the frontend into:
Try to inspect the pages and break it into divisions. You can also try to come up with your CSS styles for building a similar app interface. It will be impressive if you come with your own design.
Bootstrap plays the most important role to build these components easily.
Create the basic UI for guest pages and home dashboard (that are seen after the initial login/register forms' landing page).You can start using bootstrap components here itself.
Create the header and footer of the webpage.
Flexbox plays the most important role while building the layouts. For reference you can use this.
At the end of this task the html pages must be made. Building one 404 error code page would be a plus for the app. Homepage is shown below:
In this task, we will start using Node.js and Express.js to build the backend of the application. Let's break this task into some steps:
Start building a server using express. Express.js, which is a lightweight framework for creating web servers, makes it easier to organize your application’s functionality with middlewares and routing.
After building the server, your project folder must be consisting of server.js
file along with package.json, package-lock.json and node_modules.
Now create a folder named views
inside your main folder and place all HTML files inside it and create a folder public
and place the CSS files inside it.
Use EJS; it lets you embed javascript into HTML templates i.e, build dynamic content into your templates. It is faster and simpler than using a full framework like Angular or React, although less feature rich.
div
). Example of a template-/*include('includes/header') */
<div class="container py-md-5 container--narrow">
<div class="text-center">
<h2>Whoops, we cannot find that page.</h2>
<p class="lead text-muted">You can always visit the <a href="/">homepage</a> </a> to get a fresh start.</p>
</div>
</div>
/* include('includes/footer') */
At the end of this task your server should be listening for requests at a port. And, your views folder should contain the partials and pages using EJS. The terminal should look like this after using nodemon when starting the server.
In this project, we will be using MongoDB as the database. Refer this to know why we should prefer NoSQL over SQL databases in some cases.
Let's divide this task into some steps:
We will now start breaking the project into MVC pattern. M which stands for Model is where we will include all our business logic or all the rules that we want to enforce on our data. V which stands for Views i.e, the UI (User Interface). C which stands for Controller is the middleman depending on the incoming request. It will call the appropriate model with appropriate logic.
Once that's done the Controller will call the appropriate View and pass it any relevant dynamic data from the Model.
db.js
file in your folder and create a connection to a MongoDB instance which returns the reference to the database..env
file and store the private keys and attributes there and use it wherever required. This ensures safety and privacy of your database cluster.In this task, we will be building the authentication for the app. Let's divide this task into smaller steps:
userController.js
and models in userModel.js
. Validate attributes before storing it to the database. Like this, divide others based on functionalities. Refer thisExpected outcomes are shown below:
In this task, we will be building the core functionalities of the app. Let's divide this task into smaller steps:
In this task, we will be building a live chat and live search feature of the app. Let's divide this task into smaller steps:
frontend-js
and install webpack, webpack-cli, @babel/core and @babel-loader.const path = require('path')
const webpack = require('webpack')
module.exports = {
entry: './frontend-js/main.js',
output: {
filename: 'main-bundled.js',
path: path.resolve(__dirname, 'public')
},
mode: "production",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
}
}
In this task, we will be building live validation for the registration form and implementing csrf security to the app.
In this task, you will be pushing your project into GitHub. Make a good README for your project so that your project is well-documented.
git init
..git
file inside your repository and the unstaged files.node_modules
and .env
file (if any) before pushing it to GitHub using .gitignore
file.In this task, we will be deploying it to Heroku to make it live.
.env
file, use config vars in the setting menu of heroku to store those values before deploying.