Skip to content

Latest commit

Β 

History

History
127 lines (97 loc) Β· 2.4 KB

File metadata and controls

127 lines (97 loc) Β· 2.4 KB

Full Stack MERN

Dashboard App

A simple full-stack web application built authentication, protected routes, and CRUD operations using React (Vite) for the frontend and Node.js + Express + MongoDB for the backend.

This project was created as a learning exercise to understand how frontend and backend communicate in a real-world setup.


Features

  • User Registration
  • User Login
  • Protected Dashboard (only accessible when logged in)
  • Create, Read, Update, and Delete (CRUD) posts
  • Logout functionality
  • REST API integration

πŸ› οΈ Tech Stack

Frontend

  • React (Vite)
  • React Router
  • Axios
  • Context API (AuthContext)

Backend

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose

πŸ“ Project Structure (Backend)

  • backend/
  • └─ src/
  • β”œβ”€ config/
  • β”‚ β”œβ”€ constants.js
  • β”‚ └─ database.js
  • β”‚
  • β”œβ”€ controllers/
  • β”‚ β”œβ”€ user.controller.js
  • β”‚ └─ post.controller.js
  • β”‚
  • β”œβ”€ models/
  • β”‚ β”œβ”€ user.model.js
  • β”‚ └─ post.model.js
  • β”‚
  • β”œβ”€ routes/
  • β”‚ β”œβ”€ user.route.js
  • β”‚ └─ post.route.js
  • β”‚
  • └─ index.js

πŸ“ Project Structure (Frontend)

  • frontend/
  • └─ src/
  • β”œβ”€ api/ # Axios API calls
  • β”‚ β”œβ”€ postApi.js
  • β”‚ └─ userApi.js
  • β”‚
  • β”œβ”€ Auth/ # Authentication pages
  • β”‚ β”œβ”€ Login.jsx
  • β”‚ └─ Register.jsx
  • β”‚
  • β”œβ”€ components/ # Reusable components
  • β”‚ β”œβ”€ Navbar.jsx
  • β”‚ β”œβ”€ ProtectedRoute.jsx
  • β”‚ └─ StyledWrapper.jsx
  • β”‚
  • β”œβ”€ context/ # Global state (Auth)
  • β”‚ └─ AuthContext.jsx
  • β”‚
  • β”œβ”€ pages/ # Main pages
  • β”‚ └─ Dashboard.jsx
  • β”‚
  • β”œβ”€ App.jsx
  • └─ main.jsx

πŸ“Œ API Endpoints (Backend) Auth

  • POST /api/v1/users/register
  • POST /api/v1/users/login
  • POST /api/v1/users/logout

Posts

  • POST /api/v1/posts/create
  • GET /api/v1/posts/getPosts
  • PATCH /api/v1/posts/update/:id
  • DELETE /api/v1/posts/delete/:id

🧠 What I Learned

  • How React Context works for authentication
  • How protected routes work using React Router
  • How to connect frontend and backend using Axios
  • How REST APIs handle CRUD operations
  • Debugging common frontend/backend issues (CORS, routes, HTTP methods)

πŸ“Έ Screenshots

LogIn alt text

Register alt text

DashBoard alt text

Author: Lester Laroya