Skip to content

vineet1cg/MERN-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WhisperWall - MERN Social Feed Application

A modern social feed application built with the MERN stack, featuring a unique neobrutalism design aesthetic. Users can register, login, and create posts with images that are hosted via ImageKit.

MERN Stack React Node.js MongoDB


Tech Stack

Frontend

  • React 19 - UI library
  • Vite - Build tool and dev server
  • Tailwind CSS - Styling framework
  • React Router DOM - Client-side routing
  • Axios - HTTP client
  • Lucide React - Icon library

Backend

  • Node.js - JavaScript runtime
  • Express.js - Web framework
  • MongoDB - NoSQL database
  • Mongoose - MongoDB ODM
  • JSON Web Token (JWT) - Authentication
  • Bcryptjs - Password hashing
  • Multer - File upload middleware
  • ImageKit - Image hosting and CDN

File Structure

MERN PROJECT/
β”‚
β”œβ”€β”€ πŸ“‚ BACKEND/                    # Server-side application
β”‚   β”œβ”€β”€ package.json               # Backend dependencies
β”‚   β”œβ”€β”€ server.js                  # Application entry point
β”‚   β”‚
β”‚   └── πŸ“‚ src/
β”‚       β”œβ”€β”€ app.js                 # Express configuration & routes
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ database/
β”‚       β”‚   └── db.js              # MongoDB connection setup
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ middleware/
β”‚       β”‚   └── auth.middleware.js # JWT authentication middleware
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ models/
β”‚       β”‚   β”œβ”€β”€ user.model.js      # User schema (username, email, password)
β”‚       β”‚   └── post.model.js      # Post schema (image, caption)
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ routes/
β”‚       β”‚   β”œβ”€β”€ auth.routes.js     # /api/auth endpoints
β”‚       β”‚   └── post.routes.js     # /api/posts endpoints
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ controllers/
β”‚       β”‚   └── auth.controller.js # Auth logic (register, login)
β”‚       β”‚
β”‚       └── πŸ“‚ services/
β”‚           └── storage.service.js  # ImageKit image upload service
β”‚
β”œβ”€β”€ πŸ“‚ FRONTEND/                   # Client-side application
β”‚   β”œβ”€β”€ package.json               # Frontend dependencies
β”‚   β”œβ”€β”€ vite.config.js             # Vite configuration
β”‚   β”œβ”€β”€ tailwind.config.js         # Tailwind CSS configuration
β”‚   β”œβ”€β”€ postcss.config.js          # PostCSS configuration
β”‚   β”‚
β”‚   └── πŸ“‚ src/
β”‚       β”œβ”€β”€ main.jsx               # React app entry point
β”‚       β”œβ”€β”€ App.jsx                # Main app component with routing
β”‚       β”œβ”€β”€ index.css              # Global styles
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ pages/
β”‚       β”‚   β”œβ”€β”€ Home.jsx           # Main feed displaying all posts
β”‚       β”‚   β”œβ”€β”€ Login.jsx          # User login page
β”‚       β”‚   β”œβ”€β”€ CreatePost.jsx     # Page to create new post
β”‚       β”‚   └── AdminSetup.jsx     # Initial admin account setup
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ components/
β”‚       β”‚   β”œβ”€β”€ Navbar.jsx         # Navigation bar with links
β”‚       β”‚   β”œβ”€β”€ PostCard.jsx       # Individual post display component
β”‚       β”‚   β”œβ”€β”€ ThemeSwitcher.jsx  # Dark/light mode toggle
β”‚       β”‚   └── ProtectedRoute.jsx # Route guard for auth
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ context/
β”‚       β”‚   └── AuthContext.jsx    # Authentication state management
β”‚       β”‚
β”‚       β”œβ”€β”€ πŸ“‚ theme/
β”‚       β”‚   └── ThemeContext.jsx  # Theme state management
β”‚       β”‚
β”‚       └── πŸ“‚ services/
β”‚           └── api.js             # Axios API client with interceptors
β”‚
β”œβ”€β”€ netlify.toml                   # Netlify deployment configuration
β”œβ”€β”€ overview.md                    # Project documentation & bug reports
└── README.md                      # This file

Project Architecture Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         FRONTEND (React)                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚   Home   β”‚  β”‚   Login  β”‚  β”‚CreatePostβ”‚  β”‚AdminSetupβ”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜        β”‚
β”‚       β”‚             β”‚             β”‚             β”‚               β”‚
β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
β”‚                           β”‚                                      β”‚
β”‚                    β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”                               β”‚
β”‚                    β”‚  App.jsx    β”‚  (React Router)              β”‚
β”‚                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜                               β”‚
β”‚                           β”‚                                      β”‚
β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                   β”‚
β”‚         β”‚                 β”‚                 β”‚                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚ AuthContext β”‚  β”‚ThemeContext   β”‚  β”‚  api.js     β”‚           β”‚
β”‚  β”‚ (User Auth) β”‚  β”‚ (Dark/Light)  β”‚  β”‚  (Axios)    β”‚           β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                                              β”‚ HTTP Requests
                                              β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         BACKEND (Express)    β”‚                   β”‚
β”‚                                              β–Ό                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚                      app.js                                β”‚ β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚ β”‚
β”‚  β”‚  β”‚ CORS Config β”‚  β”‚ Auth Routes β”‚  β”‚  Post Routes   β”‚   β”‚ β”‚
β”‚  β”‚  β”‚             β”‚  β”‚ /api/auth   β”‚  β”‚  /api/posts   β”‚   β”‚ β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚ β”‚
β”‚  β”‚                          β”‚                  β”‚             β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                             β”‚                  β”‚               β”‚
β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚              β”‚   auth.controller.js β”‚  β”‚  post.routes.js β”‚     β”‚
β”‚              β”‚  (register, login)   β”‚  β”‚ (create, fetch)β”‚     β”‚
β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚                          β”‚                      β”‚               β”‚
β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚         β”‚                β”‚                     β”‚            β”‚ β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚ β”‚
β”‚  β”‚user.model.jsβ”‚  β”‚post.model.jsβ”‚  β”‚storage.service.js  β”‚   β”‚ β”‚
β”‚  β”‚ (Mongoose)  β”‚  β”‚ (Mongoose)  β”‚  β”‚    (ImageKit)       β”‚   β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚ β”‚
β”‚         β”‚                β”‚                     β”‚            β”‚ β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚ β”‚
β”‚                          β”‚                                  β”‚ β”‚
β”‚                          β–Ό                                  β”‚ β”‚
β”‚                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                            β”‚ β”‚
β”‚                   β”‚ MongoDB  β”‚                            β”‚ β”‚
β”‚                   β”‚          β”‚                            β”‚ β”‚
β”‚                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                            β”‚ β”‚
β”‚                                                             β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
                                                                β”‚
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                      β”‚
                          β”‚   ImageKit   β”‚ ◄── Image CDN       β”‚
                          β”‚   (Images)   β”‚                      β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      β”‚

Features

  • User Authentication: Register and login with JWT-based authentication
  • Image Posts: Create posts with images and captions
  • Image Hosting: Images are uploaded to ImageKit for CDN delivery
  • Protected Routes: Authenticated access to create posts
  • Dark/Light Theme: Toggle between themes with theme persistence
  • Responsive Design: Works on mobile and desktop
  • Neobrutalism UI: Unique bold design aesthetic

API Endpoints

Authentication

Method Endpoint Description
POST /api/auth/register Register a new user
POST /api/auth/login Login user

Posts (Protected)

Method Endpoint Description
GET /api/posts Get all posts
POST /api/posts/create-post Create a new post with image

Getting Started

Prerequisites

  • Node.js (v18+)
  • MongoDB (local or Atlas)
  • ImageKit account (free tier)

Environment Variables

Create a .env file in the BACKEND directory:

# Backend .env
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
IMAGE_KIT_PUBLIC=your_imagekit_public_key
IMAGE_KIT_PRIVATE=your_imagekit_private_key
IMAGE_KIT_ENDPOINT=your_imagekit_endpoint_url
FRONTEND_URL=http://localhost:5173
PORT=3000

Create a .env file in the FRONTEND directory:

# Frontend .env
VITE_BACKEND_URL=http://localhost:3000

Installation & Setup

1. Clone the Repository

git clone <repository-url>
cd "MERN PROJECT"

2. Install Backend Dependencies

cd BACKEND
npm install

3. Install Frontend Dependencies

cd ../FRONTEND
npm install

Running the Application

Start the Backend Server

cd BACKEND
npm start
# or for development with nodemon
npx nodemon server.js

The backend will run on http://localhost:3000

Start the Frontend Development Server

cd FRONTEND
npm run dev

The frontend will run on http://localhost:5173


Building for Production

Frontend Build

cd FRONTEND
npm run build

The built files will be in the dist folder.


Deployment

Backend

Deploy to platforms like:

  • Render
  • Railway
  • Fly.io
  • Heroku

Frontend

Deploy to platforms like:

  • Netlify (configured with netlify.toml)
  • Vercel

License

ISC License

About

Private Media Sharing Gallery Application With Role Based Authentication, Tech Stack : MERN

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors