Skip to content

D162005/insta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

Insta Clone

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/

Overview

This repository contains two separate applications:

  • backend/ - Express API, MongoDB models, JWT cookie authentication, and static asset hosting from public/
  • 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.

Features

  • 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

Tech Stack

Backend

  • 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

Frontend

  • React 19
  • Vite
  • React Router 7
  • Axios
  • Sass / SCSS
  • Remix Icon

Project Structure

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/

Prerequisites

  • Node.js 18 or newer
  • npm
  • MongoDB connection string
  • ImageKit account / private key

Environment Variables

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_key

The 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.js
  • frontend/src/features/post/services/post.api.js

Installation

Install dependencies separately for each app:

cd backend
npm install

cd ../frontend
npm install

Running Locally

Backend

The backend listens on port 3000.

cd backend
node server.js

Backend 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

Frontend

The frontend runs on Vite's default dev server at http://localhost:5173.

cd frontend
npm run dev

Frontend Routes

  • / - Home feed
  • /login - Login page
  • /register - Registration page
  • /create-post - Post creation form

API Reference

Auth

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.

Posts

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

Users and Follows

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

Data Model Summary

  • users - userName, email, password, bio, profileImage
  • posts - caption, imgUrl, user
  • likes - postId, userId
  • follows - follower, followee, status

Implementation Notes

  • 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 npm start script; node server.js is the current entry point.
  • Automated tests are not currently defined in either package.

Deployment Notes

  • 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.

License

No license file is currently included in the repository.

About

Full-stack Instagram clone built with React, Vite, Node.js, Express, MongoDB, JWT authentication, and ImageKit-based image uploads.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors