A full stack mern application called "memories" where users can post interesting events occurring in their life

Overview

Memories App

💫 💫 💫   Live Demo 💫 💫 💫

Full Stack "R"ERN Application - from start to finish.

The App is called "Memories" and it is a simple social media app that allows users to post interesting events that happened in their lives. with real app features like user authentication and social login using Google accounts and REDIS database.

  • Redis is an open-source (BSD-licensed), high-performance key value database and in-memory data structure store used as a database, cache, and message broker. Redis has excellent read-write performance, fast IO read-write speed from memory, and supports read-write frequencies of more than 100k + per second.

Overview video (Optional)

Here's a short video that explains the project and how it uses Redis:

Embed your YouTube video

How it works

  • Redis OM (pronounced REDiss OHM) makes it easy to add Redis to your Node.js application by mapping the Redis data structures you know and love to classes that you define. No more pesky, low-level commands, just pure code with a fluent interface.

User

const userSchema = new Schema(
  User,
  {
    name: {
      type: "string",
    },
    email: {
      type: "string",
    },
    password: {
      type: "string",
    },
  },
  {
    dataStructure: "JSON",
  }
);

await userSchema.createIndex(); // Builds the index for user repository

Posts

const postSchema = new Schema(
  Post,
  {
    title: { type: "text" },
    message: { type: "text" },
    name: { type: "string" },
    creator: { type: "string" },
    tags: { type: "text" },
    selectedFile: { type: "string" },
    likes: { type: "string[]" },
    comments: { type: "string[]" },
    createdAt: { type: "date", sortable: true },
  },
  {
    dataStructure: "JSON",
  }
);

await postSchema.createIndex(); // Builds the index for post repository

For simplicity, a unique key index with an hash value is created when a user or post is created and creates a new hashed index for subsequently added new repositories. This index key is unique for each repository, User and Post data are then stored in the redis database

The created unique index keys allows you to perform search on each of the repository

How the data is stored:

  • The user and post data are stored in various keys and various data types.
  • For each of user, key like: User:{userId} is generated and data is stored like:

  • For each of the post, key like: Post:{postId} is generated and data is stored like:

    • title: "My memory"
    • message: "Blissful memory"
    • name: "Wakeel Kehinde"
    • creator:"01GBMJVW68YR91FA94Y32NB6FZ" (an entityId of a user)
    • tags: "New, Honey, Moon"
    • selectedFile:"react-string"
    • likes:[ "01GBMJVW68YR91FA94Y32NB6FZ"] (an array of entityId of a user)
    • comments:["wow", "interesting"]
    • createdAt: 1661720826.775 (date stored in milliseconds)

How the data is accessed:

  • if an object's entityId is known, such object can be accessed using .fetch method on the repository

    const post = await postRepository.fetch(req.params.id)

    e.g:

    post.title // "My memory"
    post.message // "Blissful memory"
    post.name // "Wakeel Kehinde"
    post.creator // "01GBMJVW68YR91FA94Y32NB6FZ" (an entityId of a user)
    post.tags // "New, Honey, Moon"
    post.selectedFile // "react-string"
    post.likes // [ "01GBMJVW68YR91FA94Y32NB6FZ"] (an array of entityId of a user)
    post.comments // ["wow", "interesting"]
    post.createdAt // 1661720826.775 (date stored in milliseconds)
    
  • to access all data for a particular repository or perform any partial searche: Using RediSearch with Redis OM is where the power of this fully armed and operational battle station starts to become apparent. If you have RediSearch installed(which is installed along with latest Redis stack) on your Redis server you can use the search capabilities of Redis OM. This enables commands like:

    const posts = await postRepository.search()
    .where('name').equals('Wakeel')
    .and('tags').match('New')
    .return.all()
    
  • The above returns the posts with precisely name Wakeel and any tags that matches New

  • Recall that we built the index both user and post repository, this allows you to perform Redis searches on the repositories.

If you change your schema, no worries. Redis OM will automatically rebuild the index for you. Just call .createIndex again. And don't worry if you call .createIndex when your schema hasn't changed. Redis OM will only rebuild your index if the schema has changed. So, you can safely use it in your startup code.

  • Also, you can find all posts and return them with the command, This will return all of the posts that you've put in Redis:
const posts = await postRepository.search().return.all()
  • You can page through the results and sort in descending or ascending order. Just pass in the zero-based offset and the number of results you want:
const offset = 8
const count = 10
const posts = await postRepository.search().sortDescending("createdAt").return.page(offset, limit);
  • To access the first post. You can easily grab the first result of your search with .first:
const firstPost = await postRepository.search().return.first();
Note: If you have no posts, this will return null.

Performance Benchmarks

  • The first frame represents the response from the endpoint with MONGODB database
  • The second frame represents the response from the endpoint with REDIS database which implies more than 3x faster response

How to run it locally?

  • Fork this repo and run the git clone <forked repo> command from your terminal/bash
  • Make a copy of the .env.example file by running the command:
$ cp  .env.example .env
  • Insert the correct values for the environmental variables

  • Run the following command to start the application

$ npm install concurrently
$ npm install-all
$ npm run dev (to run both React client and Node server side development)

To start Redis Stack developer container using the redis-stack image, run the following command in your terminal:

$ docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest

For Google client Id you have to visit Google developers console from here generate your respective client Id Ensure the first two lines of the env file contains the REACT_APP_GOOGLE_API_TOKEN and REACT_APP_BASE_URL

REDIS_HOST = redis://localhost:6379

Prerequisites

  • Node - v16.16.0
  • NPM - v8.11.0
  • Docker - v20.10.16

Local installation

  • Run the command below in your rooot directory:
$ npm install concurrently
$ npm install-all
  • Note: This installs all dependencies for the client and the server simultaneously

Deployment

To make deploys work, you need to create free account on Redis Cloud

Heroku

Deployed Backend Link

Netlify

Frontend Memories App

You might also like...

A simple To Do List application that allows users to save, edit, mark completed, and delete their to-dos, and save their list when application is closed. Build with JavaScript.

To Do List A simple To Do List online application that allows users to save, and manipulate their to-dos, and save their list when application is clos

Dec 20, 2022

Move all the disks from the left hand post to the right hand post, only moving the disks one at a time and a bigger disk can never be placed on a smaller disk.

Move all the disks from the left hand post to the right hand post, only moving the disks one at a time and a bigger disk can never be placed on a smaller disk.

Hanoi Tower Description The Tower of Hanoi was a famous problem posed by a mathematician in 1883, The "puzzle" is to move all the disks from the left

Feb 5, 2022

Conways-game-of-life - A Conway's Game Of Life project using Python

conways-game-of-life A Conway's Game Of Life project using Python JavaScript Devlog January 1st 2022: also need to remember Python's syntax a bit will

Sep 23, 2022

Online Inventory Control System for an apparel manufacturing company "CASANOVA" (Pvt) Ltd. Technology stack: Node.js, Express.js, MongoDB Atlas, React.js (MERN Stack).

Project Name - Online Inventory Control System for an apparel manufacturing company "CASANOVA". The project was given a "A" grade. Group Leader - IT20

Dec 26, 2021

Modern Full Stack Social Media App (MERN)

Modern Full Stack Social Media App (MERN)

Pixby A Full Stack Social Media Application Built with React Vite Chakra UI NodeJs Express MongoDB Nodemailer Cloudinary Installation Run the setup.sh

Nov 26, 2022

Full Stack MERN website for local small business "Daisy's Cakes"

Daisys-Cakes Full Stack MERN website for local small business "Daisy's Cakes" Contribution Info This section will be deleted later when the project is

Nov 13, 2022

This React-Based WebPage allows the client/user system to create their own blog, where users can publish their own opinions.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Jul 28, 2022

A full stack application that uses an authentication system to allow FAA Inspectors, Airliners, and Aircraft Technicians to update progress on their work all while keeping a log of records on projects completed.

A full stack application that uses an authentication system to allow FAA Inspectors, Airliners, and Aircraft Technicians to update progress on their work all while keeping a log of records on projects completed.

Jun 13, 2022
Owner
Phenom
FullStack Developer (PWA | React | Typescript | Node | Next | Express | Django | SQL | NoSQL | REST API, Graphql)
Phenom
A full-stack social media application where users can post and share their coding projects, adding friends, and joining the discussion in threaded comments on project posts.

CodeFlow Description CodeFlow is a social media application where users can post and share their coding projects with others. By logging in or signing

Chris Nohilly 4 Dec 8, 2022
This project is a To-do list app which users can store and edit their Todo Tasks. Users can also change the order of their todo

Project This project is about a todo app bundling using webpack Additional description about the project and its features. Built With HTML CSS Javascr

Richmond Adu-Kyere 2 Jun 17, 2022
It is a solo Project and In this repo I try to build a E-Commerce full-stack website with MERN stack technologies. For Practice purpose.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Alok Kumar 5 Aug 3, 2022
MERN stack application which serves as an online map journal where users can mark and rate the places they've been to.

PlaceRate PlaceRate is a MERN stack application which serves as an online map journal where users can mark and rate the places they've been to. You ca

Yuvraj Virdi 0 May 17, 2022
NFTKastle is an NFT marketplace where users can mint their pictures as NFTs, list their NFTs for sale, and buy NFTs from other users.

NFTKastle NFTKastle is an NFT marketplace where users can mint their pictures as NFTs, list their NFTs for sale, and buy NFTs from other users. NFTKas

Paschal 2 Oct 31, 2022
A single-page application that allows users to keep track of their books. Users can add the book details (book title and author) and also, and the books can also be removed. Built with JavaScript, HTML, and CSS

Project Name Awesome book with ES6 Description the project. This is a single page application that allows users to keep track of their books. Users ca

Micheal Oguntayo 4 Oct 13, 2022
Todo List is a simple web-based application that gives users the ability to organize their work and life daily tasks. Built with JavaScript, HTML/CSS.

Javascript Project Todo List Using Javascript to create a simple Todo List project. Populating the todo list and then removing from the list. Built Wi

Ghazanfar Ali 9 Sep 28, 2022