An open API service indexing awesome lists of open source software.

https://github.com/espinbrandon49/swap-meet-react

Full Stack Ecommerce - Swap Meet React
https://github.com/espinbrandon49/swap-meet-react

axios-rest bcrypt-nodejs bootstrap expressjs formik formik-yup heroku jwt-authentication multer mysql nodejs react react-bootstrap react-dom react-router react-router-dom react-toastify sequelize-orm

Last synced: 5 months ago
JSON representation

Full Stack Ecommerce - Swap Meet React

Awesome Lists containing this project

README

          

# Swap Meet React API

A fully functional RESTful API for managing users, categories, products, tags, and shopping carts. Built with Node.js, Express, Sequelize, and MySQL.

---

## πŸ“Š Entity–Relationship Diagram (ERD)

![ERD](./ERD.png)

---

## πŸš€ Features
- User authentication with JWT
- Category + Product ownership scoped to users
- Tagging system (many-to-many between products and tags)
- Shopping cart with item quantities
- Full CRUD support across all entities
- Sequelize models with associations and alias consistency

---

## πŸ› οΈ Tech Stack
- Backend: Node.js, Express
- Database: MySQL with Sequelize ORM
- Auth: JWT-based authentication
- Testing: Insomnia REST client

---

## πŸ“‚ Project Structure
server/
β”œβ”€β”€ models/ # Sequelize models
β”œβ”€β”€ routes/ # Express routes
β”œβ”€β”€ seeds/ # Database seeding script
β”œβ”€β”€ config/ # DB connection
└── server.js # Express entry point

---

## βš™οΈ Setup

1. Clone Repo
git clone
cd Swap-Meet-React

2. Install Dependencies
npm install --workspaces

3. Configure Environment
Create a `.env` file:
NODE_ENV=development
DB_NAME=swapmeetreact
DB_USER=root
DB_PW=password
DB_HOST=127.0.0.1
DB_PORT=3306
JWT_SECRET=your-secret-key

4. Setup Database
mysql -u root -p
DROP DATABASE IF EXISTS swapmeetreact;
CREATE DATABASE swapmeetreact;
EXIT;

5. Seed Database
npm run seed --workspace server

6. Start Server
npm run dev --workspace server

Server will run at:
http://localhost:3001/api

---

## πŸ§ͺ API Endpoints

### Users
- POST /users β†’ Register
- POST /users/login β†’ Login (returns JWT)
- GET /users/auth β†’ Validate token
- GET /users/basicinfo/:id β†’ Public profile

### Categories
- GET /categories β†’ All categories (with products)
- GET /categories/:id β†’ Single category (with products)
- POST /categories β†’ Create category
- PUT /categories/:id β†’ Update category
- DELETE /categories/:id β†’ Delete category

### Products
- GET /products β†’ All user products
- GET /products/:id β†’ Single product
- GET /products/by-category/:category_id β†’ Products by category
- POST /products β†’ Create product
- PATCH /products/:id β†’ Update product
- DELETE /products/:id β†’ Delete product

### Tags
- GET /tags β†’ All tags (with products)
- GET /tags/:id β†’ Single tag (with products)
- POST /tags β†’ Create tag

### Cart
- POST /cart β†’ Create or return user’s cart
- GET /cart/me β†’ Get user’s cart (with products)
- POST /cart/items β†’ Add product to cart
- DELETE /cart/items β†’ Remove product from cart

---

## πŸ§ͺ Testing with Insomnia
Import the provided Insomnia collection (Insomnia_2025-09-23.yaml) to test all endpoints.

Workflow:
1. Register or log in a user
2. Copy JWT β†’ set as {{ accessToken }}
3. Run category/product/cart requests

---

## πŸ“„ License
MIT License β€” free to use and modify.