A modern full-stack e-commerce web application for buying and selling second-hand electronics. Built with React, Express.js, and MySQL.
Try it at: trustinsecond.ykd.dev
STI K3 - Layanan STI Kelompok 5
- Aldoy Fauzan Avanza - 18223113
- M Rabbani K A - 18223130
- Muhammad Rafly Fauzan - 18223132
- Geraldo Linggom Samuel T - 18223136
TrustinSecond is a comprehensive e-commerce platform that allows users to:
- Browse and search products
- Add items to cart and checkout
- View product details and inventory
- Admin dashboard for managing products, inventory, and invoices
- User authentication and authorization
- React 18 - UI library
- React Router - Client-side routing
- Vite - Build tool and dev server
- Node.js - Runtime environment
- Express.js 5 - Web framework
- Prisma - ORM for database management
- MySQL - Database
- JWT - Authentication
- Bcrypt - Password hashing
- Multer - File upload handling
- Node.js (v18 or higher)
- PostgreSQL database
- npm or yarn package manager
-
Clone the repository
git clone https://github.com/aldoyfa/TrustinSecond.git cd TrustinSecond -
Install backend dependencies
cd server npm install cd ..
-
Install frontend dependencies
cd client npm install cd ..
-
Set up environment variables
Create a
.envfile in theserverdirectory:DATABASE_URL="postgresql://user:password@localhost:3306/trustinsecond" JWT_SECRET="your-secret-key" PORT=5000
-
Run database migrations
cd server npx prisma migrate dev -
Generate Prisma Client
npx prisma generate cd ..
Start Backend Server
cd server
node src/server.jsThe backend server will run on http://localhost:15151
Start Frontend Development Server (in a new terminal)
cd client
npm run devThe frontend will run on http://localhost:15152
TrustinSecond/
├── client/ # Frontend React application
│ ├── src/
│ │ ├── components/ # Reusable components
│ │ │ ├── Layout.jsx # Main layout with navigation
│ │ │ └── ProductCard.jsx # Product card component
│ │ ├── contexts/ # React contexts
│ │ │ ├── AuthContext.jsx # Authentication state
│ │ │ └── CartContext.jsx # Shopping cart state
│ │ ├── pages/ # Page components
│ │ │ ├── AdminDashboardPage.jsx
│ │ │ ├── CartPage.jsx
│ │ │ ├── InventoryListPage.jsx
│ │ │ ├── InventoryProductsPage.jsx
│ │ │ ├── InvoicesPage.jsx
│ │ │ ├── ProductDetailPage.jsx
│ │ │ ├── ProductsPage.jsx
│ │ │ ├── SignInPage.jsx
│ │ │ └── SignUpPage.jsx
│ │ ├── App.jsx # Main app component with routes
│ │ ├── main.jsx # Entry point
│ │ └── styles.css # Global styles (centralized)
│ ├── index.html
│ ├── package.json
│ └── vite.config.mjs
│
└── server/ # Backend Node.js application
├── src/
│ ├── config/ # Configuration files
│ │ └── prisma.js # Prisma client instance
│ ├── controllers/ # Route controllers
│ │ ├── auth.controller.js
│ │ ├── cart.controller.js
│ │ ├── inventory.controller.js
│ │ ├── invoice.controller.js
│ │ └── product.controller.js
│ ├── middlewares/ # Express middlewares
│ │ ├── upload.js # Multer file upload
│ │ └── verifyToken.js # JWT authentication
│ ├── routes/ # API routes
│ │ ├── auth.route.js
│ │ ├── cart.route.js
│ │ ├── inventory.route.js
│ │ ├── invoice.route.js
│ │ └── product.route.js
│ ├── utils/ # Utility functions
│ │ ├── cookieOptions.js
│ │ └── response.js
│ └── server.js # Express server entry point
│
├── prisma/ # Prisma schema and migrations
│ ├── schema.prisma
│ └── migrations/
│
├── uploads/ # Uploaded product images
├── .env # Environment variables
└── package.json
POST /api/auth/register- Register new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout user
GET /api/products- Get all productsGET /api/products/:id- Get product by IDGET /api/products/inventory/:id- Get products by inventory IDPOST /api/products- Create product (Admin)PUT /api/products/:id- Update product (Admin)DELETE /api/products/:id- Delete product (Admin)
GET /api/inventory- Get all inventoriesGET /api/inventory/:id- Get inventory by IDPOST /api/inventory- Create inventory (Admin)PUT /api/inventory/:id- Update inventory (Admin)DELETE /api/inventory/:id- Delete inventory (Admin)
GET /api/cart- Get user's cartPOST /api/cart- Add item to cartDELETE /api/cart/:id- Remove item from cart
GET /api/invoice- Get all invoices (Admin)GET /api/invoice/:id- Get invoice by IDPOST /api/invoice/checkout- Create invoice from cartPUT /api/invoice/:id- Update invoice (Admin)DELETE /api/invoice/:id- Delete invoice (Admin)
- Product browsing with search functionality
- Product details view
- Shopping cart management
- Checkout process
- Invoice viewing
- Inventory categories
- Product management (CRUD)
- Inventory management (CRUD)
- Invoice management
- Image upload for products
- Dashboard with tabs interface