Skip to content

Modern article publishing app built with React, Node.js & MongoDB - write, share, and discover.

Notifications You must be signed in to change notification settings

Sahilll94/Article-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Article App

A modern, full-stack article publishing platform built with React, Node.js, and MongoDB. Share your thoughts, connect with writers, and discover inspiring content.

✨ Features

πŸ“ Content Management

  • Rich markdown editor with live preview
  • Article drafts and publishing workflow
  • Featured image uploads with Cloudinary integration
  • SEO-optimized article pages with meta tags
  • Article preview functionality before publishing
  • Tag and category organization

πŸ‘₯ Social Features

  • User profiles with bio and social links
  • Follow/unfollow system
  • View followers and following lists
  • User discovery through profiles
  • Google OAuth authentication
  • Traditional email/password auth

🎨 User Experience

  • Responsive design for all devices
  • Modern, minimalist UI
  • Dark/light theme support
  • Real-time connection status
  • Error boundaries and graceful error handling
  • Loading states and skeleton screens

πŸ”§ Technical Features

  • JWT authentication with secure token management
  • File upload with Cloudinary integration
  • MongoDB with Mongoose ODM
  • RESTful API architecture
  • Rate limiting and security middleware
  • Environment-based configuration

πŸš€ Quick Start

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB (local or Atlas)
  • Cloudinary account (for image uploads)
  • Firebase project (for Google OAuth)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/article-app.git
    cd article-app
  2. Backend Setup

    cd Backend
    npm install
  3. Frontend Setup

    cd ../Frontend
    npm install

Environment Configuration

Backend Environment (.env)

# Database
MONGODB_URI=mongodb://localhost:27017/article-app

# JWT
JWT_SECRET=your-super-secret-jwt-key

# Cloudinary
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret

# Firebase Admin
FIREBASE_PROJECT_ID=your-project-id
FIREBASE_PRIVATE_KEY=your-private-key
FIREBASE_CLIENT_EMAIL=your-client-email

# Server
PORT=5000
NODE_ENV=development
FRONTEND_URL=http://localhost:5173

Frontend Environment (.env)

# API Configuration
VITE_API_URL=http://localhost:5000/api
VITE_APP_ENV=development

# Firebase Client
VITE_FIREBASE_API_KEY=your-api-key
VITE_FIREBASE_AUTH_DOMAIN=your-auth-domain
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-storage-bucket
VITE_FIREBASE_MESSAGING_SENDER_ID=your-sender-id
VITE_FIREBASE_APP_ID=your-app-id

Running the Application

  1. Start the Backend

    cd Backend
    npm start
  2. Start the Frontend

    cd Frontend
    npm run dev
  3. Access the App

πŸ“ Project Structure

Article-App/
β”œβ”€β”€ Backend/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── firebase.js          # Firebase Admin setup
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ auth.js              # JWT authentication
β”‚   β”‚   β”œβ”€β”€ upload.js            # Cloudinary uploads
β”‚   β”‚   └── validation.js        # Request validation
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ Article.js           # Article schema
β”‚   β”‚   └── User.js              # User schema
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ articles.js          # Article CRUD
β”‚   β”‚   β”œβ”€β”€ auth.js              # Authentication
β”‚   β”‚   └── users.js             # User management & follow system
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── helpers.js           # Utility functions
β”‚   └── server.js                # Express server
β”œβ”€β”€ Frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   β”œβ”€β”€ _redirects           # Netlify redirects
β”‚   β”‚   └── vercel.json          # Vercel config
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ ErrorBoundary.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ FollowButton.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ FollowList.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ FollowModal.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Navigation.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.jsx
β”‚   β”‚   β”‚   └── SEOHead.jsx
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   └── AuthContext.jsx  # Authentication state
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ ArticleView.jsx  # Article reading page
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx    # User dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.jsx         # Homepage with articles
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx        # Login page
β”‚   β”‚   β”‚   β”œβ”€β”€ NotFound.jsx     # 404 page
β”‚   β”‚   β”‚   β”œβ”€β”€ Preview.jsx      # Article preview
β”‚   β”‚   β”‚   β”œβ”€β”€ Profile.jsx      # User profile editor
β”‚   β”‚   β”‚   β”œβ”€β”€ PublicProfile.jsx # Public user profiles
β”‚   β”‚   β”‚   β”œβ”€β”€ Register.jsx     # Registration page
β”‚   β”‚   β”‚   └── Write.jsx        # Article editor
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   └── firebaseAuth.js  # Firebase client
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”‚   β”œβ”€β”€ api.js           # API client
β”‚   β”‚   β”‚   β”œβ”€β”€ config.js        # App configuration
β”‚   β”‚   β”‚   └── helpers.js       # Utility functions
β”‚   β”‚   └── App.jsx              # Main app component
β”‚   └── package.json
└── README.md

πŸ” Authentication

The app supports two authentication methods:

Email/Password

  • User registration with email verification
  • Secure password hashing with bcrypt
  • JWT token-based authentication

Google OAuth

  • Firebase Google Sign-In integration
  • Seamless account creation and login
  • Secure token verification on backend

🌐 API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • POST /api/auth/google - Google OAuth

Articles

  • GET /api/articles - Get published articles
  • GET /api/articles/:slug - Get article by slug
  • POST /api/articles - Create new article
  • PUT /api/articles/:id - Update article
  • DELETE /api/articles/:id - Delete article
  • POST /api/articles/:id/like - Like/unlike article

Users & Social

  • GET /api/users/username/:username - Get user by username
  • POST /api/users/:id/follow - Follow/unfollow user
  • GET /api/users/:id/followers - Get user followers
  • GET /api/users/:id/following - Get user following
  • GET /api/users/:id/follow-status - Check follow status

πŸš€ Deployment

Backend Deployment

  1. Set up environment variables on your hosting platform
  2. Configure MongoDB Atlas connection
  3. Set up Cloudinary and Firebase credentials
  4. Deploy to platforms like Railway, Render, or Heroku

Frontend Deployment

  1. Build the project: npm run build
  2. Deploy to Netlify, Vercel, or any static hosting
  3. Configure environment variables
  4. Set up redirects for client-side routing

Production Environment Variables

Ensure all sensitive keys are properly configured in your hosting platform's environment settings.

πŸ”’ Security Considerations

Production Checklist

  • All environment variables are set on hosting platform (not in code)
  • Debug logging is disabled in production builds
  • API keys and tokens are never logged or exposed
  • CORS origins are properly configured for production domains
  • Rate limiting is enabled
  • HTTPS is enforced on both frontend and backend

Environment Variables Security

  • Never commit .env files to version control
  • Use your hosting platform's environment variable settings
  • Rotate API keys and secrets regularly
  • Use different Firebase projects for development and production

πŸ›  Development

Available Scripts

Backend

  • npm start - Start production server
  • npm run dev - Start development server with nodemon

Frontend

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run preview - Preview production build

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“ License

This project is licensed under the MIT License.

🀝 Support

If you have any questions or need help, please:

  1. Check the documentation
  2. Search existing issues
  3. Create a new issue with detailed information

Built with ❀️ using React, Node.js, and MongoDB

About

Modern article publishing app built with React, Node.js & MongoDB - write, share, and discover.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published