A complete full-stack web application for current affairs and competitive exam preparation with Daily Current Affairs, MCQs, User Authentication, Admin Panel, and Google AdSense integration.
- β Responsive React-based UI
- β Daily Current Affairs with filtering & search
- β MCQ Practice with instant results
- β User Authentication (Register/Login)
- β User Dashboard with saved articles
- β Category-wise content organization
- β Exam-specific filtering (UPSC, SSC, Banking, etc.)
- β Newsletter subscription
- β SEO optimized pages
- β Google AdSense ready
- β RESTful API with Express.js
- β MongoDB database with Mongoose
- β JWT authentication
- β Role-based access control (User/Author/Admin)
- β Article management system
- β MCQ management with statistics
- β User profile management
- β Newsletter system
- β Admin dashboard
- β Dashboard with statistics
- β Article creation & management
- β MCQ creation & management
- β User management
- β Content moderation
- Node.js (v14 or higher)
- MongoDB (local or Atlas)
- npm or yarn
git clone https://github.com/yourusername/nmai-website.git
cd nmai-websitecd backend
# Install dependencies
npm install
# Create .env file
cp .env.example .env
# Edit .env with your configuration
nano .envRequired Environment Variables (.env):
PORT=5000
NODE_ENV=development
MONGODB_URI=mongodb://localhost:27017/nmai-current-affairs
JWT_SECRET=your-super-secret-jwt-key-change-this
JWT_EXPIRE=7d
FRONTEND_URL=http://localhost:3000
ADMIN_EMAIL=admin@nmai.in
ADMIN_PASSWORD=Admin@123For MongoDB Atlas (Production):
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/nmaicd ../frontend
# Install dependencies
npm installTerminal 1 - Backend:
cd backend
npm run dev
# Server runs on http://localhost:5000Terminal 2 - Frontend:
cd frontend
npm start
# App opens on http://localhost:3000Backend:
cd backend
npm startFrontend:
cd frontend
npm run build
# Serve the build folder with a static serverTo populate the database with sample data:
cd backend
npm run seedThis creates:
- Sample articles
- Sample MCQs
- Admin user
- Test users
Email: admin@nmai.in
Password: Admin@123
nmai-website/
βββ backend/
β βββ models/
β β βββ Article.js
β β βββ MCQ.js
β β βββ User.js
β βββ routes/
β β βββ articles.js
β β βββ mcqs.js
β β βββ auth.js
β β βββ users.js
β β βββ newsletter.js
β β βββ admin.js
β βββ middleware/
β β βββ auth.js
β βββ .env.example
β βββ package.json
β βββ server.js
βββ frontend/
β βββ public/
β βββ src/
β β βββ components/
β β βββ pages/
β β βββ services/
β β βββ utils/
β β βββ App.js
β β βββ index.js
β βββ package.json
βββ README.md
- POST
/api/auth/register- Register new user - POST
/api/auth/login- Login user - GET
/api/auth/me- Get current user - PUT
/api/auth/update-profile- Update profile - PUT
/api/auth/change-password- Change password - POST
/api/auth/forgot-password- Request password reset - POST
/api/auth/reset-password/:token- Reset password
- GET
/api/articles- Get all articles (with filters) - GET
/api/articles/latest- Get latest articles - GET
/api/articles/trending- Get trending articles - GET
/api/articles/:slug- Get single article - GET
/api/articles/category/:category- Get by category - POST
/api/articles- Create article (Admin/Author) - PUT
/api/articles/:id- Update article (Admin/Author) - DELETE
/api/articles/:id- Delete article (Admin)
- GET
/api/mcqs- Get all MCQs (with filters) - GET
/api/mcqs/daily-quiz- Get random 10 MCQs - POST
/api/mcqs/submit- Submit quiz answers - GET
/api/mcqs/categories- Get categories - GET
/api/mcqs/stats- Get statistics - POST
/api/mcqs- Create MCQ (Admin/Author) - PUT
/api/mcqs/:id- Update MCQ (Admin) - DELETE
/api/mcqs/:id- Delete MCQ (Admin)
- POST
/api/users/save-article/:id- Save article - DELETE
/api/users/save-article/:id- Unsave article - GET
/api/users/saved-articles- Get saved articles - GET
/api/users/quiz-history- Get quiz history
- POST
/api/newsletter/subscribe- Subscribe - POST
/api/newsletter/unsubscribe- Unsubscribe
- GET
/api/admin/dashboard-stats- Dashboard statistics - GET
/api/admin/users- Get all users - PUT
/api/admin/users/:id- Update user - DELETE
/api/admin/users/:id- Delete user
Navbar.js- Navigation headerFooter.js- Footer with legal linksArticleCard.js- Article preview cardMCQCard.js- MCQ question cardCategoryFilter.js- Filter by categorySearchBar.js- Search functionality
Home.js- Homepage with latest articlesCurrentAffairs.js- Daily current affairs listArticleDetail.js- Single article viewMCQPractice.js- MCQ practice pageDailyQuiz.js- Daily quiz interfaceLogin.js- Login pageRegister.js- Registration pageProfile.js- User profile/dashboardAdminDashboard.js- Admin panel- Legal pages (already created)
The application uses:
- Modern CSS3 with Flexbox/Grid
- Responsive design (mobile-first)
- Color scheme inspired by GKToday/DrishtiIAS
- Google Fonts (Inter/Roboto)
- Password hashing with bcrypt
- JWT token authentication
- HTTP-only cookies (optional)
- Helmet.js security headers
- Rate limiting
- Input validation
- XSS protection
- CORS configuration
- Mobile-first approach
- Breakpoints:
- Mobile: < 768px
- Tablet: 768px - 1024px
- Desktop: > 1024px
- Get AdSense approval
- Add AdSense script to
public/index.html:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-YOUR-ID"
crossorigin="anonymous"></script>- Add ad units in components:
<ins className="adsbygoogle"
style={{display:'block'}}
data-ad-client="ca-pub-YOUR-ID"
data-ad-slot="YOUR-SLOT-ID"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>- Create account on deployment platform
- Connect GitHub repository
- Add environment variables
- Deploy
- Build production version
npm run build- Deploy
buildfolder to Netlify/Vercel - Configure environment variables
- Set up custom domain
- Create MongoDB Atlas account
- Create cluster
- Create database user
- Get connection string
- Update MONGODB_URI in .env
- User accounts
- Authentication data
- Subscriptions
- Saved articles
- Quiz history
- Current affairs content
- Metadata
- Categories
- Exam relevance
- View counts
- Questions
- Options
- Correct answers
- Explanations
- Statistics
- Detailed error messages
- Hot reloading
- CORS:
http://localhost:3000 - Debug mode ON
- Minified builds
- Error tracking (Sentry)
- CORS: Your domain
- Debug mode OFF
- HTTPS enforcement
Add to public/index.html:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-YOUR-ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-YOUR-ID');
</script># Check if MongoDB is running
sudo systemctl status mongod
# Start MongoDB
sudo systemctl start mongod# Kill process on port 5000
npx kill-port 5000
# Or use different port in .env
PORT=5001- Check FRONTEND_URL in backend .env
- Verify CORS configuration in server.js
For issues or questions:
- Email: support@nmai.in
- GitHub Issues: [Create Issue]
MIT License - feel free to use for your own projects!
Inspired by:
- GKToday (https://www.gktoday.in)
- DrishtiIAS (https://www.drishtiias.com)
If this project helps you, please give it a star on GitHub!
Built with β€οΈ for Competitive Exam Aspirants