A full-stack clothing swap platform built with React, Node.js, Express, and PostgreSQL.
- Project Structure
- API Endpoints
- Frontend Routes
- Database Setup
- Running the App
- Admin User Setup
- Development Tips
rewear app/
rewear app/
client/ # React frontend
server/ # Node.js/Express backend
Auth
POST /api/auth/register— Register a new userPOST /api/auth/login— LoginGET /api/auth/profile— Get current user profile
Items
GET /api/items— List all approved & available itemsGET /api/items/featured— List featured itemsGET /api/items/:id— Get item detailsPOST /api/items— Create new item (auth required)PUT /api/items/:id— Update item (auth required)DELETE /api/items/:id— Delete item (auth required)GET /api/items/user/me— Get current user's items
Swaps
POST /api/swaps— Create swap requestGET /api/swaps/my-requests— My swap requestsGET /api/swaps/my-items— Requests for my itemsPUT /api/swaps/:id/accept— Accept swapPUT /api/swaps/:id/reject— Reject swapPUT /api/swaps/:id/complete— Complete swapGET /api/swaps/stats— Swap stats
Users
GET /api/users/profile— Get user profile & statsPUT /api/users/profile— Update profileGET /api/users/items— Get user's itemsGET /api/users/swaps— Get user's swap historyGET /api/users/stats— Get user statsGET /api/users/points— Get user points
Admin (admin only)
GET /api/admin/items/pending— List pending itemsPUT /api/admin/items/:id/approve— Approve itemPUT /api/admin/items/:id/reject— Reject itemGET /api/admin/items— List all itemsGET /api/admin/users— List all usersPUT /api/admin/users/:id/admin— Toggle admin statusPUT /api/admin/users/:id/points— Adjust user pointsGET /api/admin/stats— Dashboard statsGET /api/admin/categories— Category stats
Public Stats
GET /api/stats— Public stats for landing page
/— Landing page/login— Login/register— Register/browse— Browse items/item/:id— Item details/add-item— List an item (protected)/edit-item/:id— Edit item (protected)/dashboard— User dashboard (protected)/admin— Admin dashboard (admin only)/admin/users— Admin management (admin only)
- Install PostgreSQL (if not already installed)
- Create the database:
CREATE DATABASE rewear2;
- Create tables:
- The backend auto-creates tables on startup (see
server/config/database.js). - Or, you can manually run the following DDL (simplified):
- The backend auto-creates tables on startup (see
-- Users table
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
points INTEGER DEFAULT 100,
is_admin BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Items table
CREATE TABLE IF NOT EXISTS items (
id SERIAL PRIMARY KEY,
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
title VARCHAR(255) NOT NULL,
description TEXT,
category VARCHAR(100) NOT NULL,
type VARCHAR(100) NOT NULL,
size VARCHAR(50),
condition VARCHAR(50) NOT NULL,
tags TEXT[],
images TEXT[],
points_value INTEGER DEFAULT 50,
is_available BOOLEAN DEFAULT TRUE,
is_approved BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Swaps table
CREATE TABLE IF NOT EXISTS swaps (
id SERIAL PRIMARY KEY,
requester_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
item_id INTEGER REFERENCES items(id) ON DELETE CASCADE,
offered_item_id INTEGER REFERENCES items(id) ON DELETE CASCADE,
swap_type VARCHAR(50) NOT NULL,
status VARCHAR(50) DEFAULT 'pending',
points_offered INTEGER DEFAULT 0,
message TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);cd "rewear app/rewear app/server"
npm install
npm run dev
- The server runs on http://localhost:5000
- Database and server credentials are hardcoded in
server/config/database.js. - If you need to change the database user, password, or other settings, edit the config at the top of that file:
const pool = new Pool({
user: 'postgres',
host: 'localhost',
database: 'rewear2',
password: 'password',
port: 5432,
});cd "rewear app/rewear app/client"
npm install
npm start
- The app runs on http://localhost:3000
To make a user an admin:
- Register a user via the app or API.
- In PostgreSQL, run:
UPDATE users SET is_admin = true WHERE email = 'your@email.com';
- Log out and log back in to refresh your admin status.
- If you change database structure, restart the backend server.
- If you can't see admin features, make sure your user is marked as admin and you are logged in again.
- Uploaded images are stored in
server/uploads/. - For CORS issues, ensure your frontend and backend are running on the correct ports.
- For any issues, check the browser console and backend logs.
THANK YOU!! ~Team Console Crusaders