Marketplace kampus untuk jual beli barang bekas antar mahasiswa. Dibangun dengan Next.js 16, React 19, dan Tailwind CSS 4.
- Landing Page - Hero section dengan featured products
- Product List - Katalog produk dengan filter kategori
- Product Detail - Detail produk dengan info penjual
- Login & Register - Autentikasi user
- My Products - Kelola produk sendiri (view, edit, delete)
- Upload Product - Form upload produk dengan foto
- Edit Product - Update informasi produk
- Wishlist - Simpan produk favorit
- Admin Dashboard - Statistics overview (users, products, categories, wishlists)
- Manage Users - Lihat semua user dan role
- Manage Products - Lihat & hapus semua produk
- Manage Categories - Lihat & tambah kategori baru
- Node.js 18+ atau Bun
- Backend Barkasiwa running di
http://localhost:4000
# Install dependencies
bun install
# atau
npm install
# Run development server
bun dev
# atau
npm run devfrontend-barkasiwa/
βββ app/ # Next.js App Router
β βββ page.tsx # Landing page
β βββ layout.tsx # Root layout dengan AuthProvider
β βββ login/ # Login page
β βββ register/ # Register page
β βββ products/ # Public product pages
β β βββ page.tsx # Product list
β β βββ [id]/page.tsx # Product detail
β βββ dashboard/ # Protected user pages
β β βββ products/
β β β βββ page.tsx # My products
β β β βββ new/page.tsx # Upload product
β β β βββ [id]/edit/page.tsx # Edit product
β β βββ wishlist/page.tsx # My wishlist
β βββ admin/ # Admin pages
β βββ page.tsx # Dashboard
β βββ users/page.tsx # Manage users
β βββ products/page.tsx # Manage products
β βββ categories/page.tsx # Manage categories
βββ components/ # React components
β βββ Navbar.tsx # Navigation bar
β βββ ProductCard.tsx # Product card component
βββ contexts/ # React contexts
β βββ AuthContext.tsx # Authentication context
βββ lib/ # Utilities
β βββ api.ts # API client
β βββ utils.ts # Helper functions
βββ types/ # TypeScript types
β βββ api.ts # API types
βββ .env.local # Environment variables
Authentication menggunakan JWT token (localStorage) dan HttpOnly cookie.
import { useAuth } from '@/contexts/AuthContext';
function MyComponent() {
const { user, isAdmin, loading, login, logout } = useAuth();
// Check if user is logged in
if (user) {
console.log('Logged in as:', user.nama);
}
// Check if user is admin
if (isAdmin) {
console.log('User has admin privileges');
}
// Login
await login(email, password);
// Logout
await logout();
}API client tersedia di lib/api.ts:
import { api } from '@/lib/api';
// Get all products
const products = await api.getProducts();
// Get product detail
const product = await api.getProduct(id);
// Create product
const formData = new FormData();
formData.append('nama_barang', 'Laptop');
formData.append('harga', '5000000');
formData.append('category_id', '1');
formData.append('foto', file);
await api.createProduct(formData);
// Add to wishlist
await api.addToWishlist(productId);
// Admin: Get stats
const stats = await api.getAdminStats();Menggunakan Tailwind CSS 4 dengan utility-first approach:
<div className="bg-white p-4 rounded-lg shadow-md hover:shadow-lg transition">
<h1 className="text-3xl font-bold text-blue-600">Title</h1>
<p className="text-gray-600 mt-2">Description</p>
</div>import { formatCurrency } from '@/lib/utils';
formatCurrency(5000000); // "Rp 5.000.000"import { formatDate } from '@/lib/utils';
formatDate('2025-01-09'); // "9 Januari 2025"import { getImageUrl } from '@/lib/utils';
getImageUrl('abc123.jpg'); // "http://localhost:4000/uploads/abc123.jpg"Admin:
- Email:
[email protected] - Password:
admin123
User:
- Register via
/register
- Landing Page β http://localhost:3000
- Register β Create new account
- Login β Login with credentials
- Browse Products β View product list
- Product Detail β Click on product
- Add to Wishlist β Click wishlist button
- Upload Product β Go to "Produk Saya" β "+ Upload Produk"
- Admin Dashboard β Login as admin β Click "Admin"
File .env.local:
NEXT_PUBLIC_API_URL=http://localhost:4000bun devbun run build
bun startbun run buildPastikan backend .env memiliki:
CORS_ORIGIN=http://localhost:3000- Pastikan backend running
- Check file ada di
backend-barkasiwa/public/uploads/ - Verify
next.config.tssudah dikonfigurasi
Clear localStorage dan cookies:
localStorage.clear();# Kill process on port 3000
npx kill-port 3000- Framework: Next.js 16 (App Router)
- UI Library: React 19
- Styling: Tailwind CSS 4
- Language: TypeScript 5
- Package Manager: Bun / npm
- Image Optimization: Next.js Image
- Backend API: http://localhost:4000
- Swagger Docs: http://localhost:4000/
- Backend Integration Guide: task/BACKEND_INTEGRATION.md
- Frontend Starter Guide: task/FRONTEND_STARTER.md
- Setup Guide: SETUP.md
- Backend harus running sebelum start frontend
- Protected routes akan redirect ke
/loginjika belum login - Admin routes akan redirect ke
/jika bukan admin - Image upload max size sesuai backend config
- Token disimpan di localStorage dan HttpOnly cookie
- Add search functionality
- Add pagination
- Add product sorting
- Add user profile page
- Add chat/messaging feature
- Add notifications
- Add image gallery for products
- Add product reviews/ratings
Private project for Barkasiwa marketplace.
Happy Coding! π