A full-stack web application where college students can buy and sell used products. The project consists of a robust Node.js/Express.js backend API and a modern React/Vite/Tailwind CSS frontend.
| Feature Area | Backend (Node/Express) | Frontend (React/Vite) |
|---|---|---|
| User Management | JWT Auth, secure cookies, bcrypt hashing, protected routes. | Register, Login, Logout flow with Context API state. |
| Product Listings | Full CRUD operations, Cloudinary image upload, authorization. | Create, edit, delete, Mark as Sold, My Products dashboard. |
| Search & Filter | Advanced query parameters for search, category, and price range. | Responsive filtering component with instant results. |
| Security | Input validation (express-validator), MongoDB injection protection. |
PrivateRoute protection, client-side validation. |
| Design | N/A | Mobile-first responsive design with Tailwind CSS. |
All core features, including full CRUD for products, secure authentication, advanced searching, and a responsive UI, are complete.
You will need Node.js (v16+), MongoDB, and a Cloudinary account to run the full application.
# Clone the repository
git clone https://github.com/SouCoder9/OwnerSwap.git
cd OwnerSwap
# Install backend dependencies
cd backend
npm install
# Install frontend dependencies
cd ../frontend
npm install
Create a .env file in the backend directory based on the .env.example and fill in your credentials:
| Variable | Description |
|---|---|
MONGODB_URI |
Your MongoDB connection string (Atlas recommended) |
JWT_SECRET |
Secret key for JWT signing |
CLOUDINARY_CLOUD_NAME |
Your Cloudinary Cloud Name |
CLOUDINARY_API_KEY / SECRET |
Your Cloudinary API Key and Secret |
You will need two separate terminals to run both the backend and frontend concurrently.
# In the /OwnerSwap/backend directory
npm run dev
# Server runs on http://localhost:5000
# In the /OwnerSwap/frontend directory
npm run dev
# App runs on http://localhost:5173
| Category | Method | Endpoint | Description | Authentication |
|---|---|---|---|---|
| Auth | POST |
/api/auth/register |
Create a new user account. | Public |
| Auth | POST |
/api/auth/login |
Log in and receive an httpOnly JWT cookie. |
Public |
| Auth | GET |
/api/auth/me |
Get the currently logged-in userβs profile. | Protected |
| Product | POST |
/api/products |
Create a new product listing (supports multipart/form-data). |
Protected |
| Product | GET |
/api/products |
Get all products with search and filter support (e.g., ?search=book&category=Textbooks). |
Public |
| Product | GET |
/api/products/my-products |
Get the logged-in userβs listings. | Protected |
| Product | PUT |
/api/products/:id |
Update a product listing. | Protected (Owner only) |
| Product | DELETE |
/api/products/:id |
Delete a product listing. | Protected (Owner only) |
OwnerSwap/
βββ backend/
βΒ Β βββ models/ # MongoDB schemas
βΒ Β βββ routes/ # Express API endpoints
βΒ Β βββ middleware/ # Auth/Error handling
βΒ Β βββ server.js # Main entry point
βββ frontend/
Β Β βββ src/
Β Β βΒ Β βββ components/ # Reusable UI elements
Β Β βΒ Β βββ context/ # Global state management
Β Β βΒ Β βββ pages/ # Router-defined components
Β Β βΒ Β βββ services/ # API integration layer (Axios)
Β Β βββ tailwind.config.js
This project is licensed under the MIT License.
Let me know if youβd like to dive deeper into any specific section, like the database schema or the frontend state management!