A full-stack MERN (MongoDB, Express, React, Node.js) application for managing solar energy products, blogs, and services. Features a modern, animated frontend with a powerful admin panel for content management.
- Landing Page: Modern, animated homepage with hero section and featured content
- Product Shop: Browse, search, and filter solar products with detailed product pages
- Blog System: Read articles about solar energy with categories and search
- Contact Form: Easy-to-use contact form for customer inquiries
- Service Provider: Information about installation and maintenance services
- Authentication: Secure user registration and login with JWT tokens
- Responsive Design: Fully responsive across all devices
- Dashboard: Overview with statistics and activity charts
- Blog Management: Create, edit, delete, and publish blog posts
- Product Management: Full CRUD operations for products with inventory tracking
- Order Management: View and manage customer orders with status updates
- User Management: View users, their activity, and login history
- Contact Management: Review and respond to customer inquiries
- React 18: Modern React with hooks
- React Router v6: Client-side routing
- Framer Motion: Beautiful animations and transitions
- Axios: HTTP client for API calls
- React Toastify: Toast notifications
- React Icons: Icon library
- Recharts: Data visualization for admin dashboard
- Node.js & Express: Server and API
- MongoDB & Mongoose: Database and ODM
- JWT: Authentication tokens
- Bcrypt: Password hashing
- Multer: File upload handling
- Express Validator: Input validation
Before you begin, ensure you have installed:
git clone <repository-url>
cd solar-expert# Navigate to backend directory
cd backend
# Install dependencies
npm install
# Create .env file
cp .env.example .env
# Edit .env file with your configuration
# Required environment variables:
# - PORT=5000
# - MONGODB_URI=mongodb://localhost:27017/solarexpert
# - JWT_SECRET=your_super_secret_jwt_key_change_in_production
# - JWT_EXPIRE=30d# Navigate to frontend directory (from project root)
cd frontend
# Install dependencies
npm installYou need to create an admin user manually in MongoDB:
// Connect to MongoDB and run this in MongoDB shell or Compass:
use solarexpert
db.users.insertOne({
name: "Admin User",
email: "admin@solarexpert.com",
password: "$2a$10$YourHashedPasswordHere", // Use bcrypt to hash "admin123" or your password
role: "admin",
phone: "",
isActive: true,
loginHistory: [],
createdAt: new Date()
})Or use this Node.js script to create admin user:
// create-admin.js in backend folder
const bcrypt = require('bcryptjs');
const mongoose = require('mongoose');
const User = require('./models/User');
mongoose.connect('mongodb://localhost:27017/solarexpert');
async function createAdmin() {
const hashedPassword = await bcrypt.hash('admin123', 10);
const admin = await User.create({
name: 'Admin User',
email: 'admin@solarexpert.com',
password: hashedPassword,
role: 'admin',
phone: '555-0000',
});
console.log('Admin created:', admin.email);
process.exit();
}
createAdmin();Terminal 1 - Backend:
cd backend
npm run dev
# Backend runs on http://localhost:5000Terminal 2 - Frontend:
cd frontend
npm start
# Frontend runs on http://localhost:3000Build Frontend:
cd frontend
npm run buildRun Backend:
cd backend
NODE_ENV=production npm startsolar-expert/
βββ backend/
β βββ models/ # MongoDB schemas
β β βββ User.js
β β βββ Blog.js
β β βββ Product.js
β β βββ Order.js
β β βββ Contact.js
β βββ routes/ # API routes
β β βββ auth.js
β β βββ users.js
β β βββ blogs.js
β β βββ products.js
β β βββ orders.js
β β βββ contact.js
β βββ middleware/ # Custom middleware
β β βββ auth.js
β β βββ upload.js
β βββ uploads/ # Uploaded files
β βββ server.js # Express server
β βββ package.json
β
βββ frontend/
βββ public/
β βββ index.html
β βββ manifest.json
βββ src/
β βββ components/
β β βββ Navbar.js
β β βββ Footer.js
β β βββ ProtectedRoute.js
β β βββ admin/
β β βββ AdminLayout.js
β βββ pages/
β β βββ Home.js
β β βββ About.js
β β βββ Shop.js
β β βββ ProductDetail.js
β β βββ Blog.js
β β βββ BlogDetail.js
β β βββ Contact.js
β β βββ ServiceProvider.js
β β βββ Login.js
β β βββ Register.js
β β βββ admin/
β β βββ Dashboard.js
β β βββ Blogs.js
β β βββ Products.js
β β βββ Orders.js
β β βββ Users.js
β β βββ Contacts.js
β βββ context/
β β βββ AuthContext.js
β βββ App.js
β βββ index.js
β βββ index.css
βββ package.json
POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/auth/me- Get current userPUT /api/auth/updateprofile- Update user profile
GET /api/users- Get all usersGET /api/users/:id- Get user by IDPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user
GET /api/blogs- Get published blogs (Public)GET /api/blogs/all- Get all blogs (Admin)GET /api/blogs/:id- Get single blogPOST /api/blogs- Create blog (Admin)PUT /api/blogs/:id- Update blog (Admin)DELETE /api/blogs/:id- Delete blog (Admin)
GET /api/products- Get active products (Public)GET /api/products/all- Get all products (Admin)GET /api/products/:id- Get single productPOST /api/products- Create product (Admin)PUT /api/products/:id- Update product (Admin)DELETE /api/products/:id- Delete product (Admin)
GET /api/orders- Get all orders (Admin)GET /api/orders/myorders- Get user's ordersGET /api/orders/:id- Get single orderPOST /api/orders- Create orderPUT /api/orders/:id- Update order status (Admin)DELETE /api/orders/:id- Delete order (Admin)
POST /api/contact- Submit contact form (Public)GET /api/contact- Get all contacts (Admin)PUT /api/contact/:id- Update contact status (Admin)DELETE /api/contact/:id- Delete contact (Admin)
- Modern UI: Clean, professional design with gradient accents
- Animations: Smooth Framer Motion animations throughout
- Responsive: Mobile-first design that works on all screen sizes
- Dark Sidebar: Professional admin panel with dark-themed sidebar
- Toast Notifications: User-friendly feedback for all actions
- Loading States: Skeleton screens and spinners for better UX
- JWT-based authentication
- Password hashing with bcrypt
- Protected routes (client and server-side)
- Admin-only endpoints
- Input validation
- CORS configuration
- Secure HTTP headers
- Mobile: < 768px
- Tablet: 768px - 968px
- Desktop: > 968px
- Payment gateway integration (Stripe/PayPal)
- Email notifications
- Product reviews and ratings
- Advanced search and filters
- Wishlist functionality
- Order tracking system
- PDF invoice generation
- Social media sharing
- Multi-language support
- Dark mode toggle
# Make sure MongoDB is running
# Windows:
net start MongoDB
# macOS/Linux:
sudo systemctl start mongod# Change port in backend/.env
PORT=5001
# Or kill the process using the port (example for port 5000)
# Windows:
netstat -ano | findstr :5000
taskkill /PID <PID> /F
# macOS/Linux:
lsof -ti:5000 | xargs kill -9Make sure your backend is running and the frontend proxy is configured correctly in frontend/package.json:
"proxy": "http://localhost:5000"This project is licensed under the MIT License.
Created with β€οΈ for a sustainable future.
- React team for the amazing framework
- MongoDB for the powerful database
- Framer Motion for beautiful animations
- All open-source contributors
For support, email info@solarexpert.com or create an issue in the repository.
Happy Coding! βοΈ