A modern, feature-rich blogging platform inspired by Medium, built with Next.js, MongoDB, and React.
- Rich text editor with image uploads, formatting, and embedding
- Draft, scheduled, and published post states
- Categories and tags for content organization
- SEO optimization tools
- Media library for asset management
- Responsive design for all devices
- Dark/light mode support
- Reading progress tracking
- Estimated reading time
- Social sharing capabilities
- Bookmarking functionality
- Follow authors feature
- Personalized content recommendations
- Premium content with subscription model
- M-Pesa integration for mobile payments
- Sponsored content management
- Ad integration (Google Ads)
- Micropayments for individual articles
- Comprehensive dashboard for authors
- Reading statistics and user behavior
- Traffic sources and demographics
- Content performance metrics
- Engagement analytics (likes, comments, shares)
- AI-assisted content creation
- Automated content suggestions
- Smart categorization of articles
- Personalized recommendation engine
- Next.js 14 (App Router)
- React 18
- Tailwind CSS
- Shadcn UI Components
- TypeScript
- Node.js
- Express.js
- MongoDB
- JWT Authentication
- M-Pesa Payment Gateway
- Google Analytics
- Social Media APIs
- AI Content Generation
- Node.js 18.x or higher
- MongoDB 5.x or higher
- npm or yarn
Create a .env file in the server directory with the following variables:
``` PORT=5000 CLIENT_URL=http://localhost:3000 MONGODB_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret NEXT_PUBLIC_SITE_URL=http://localhost:3000 NEXT_PUBLIC_API_URL=http://localhost:5000/api
MPESA_CONSUMER_KEY=your_mpesa_consumer_key MPESA_CONSUMER_SECRET=your_mpesa_consumer_secret MPESA_PASSKEY=your_mpesa_passkey MPESA_SHORTCODE=your_mpesa_shortcode MPESA_CALLBACK_URL=your_mpesa_callback_url ```
-
Clone the repository ```bash git clone https://github.com/yourusername/apple-blog-platform.git cd apple-blog-platform ```
-
Install dependencies for both client and server ```bash
npm install
cd server npm install ```
- Run the development server ```bash
cd server npm run dev
cd .. npm run dev ```
- Open http://localhost:3000 in your browser to see the application.
- Make sure MongoDB is running
- Seed the database with initial data (optional) ```bash cd server npm run seed ```
``` apple-blog-platform/ ├── app/ # Next.js app directory │ ├── (auth)/ # Authentication routes │ ├── (dashboard)/ # Dashboard routes │ ├── (main)/ # Main public routes │ └── api/ # API routes ├── components/ # React components │ ├── dashboard/ # Dashboard components │ ├── editor/ # Rich text editor components │ ├── payment/ # Payment components │ ├── subscription/ # Subscription components │ └── ui/ # UI components (shadcn) ├── contexts/ # React contexts ├── hooks/ # Custom React hooks ├── lib/ # Utility functions and services ├── public/ # Static assets ├── server/ # Backend server │ ├── controllers/ # API controllers │ ├── middleware/ # Express middleware │ ├── models/ # MongoDB models │ ├── routes/ # API routes │ ├── services/ # Business logic services │ └── utils/ # Utility functions └── styles/ # Global styles ```
The API follows RESTful principles and is organized around resources. All requests and responses are in JSON format.
POST /api/auth/register- Register a new userPOST /api/auth/login- Login and get JWT tokenGET /api/auth/me- Get current user info
GET /api/posts- Get all postsGET /api/posts/:id- Get a specific postPOST /api/posts- Create a new postPUT /api/posts/:id- Update a postDELETE /api/posts/:id- Delete a post
GET /api/categories- Get all categoriesPOST /api/categories- Create a new categoryGET /api/tags- Get all tagsPOST /api/tags- Create a new tag
GET /api/users- Get all users (admin only)PUT /api/users/profile- Update user profilePUT /api/users/password- Change password
POST /api/follow/:userId- Follow a userDELETE /api/follow/:userId- Unfollow a userGET /api/follow/:userId/followers- Get user's followersGET /api/follow/:userId/following- Get users followed by userGET /api/follow/:userId/status- Check follow status
GET /api/recommendations/personalized- Get personalized recommendationsGET /api/recommendations/trending- Get trending postsGET /api/recommendations/similar/:postId- Get similar posts
GET /api/analytics/dashboard- Get dashboard statsGET /api/analytics/posts/:id- Get post analyticsGET /api/analytics/reading-stats- Get reading statisticsGET /api/analytics/reading-history- Get reading history
POST /api/mpesa/stkpush- Initiate M-Pesa paymentGET /api/mpesa/status/:transactionId- Check payment statusPOST /api/mpesa/callback- M-Pesa callback URL
- Push your code to GitHub
- Connect your GitHub repository to Vercel
- Configure environment variables in Vercel dashboard
- Deploy
- Set up a MongoDB Atlas cluster
- Deploy the server to a service like Heroku, Digital Ocean, or AWS
- Configure environment variables
- Set up proper CORS configuration
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Let's update the server's index.js to include our new routes: