A full-stack Instagram-inspired social media platform built with React.js, Node.js, Express.js, and MongoDB.
- Project Overview
- Tech Stack
- Features
- Project Structure
- Installation & Setup
- Environment Configuration
- API Documentation
- Frontend Components
- Database Schema
- Email Verification System
- Development Workflow
- Production Deployment
- Troubleshooting
F*Meta is a modern social media platform that replicates Instagram's core functionality with features like user authentication, email verification, and a dynamic dashboard feed.
- β User Registration & Login
- β Email Verification System
- β JWT-based Authentication
- β Instagram-like UI/UX with Mobile-First Design
- β Fully Responsive Design (Mobile/Tablet/Desktop)
- β Instagram-Style Profile Layouts
- β Responsive Sidebar Navigation
- β Mobile Bottom Navigation Bar
- β Dashboard with Random Posts
- β User Search & Profile Viewing
- β Follow/Unfollow System
- β Password Show/Hide Toggle
- β Real-time Form Validation
- React.js (18+) - UI Library
- Vite - Build Tool
- Tailwind CSS - Styling
- React Router Dom - Routing
- Lucide React - Icons
- Node.js - Runtime Environment
- Express.js - Web Framework
- MongoDB - Database
- Mongoose - ODM
- JWT - Authentication
- Bcryptjs - Password Hashing
- Nodemailer - Email Service
Social_Media/
βββ backend/
β βββ src/
β β βββ controller/
β β β βββ auth.controller.js
β β βββ models/
β β β βββ user.model.js
β β β βββ post.model.js
β β βββ routes/
β β β βββ auth.routes.js
β β βββ utils/
β β βββ db.js
β βββ .env
β βββ .env.example
β βββ index.js
β βββ package.json
βββ frontend/
βββ src/
β βββ components/
β β βββ ProtectedRoute.jsx
β β βββ ui/
β β βββ button.jsx
β β βββ input.jsx
β βββ config/
β β βββ api.js
β βββ elements/
β β βββ Authorisation/
β β β βββ loginCard.jsx
β β β βββ signupCard.jsx
β β βββ Dashboard/
β β βββ FeedContent.jsx
β β βββ ProfileContent.jsx
β β βββ SearchContent.jsx
β β βββ Sidebar.jsx
β βββ pages/
β β βββ authorisation.jsx
β β βββ dashboard.jsx
β β βββ emailVerification.jsx
β βββ utils/
β β βββ auth.js
β βββ App.jsx
β βββ App.css
β βββ main.jsx
βββ .env
βββ index.html
βββ package.json
βββ vite.config.js
- Node.js (16+ recommended)
- MongoDB Atlas account or local MongoDB
- Gmail account for email service
git clone <your-repository-url>
cd Social_Mediacd backend
npm installcd frontend
npm install# Server Configuration
NODE_ENV=development
PORT=8000
# Database
dbURL=your-mongodb-atlas-production-url
# JWT Configuration
JWT_SECRET=your-super-secure-jwt-secret-key
# Frontend URL
FRONTEND_URL=http://localhost:5173
# Email Configuration
Email=your-production-email@gmail.com
EmailPassword=your-gmail-app-passwordVITE_API_URL=http://localhost:8000NODE_ENV=production
PORT=8000
dbURL=your-mongodb-atlas-production-url
JWT_SECRET=your-super-secure-production-jwt-secret
FRONTEND_URL=https://yourdomain.com
Email=your-production-email@gmail.com
EmailPassword=your-gmail-app-passwordVITE_API_URL=https://api.yourdomain.com- Development:
http://localhost:8000/api - Production:
https://api.yourdomain.com/api
POST /auth/register
Content-Type: application/json
{
"name": "John Doe",
"username": "johndoe123",
"email": "john@example.com",
"password": "password123"
}Response:
{
"success": true,
"message": "Registration successful! Please check your email to verify your account.",
"requiresVerification": true
}GET /auth/verify-email?token=verification_tokenResponse:
{
"success": true,
"message": "Email verified successfully!"
}POST /auth/login
Content-Type: application/json
{
"emailOrPhoneOrUsername": "johndoe123",
"password": "password123"
}Response:
{
"success": true,
"message": "Login successful",
"user": {
"_id": "user_id",
"name": "John Doe",
"username": "johndoe123",
"email": "john@example.com",
"isEmailVerified": true
},
"token": "jwt_token_here"
}GET /auth/profile
Authorization: Bearer <jwt_token>POST /auth/logout
Authorization: Bearer <jwt_token>POST /auth/refresh
Authorization: Bearer <jwt_token>-
LoginCard (
/src/elements/Authorisation/loginCard.jsx)- Email/Username/Phone login
- Password show/hide toggle
- Form validation
- API integration
-
SignupCard (
/src/elements/Authorisation/signupCard.jsx)- User registration form
- Email verification flow
- Success/error messaging
- Instagram-style UI
-
Sidebar (
/src/elements/Dashboard/Sidebar.jsx)- Responsive navigation system
- Desktop sidebar (lg: breakpoint)
- Mobile bottom navigation bar
- Instagram-style navigation icons
- User profile integration
-
FeedContent (
/src/elements/Dashboard/FeedContent.jsx)- Instagram-like post feed
- Random post generation
- Responsive grid layout
- Interactive post elements
-
ProfileContent (
/src/elements/Dashboard/ProfileContent.jsx)- Instagram-style profile layout
- Mobile-first responsive design
- Desktop/mobile layout variations
- Profile picture, stats, and bio sections
- Action buttons (Edit profile/Follow/Message)
- Posts grid with hover effects
-
SearchContent (
/src/elements/Dashboard/SearchContent.jsx)- User search functionality
- Recent searches with localStorage
- Profile viewing with follow/unfollow
- Responsive search results
- Instagram-style user cards
-
Authorisation (
/src/pages/authorisation.jsx)- Toggle between login/signup
- Responsive design
- Centralized authentication
-
Dashboard (
/src/pages/dashboard.jsx)- Main app interface
- Responsive layout with sidebar integration
- Dynamic content switching (Feed/Search/Profile)
- Protected route implementation
-
EmailVerification (
/src/pages/emailVerification.jsx)- Token-based verification
- Success/error handling
- Automatic redirection
-
Button (
/src/components/ui/button.jsx)- Reusable button component
- Multiple variants and sizes
- Consistent styling across app
-
Input (
/src/components/ui/input.jsx)- Form input component
- Validation states
- Instagram-style design
- Profile Layout: Horizontal layout with profile picture left, stats right
- Navigation: Bottom navigation bar with 5 main icons
- Buttons: Compact sizing with touch-friendly targets
- Typography: Scaled text sizes for mobile readability
- Spacing: Optimized padding and margins for small screens
- Profile Layout: Traditional side-by-side layout
- Navigation: Left sidebar with full labels
- Buttons: Larger desktop-style buttons
- Typography: Larger text for desktop viewing
- Spacing: Generous padding and spacing
- Base: Mobile-first (320px+)
- sm: Large mobile (640px+)
- md: Tablet (768px+)
- lg: Desktop transformation (1024px+)
- xl: Large desktop (1280px+)
- Framework: Tailwind CSS with custom responsive utilities
- Theme: Dark theme (Instagram-inspired)
- Design System: Mobile-first with progressive enhancement
- Icons: Lucide React for consistent iconography
- Layout: CSS Grid and Flexbox for responsive layouts
{
name: String (required),
username: String (required, unique),
email: String (unique, sparse),
phone: String (unique, sparse),
password: String (required),
bio: String,
profilePicture: String,
isEmailVerified: Boolean (default: false),
emailVerificationToken: String,
emailVerificationExpires: Date,
followers: [ObjectId] (ref: User),
following: [ObjectId] (ref: User),
posts: [ObjectId] (ref: Post),
createdAt: Date,
updatedAt: Date
}{
content: String (required),
author: ObjectId (ref: User, required),
images: [String],
likes: [ObjectId] (ref: User),
comments: [{
user: ObjectId (ref: User),
text: String,
createdAt: Date
}],
location: String,
hashtags: [String],
createdAt: Date,
updatedAt: Date
}- User registers with email
- Backend generates verification token (24-hour expiry)
- Email sent with verification link
- User clicks link β Frontend verification page
- Token validated β User marked as verified
- Redirect to login page
- Service: Gmail SMTP
- Security: App Password required
- Template: HTML email with F*Meta branding
- Enable 2-Factor Authentication
- Generate App Password
- Use App Password in EmailPassword env variable
cd backend
node index.js # Start backend servercd frontend
npm run dev # Using Vite dev server- Frontend: http://localhost:5173
- Backend: http://localhost:8000
- API Base: http://localhost:8000/api
- Register new user at
/auth/register - Check email for verification link
- Click verification link
- Login with verified credentials
- Access dashboard
# Build for production
npm run build
# Deploy to Vercel
vercel --prod# Set environment variables
# Deploy using platform-specific methodFrontend: https://yourdomain.com
Backend: https://api.yourdomain.com
- Update FRONTEND_URL in backend .env
- Update API_BASE_URL in frontend config
- Set secure JWT_SECRET
- Configure CORS for production domain
- Use MongoDB Atlas
- Set NODE_ENV=production
- Test email verification flow
- Verify all API endpoints
- Test complete user journey
const corsOptions = {
origin: process.env.NODE_ENV === 'production'
? ['https://yourdomain.com']
: ['http://localhost:5173'],
credentials: true,
methods: ['GET', 'POST', 'PUT', 'DELETE'],
allowedHeaders: ['Content-Type', 'Authorization']
};- Check Gmail App Password
- Verify email environment variables
- Check SMTP configuration
- Review console logs for email errors
- Update corsOptions for your domain
- Check FRONTEND_URL environment variable
- Verify API_BASE_URL in frontend config
- Check JWT_SECRET consistency
- Verify token expiration
- Check Authorization header format
- Verify MongoDB Atlas connection string
- Check IP whitelist in Atlas
- Confirm database credentials
- Frontend runs on port 5173
- Backend runs on port 8000
- Ensure no port conflicts
# Check environment variables
node -e "console.log(process.env)"
# Test database connection
node -e "require('./src/utils/db.js').connectDb()"
# Test email configuration
node -e "console.log(process.env.Email, process.env.EmailPassword)"- Use ES6+ syntax
- Implement proper error handling
- Add console logging for debugging
- Follow RESTful API conventions
- Use async/await for asynchronous operations
- Never commit .env files
- Use secure JWT secrets
- Implement proper CORS
- Validate all inputs
- Hash passwords with bcrypt
- Set token expiration times
- Implement pagination for posts
- Use MongoDB indexes for faster queries
- Optimize bundle size with code splitting
- Implement caching strategies
- Use CDN for static assets
- Lazy load images and components
- Implement virtual scrolling for large lists
- Optimize responsive images with srcset
- Use service workers for offline functionality
-
Authentication System
- User registration and login
- Email verification system
- JWT authentication with refresh tokens
- Password hashing with bcrypt
- Protected routes implementation
-
User Interface
- Instagram-style UI components
- Fully responsive design (mobile/tablet/desktop)
- Mobile-first approach with progressive enhancement
- Dark theme with Instagram-inspired styling
-
Navigation System
- Responsive sidebar for desktop
- Mobile bottom navigation bar
- Dynamic content switching
- Instagram-style navigation icons
-
Profile System
- User profile viewing and editing
- Instagram-like profile layouts
- Responsive profile sections
- Profile picture, bio, and stats display
-
Search & Discovery
- User search functionality
- Recent searches with localStorage
- Profile viewing from search results
- Follow/unfollow system integration
-
Dashboard Features
- Feed with random posts
- Interactive post grid
- Responsive layout system
- User authentication checks
-
Technical Features
- Error and success messaging
- Form validation
- API integration
- Centralized configuration
- Email verification flow
-
Post Management
- Post creation and editing
- Image upload functionality
- Post deletion and archiving
- Story feature implementation
-
Social Features
- Like and comment system
- Real-time notifications
- Direct messaging
- Activity feed
-
Enhanced Features
- Advanced search filters
- Hashtag system
- Location tagging
- User mentions
-
Performance & Optimization
- Image optimization
- Lazy loading
- Caching strategies
- Performance monitoring
Project: F*Meta Social Media Platform
Version: 1.0.0