Instagram-style full-stack social application with a Node.js/Express backend, MongoDB data layer, ImageKit image uploads, and a React/Vite frontend.
Live-Link:https://insta-3w5h.onrender.com/
This repository contains two separate applications:
backend/- Express API, MongoDB models, JWT cookie authentication, and static asset hosting frompublic/frontend/- React 19 application built with Vite, React Router, Axios, and Sass
The application supports user registration and login, authenticated feeds, post creation with image upload, likes, and follow/unfollow actions.
- User registration and login with password hashing
- JWT-based authentication stored in an HTTP cookie
- Auth-protected profile lookup via
get-me - Create posts with image uploads through ImageKit
- View all posts and the current user's posts
- Like and unlike posts
- Follow and unfollow users
- Follow request accept/reject endpoints in the API
- Node.js
- Express 5
- MongoDB with Mongoose
- JWT authentication
- bcryptjs for password hashing
- cookie-parser and CORS
- Multer for multipart form uploads
- ImageKit Node SDK for image storage
- React 19
- Vite
- React Router 7
- Axios
- Sass / SCSS
- Remix Icon
backend/
server.js
src/
app.js
config/database.js
controllers/
middlewares/
models/
routes/
public/
frontend/
src/
App.jsx
AppRoutes.jsx
features/
auth/
home/
post/
common/
- Node.js 18 or newer
- npm
- MongoDB connection string
- ImageKit account / private key
Create a .env file inside backend/ with the following values:
MONGO_URL=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
IMAGEKIT_PRIVATE_KEY=your_imagekit_private_keyThe current frontend code is configured to call the deployed API at https://insta-3w5h.onrender.com/api. If you run the backend locally, update the Axios baseURL values in:
frontend/src/features/auth/services/auth.api.jsfrontend/src/features/post/services/post.api.js
Install dependencies separately for each app:
cd backend
npm install
cd ../frontend
npm installThe backend listens on port 3000.
cd backend
node server.jsBackend behavior:
- Connects to MongoDB through
src/config/database.js - Enables JSON parsing, cookie parsing, and CORS with credentials
- Serves static files from
backend/public - Mounts API routes under
/api/auth,/api/post, and/api/user
The frontend runs on Vite's default dev server at http://localhost:5173.
cd frontend
npm run dev/- Home feed/login- Login page/register- Registration page/create-post- Post creation form
| Method | Path | Description |
|---|---|---|
POST |
/api/auth/register |
Register a new user |
POST |
/api/auth/login |
Log in an existing user |
GET |
/api/auth/get-me |
Return the authenticated user's profile |
Register and login expect JSON bodies containing userName, email, and password as applicable. Successful authentication sets a token cookie.
| Method | Path | Description |
|---|---|---|
POST |
/api/post |
Create a post with multipart form data (caption, instaFile) |
GET |
/api/post |
Get the authenticated user's posts |
GET |
/api/post/details/:postId |
Get a single post owned by the authenticated user |
GET |
/api/post/all-posts |
Get the full feed |
POST |
/api/post/like/:postId |
Like a post |
DELETE |
/api/post/unlike/:postId |
Unlike a post |
| Method | Path | Description |
|---|---|---|
POST |
/api/user/follow/:userId |
Follow a user |
DELETE |
/api/user/follow/:userId |
Unfollow a user |
POST |
/api/user/follow/request/accept/:userId |
Accept a follow request |
DELETE |
/api/user/follow/request/reject/:userId |
Reject a follow request |
users-userName,email,password,bio,profileImageposts-caption,imgUrl,userlikes-postId,userIdfollows-follower,followee,status
- Authentication uses JWT stored in a cookie and verified by middleware on protected routes.
- Images are uploaded to ImageKit before a post record is saved.
- The frontend keeps separate context providers for auth and post state.
- The current codebase does not define a backend
npmstart script;node server.jsis the current entry point. - Automated tests are not currently defined in either package.
- The frontend service layer is currently pointing to a deployed API URL on Render.
- If you deploy the backend elsewhere, update the frontend Axios base URLs accordingly.
- The backend is already configured with CORS credentials support for
http://localhost:5173.
No license file is currently included in the repository.