AndrewJBateman / mern-stack-data

:clipboard: A Full-stack data display app with React frontend and Express-MongoDB-Node.js backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

⚑ MERN Full Stack Tracker

  • Mongo Express React Node (MERN) full-stack app, integrates React frontend with Node.js backend
  • Code from @EdRohDev with code changes and commenting added
  • Note: to open web links in a new window use: ctrl+click on link

GitHub repo size GitHub pull requests GitHub Repo stars GitHub last commit

πŸ“„ Table of contents

πŸ“š General info

πŸ“š Backend

  • MongoDB Atlas used as the backend database - requires mongodb to be running
  • Mongoose query models used to interact with the database
  • Note: I used 'my ip address' as the whitelist network access in MongoDB.Atlas but this required daily updating when my ip address changed - otherwise with a non-matching ip address the backend simply did not work. Better to use the localhost address to avoid this problem but may be less secure.
  • Node.js routes used with controller functions
  • Nodejs diagram

πŸ“š Frontend

  • React reducers functions that take the current state and an action as arguments, and return a new state result. In other words, (state, action) => newState.

πŸ“· Screenshots

Backend screenshot Frontend screenshot

πŸ“Ά Backend Technologies

πŸ“Ά Frontend Technologies

πŸ’Ύ Setup - Backend

  • Install backend dependencies using npm i
  • Install nodemon globally if you don't already have it
  • Register with MongoDB Atlas, create & configure a database cluster and add connection string to .env file (see .env.example file)
  • Run npm run dev for a dev server
  • Backend data can be viewed using Thunder Client using urls for example: localhost:1337/kpi/kpis

πŸ’Ύ Setup - Frontend

  • Change to /client directory run npm run dev. Frontend will open at http://localhost:5173/

πŸ’» Code Examples

  • Use React hook useMemo to cache results of data mapping
  const revenue = useMemo(() => {
    const revenueData =
      data &&
      data[0].monthlyData.map(({ month, revenue }) => {
        return {
          name: month.substring(0, 3),
          revenue: revenue,
        };
      });
    console.log("revenueData", revenueData);
    return revenueData;
  }, [data]);

πŸ†’ Features

  • graph data stored in cache and derived from database data using map functions

πŸ“‹ Status & To-Do List

  • Status: Working
  • To-Do: add commenting

πŸ‘ Inspiration

πŸ“ License

  • N/A.

βœ‰οΈ Contact

About

:clipboard: A Full-stack data display app with React frontend and Express-MongoDB-Node.js backend


Languages

Language:JavaScript 77.3%Language:TypeScript 22.2%Language:CSS 0.3%Language:HTML 0.2%