A modern, responsive web application for buying and selling sustainable second-hand items. Built with Next.js, TypeScript, and TailwindCSS.
- User Authentication: Secure JWT-based auth with email/password signup and login
- Product Management: Full CRUD operations for product listings with image upload
- Real-time Search: Live search with category filtering and sorting
- Shopping Cart: Add/remove items with real-time counter in navbar
- Order Management: Complete checkout process and order history
- User Dashboard: Profile management and account settings
- Image Upload: Drag-and-drop photo upload for product listings
- Responsive Design: Mobile-first design that works on all devices
- Real-time Updates: Live search results and cart counter updates
- Secure Authentication: JWT tokens with httpOnly cookies and bcrypt password hashing
- Database Integration: SQLite with Prisma ORM for development
- Input Validation: Zod schema validation on both client and server
- Type Safety: Full TypeScript implementation
- Frontend: Next.js 15, React 19, TypeScript, TailwindCSS
- Backend: Next.js API Routes
- Database: SQLite (development) / PostgreSQL (production) with Prisma ORM
- Authentication: JWT with bcrypt password hashing
- Validation: Zod for input validation
- Styling: TailwindCSS for responsive UI
- Node.js 18+
- npm or yarn
-
Clone the repository
git clone https://github.com/Mainakgit0/coderz_ecofinds.git cd coderz_ecofinds
-
Install dependencies
npm install
-
Set up environment variables
# Create .env file with these values: DATABASE_URL="file:./dev.db" JWT_SECRET="your-super-secret-jwt-key-change-this-in-production"
-
Set up the database
# Generate Prisma client npx prisma generate # Run database migrations npx prisma db push # Seed the database with sample data npx tsx prisma/seed.ts
-
Start the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
The seed script creates two sample accounts for testing:
- Email:
alice@example.com
| Password:Password123!
- Email:
bob@example.com
| Password:Password123!
src/
βββ app/ # Next.js app router pages
β βββ api/ # API routes
β β βββ auth/ # Authentication endpoints
β β βββ users/ # User management
β β βββ products/ # Product CRUD
β β βββ cart/ # Shopping cart
β β βββ orders/ # Order management
β β βββ upload/ # Image upload
β βββ auth/ # Auth pages (login/signup)
β βββ cart/ # Shopping cart page
β βββ dashboard/ # User dashboard
β βββ marketplace/ # Main marketplace page
β βββ my/listings/ # User's product listings
β βββ orders/ # Order history
β βββ product/[id]/ # Product detail pages
βββ components/ # Reusable UI components
βββ contexts/ # React contexts (Auth, Cart, Theme)
βββ lib/ # Utility functions
β βββ auth.ts # Authentication utilities
β βββ db.ts # Database connection
β βββ validations.ts # Zod schemas
βββ prisma/ # Database schema and migrations
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
- Password Hashing: bcrypt with 12 salt rounds
- JWT Tokens: Access (15min) + Refresh (7d) tokens
- Secure Cookies: httpOnly, secure, sameSite settings
- Input Validation: Server-side validation with Zod
- CORS Protection: Configured for production deployment
- SQL Injection Protection: Prisma ORM with parameterized queries
- User: Authentication and profile data
- Product: Product listings with categories and detailed information
- Order: Purchase records
- OrderItem: Individual items in orders
- CartItem: Shopping cart functionality
- Clothing
- Electronics
- Furniture
- Books
- Accessories
- Other
POST /api/auth/signup
- Register new userPOST /api/auth/login
- User loginPOST /api/auth/logout
- User logoutPOST /api/auth/refresh
- Refresh access token
GET /api/users/me
- Get current userPUT /api/users/me
- Update user profileDELETE /api/users/delete
- Delete user account
GET /api/products
- List products (with search/filter)POST /api/products
- Create productGET /api/products/:id
- Get product detailsPUT /api/products/:id
- Update productDELETE /api/products/:id
- Delete product
GET /api/cart
- Get cart itemsPOST /api/cart
- Add item to cartDELETE /api/cart/:id
- Remove from cartPOST /api/orders
- Checkout (create order)GET /api/orders/me
- Get user's orders
POST /api/upload
- Upload product images
- Push code to GitHub
- Connect repository to Vercel
- Set environment variables in Vercel dashboard
- Deploy automatically on push
DATABASE_URL="postgresql://..." # PostgreSQL connection string
JWT_SECRET="your-production-secret-key"
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
For support, please open an issue on GitHub or contact the development team.