Skip to content

Vt221001/walpaper_backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wallpaper App Backend

This is the backend for the Wallpaper App, built with Node.js, Express, and MongoDB, featuring:

  • User and Admin authentication
  • Image uploads with Cloudinary
  • Payments with Razorpay
  • Validation with Joi
  • Modular controller and route structure
  • Error handling middleware

📁 Project Structure

├── Controllers/       → Logic for each route
├── Db/db.js           → MongoDB connection
├── Middlewares/       → Custom middleware (error, multer)
├── Models/            → Mongoose schemas
├── Routes/            → Express routers
├── Utils/             → Helpers (Cloudinary, handlers)
├── Validation/        → Joi validation schemas
├── public/temp/       → Temp folder for uploads
├── app.js             → Main Express app
├── index.js           → Server entry point

⚙️ Tech Stack

  • Backend: Node.js, Express
  • Database: MongoDB with Mongoose
  • File Uploads: Multer + Cloudinary
  • Payments: Razorpay
  • Authentication: JWT
  • Validation: Joi
  • Mailer: Nodemailer

📦 Installation

1. Clone the repository

git clone https://github.com/yourusername/wallpaper-app-backend.git
cd wallpaper-app-backend

2. Install dependencies

npm install

🛠️ Configuration

Create a .env file in the root directory and add the following:

PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret

# Razorpay
RAZORPAY_KEY_ID=your_razorpay_key_id
RAZORPAY_KEY_SECRET=your_razorpay_key_secret

# Cloudinary
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret

# Nodemailer
SMTP_HOST=smtp.example.com
SMTP_PORT=465
SMTP_USER=youremail@example.com
SMTP_PASS=yourpassword

🔐 Note: Make sure to keep .env in your .gitignore (already done).


🚀 Start the Server

Development mode (with auto-reload)

npx nodemon index.js

Production mode

node index.js

Server will start at http://localhost:5000 (or your configured port).


📤 Image Upload (Cloudinary)

  • Cloudinary is configured in src/Utils/cloudinary.js.
  • Uploads handled via multerMiddleware.js.
  • Endpoint example: /api/wallpapers/upload

💳 Payment Integration (Razorpay)

  • Razorpay controller: src/Controllers/razorpayController.js
  • Route: /api/payment/create-order
  • Uses your Razorpay credentials to create and verify orders.

✅ API Features

Feature Endpoint Method
User Registration /api/users/register POST
User Login /api/login POST
Admin CRUD /api/admin/ GET/POST/PUT/DELETE
Wallpaper Upload /api/wallpapers/upload POST
Wallpaper List /api/wallpapers GET
Create Razorpay Order /api/payment/create-order POST

Full routing is in /src/Routes/


🔍 Prettier & Linting

  • Prettier config: .prettierrc
  • Ignored files: .prettierignore

Run formatting:

npx prettier --write .

📦 Deployment (Optional)

If you’re deploying to Vercel, your vercel.json will help route the backend appropriately.

You may also consider platforms like:

  • Render
  • Railway
  • DigitalOcean App Platform

🧪 Testing (Optional Setup)

You can test endpoints using:

  • Postman
  • Thunder Client (VS Code)
  • Insomnia

🙌 Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.


📄 License

This project is licensed under the ISC License.


👨‍💻 Author

Developed by Vedansh Tiwari

About

The Wallpaper Backend is a robust server-side application designed to manage wallpapers, user interactions, and related services. It is built using Node.js, Express.js, and MongoDB, providing a scalable and efficient platform for handling requests and storing data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors