Skip to content

paddywind/good-shop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Good Shop

A simple full‑stack blog demo with a Node/Express backend and a Next.js frontend.

Repository layout

  • backend/ — Express API, MongoDB models, middleware for auth and image upload(Cloudinary)
  • frontend/ — Next.js (app router) frontend with pages, components and client API helpers.

Key backend files:

  • backend/server.js — main server entry.
  • backend/src/models/ — Mongoose models (User, BlogPost).
  • backend/src/routes/ — API routes (authRoutes.js, blogRoutes.js).
  • backend/.env.example — example environment variables required by the backend.

Key frontend files:

  • frontend/src/app/ — Next.js app pages and admin area.
  • frontend/src/components/ — UI components.
  • frontend/src/lib/api.js and frontend/src/lib/secureApi.js — client API helpers.
  • frontend/.env — environment variables for the frontend (e.g. NEXT_PUBLIC_API_URL).

Prerequisites

  • Node.js (recommend v18 or later)
  • npm (bundled with Node) or yarn
  • MongoDB database (Atlas)
  • A Cloudinary account for image uploads

Environment variables

Backend: copy backend/.env.example to backend/.env and update values. Example keys found in the project:

CLOUDINARY_URL=cloudinary://<api_key>:<api_secret>@<cloud_name>
JWT_SECRET=your_jwt_secret_here
MONGO_URI=mongodb+srv://<user>:<password>@your-cluster.mongodb.net/<dbname>

Frontend: frontend/.env currently contains:

NEXT_PUBLIC_API_URL=http://localhost:5000

Adjust NEXT_PUBLIC_API_URL to point to your running backend API.

Install and run (development)

Open two terminals (one for backend, one for frontend):

Backend (from repo root):

cd backend
npm install
# create .env from example and edit values
cp .env.example .env
# start dev server (uses nodemon)
npm run dev

Notes:

  • npm run dev in backend runs nodemon server.js.
  • npm.start will run node server.js (for production/startup without nodemon).

Frontend:

cd frontend
npm install
npm run dev

The frontend runs on http://localhost:3000 by default. It uses NEXT_PUBLIC_API_URL to talk to the backend.

Build and run (production)

Import project repo to vercel and deploy the frontend and backend separately using the required environment variables.

Common tasks & tips

  • If uploads fail, confirm CLOUDINARY_URL is set and valid.
  • Check backend logs for MongoDB connection errors; ensure MONGO_URI is reachable.

Where to look in the code

  • Authentication logic: backend/src/middleware/authMiddleware.js and backend/src/routes/authRoutes.js.
  • Cloudinary uploads: backend/src/middleware/cloudinaryMiddleware.js and usage in routes.
  • Client API usage: frontend/src/lib/api.js and frontend/src/lib/secureApi.js.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published