Skip to content

Commit 8419cc8

Browse files
feat(frontend): add cart and payment features, improve localhost setup
2 parents fe92004 + d177149 commit 8419cc8

File tree

16 files changed

+706
-207
lines changed

16 files changed

+706
-207
lines changed

CODE_OF_CONDUCT.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,14 @@ enforcement ladder](https://github.com/mozilla/diversity).
126126
For answers to common questions about this code of conduct, see the FAQ at
127127
https://www.contributor-covenant.org/faq. Translations are available at
128128
https://www.contributor-covenant.org/translations.
129+
130+
## Project Status Updates
131+
132+
To keep the community informed and help with onboarding and debugging, contributors should also keep the project's `PROJECT_STATUS.md` up to date when making changes that affect configuration, runtime behavior, scripts, or major features. Examples include:
133+
134+
- Adding or changing routes or API endpoints
135+
- Changing dev/start scripts or build tools
136+
- Updating or removing CI hooks and developer tooling
137+
- Adding or removing major dependencies
138+
139+
When you open a pull request that makes such changes, please update `PROJECT_STATUS.md` with a short note (what changed, date, and any local steps needed to run or test). This helps maintainers and new contributors quickly understand the current project health.

CONTRIBUTION.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Contribution Guidelines
2+
3+
Thank you for contributing to UniLoot! This repository follows a lightweight process to keep project status clear and up-to-date.
4+
5+
## How to contribute
6+
7+
1. Fork the repository (or branch from main if you have write access).
8+
2. Create a descriptive branch for your work (e.g. `feature/browse-page`, `fix/db-connection`).
9+
3. Make your changes and run the app locally (see `README.md` for setup). Add tests if applicable.
10+
4. Update documentation where relevant.
11+
12+
## Project Status Tracking (IMPORTANT)
13+
14+
We use `PROJECT_STATUS.md` as the canonical human-readable snapshot of the repository health and major changes. To keep the project status accurate for all contributors, please follow these rules:
15+
16+
- Every time you merge or push a change that affects configuration, scripts, runtime behavior, CI, or major features (for example: adding routes, changing server scripts, updating TypeScript config, adding/removing hooks, etc.), update `PROJECT_STATUS.md` with:
17+
- A one-line summary of the change (who, when, what)
18+
- Any local run/start instructions that changed
19+
- New dependencies added or removed
20+
- Any manual steps required for running the app (for example, set `MONGO_URI` in `backend/.env`)
21+
22+
- Keep the **Last updated** line current with the date and include the commit hash or PR reference if possible.
23+
24+
- Use clear headings and the same top-level structure as the existing `PROJECT_STATUS.md` so the file remains easy to scan (Summary → Changes → Health checks → Next steps).
25+
26+
## Commit message style
27+
28+
We recommend conventional commits. A good commit message format is:
29+
30+
```
31+
<type>(<scope>): <short summary>
32+
33+
<body> (optional)
34+
35+
<footer> (optional)
36+
```
37+
38+
Examples:
39+
```
40+
feat(ui): add product card component
41+
fix(backend): guard mongoose connect when MONGO_URI missing
42+
chore(dev): update dev script to src/server.ts
43+
```
44+
45+
If you are unable to use commit hooks locally, explain why in the PR description and we can address the hook configuration centrally.
46+
47+
## Making a Pull Request
48+
49+
- Open a PR against `main` with a descriptive title and summary of changes.
50+
- Link any related issues.
51+
- In the PR description, include any manual steps required to run/test the change (for reviewers).
52+
- Update `PROJECT_STATUS.md` in the same PR if the change affects project state.
53+
54+
## Questions
55+
56+
If you're unsure whether a change requires a `PROJECT_STATUS.md` update, please add it — better to be explicit. If you have questions, open an issue and tag a maintainer.
57+
58+
Thanks for improving UniLoot — your contributions make the project better!
59+
60+
## Keep your branch up-to-date with `main`
61+
62+
To avoid merge conflicts and keep development smooth, please regularly sync your feature branches with `main` while you work. Recommended cadence:
63+
64+
- Pull from `main` at least once a day for long-lived branches.
65+
- Pull before opening a PR or immediately before merging.
66+
67+
Suggested workflow (from your feature branch):
68+
69+
```powershell
70+
# fetch latest
71+
git fetch origin
72+
73+
# update your local main branch
74+
git checkout main
75+
git pull origin main
76+
77+
# switch back to your feature branch and rebase or merge
78+
git checkout feature/your-branch
79+
# Option A: rebase (clean history)
80+
git rebase main
81+
# OR Option B: merge (preserve history)
82+
git merge main
83+
```
84+
85+
If you frequently encounter conflicts or diverging histories, consider creating smaller PRs or rebasing frequently to keep your work current.

PROJECT_STATUS.md

Lines changed: 50 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -1,197 +1,68 @@
1-
# 🔍 COMPLETE PROJECT RECHECK - October 17, 2025
1+
# 🔍 PROJECT STATUS — October 21, 2025
22

3-
## ALL SYSTEMS GREEN - NO ERRORS FOUND
3+
## CURRENT SUMMARY
44

5-
### 📊 Final Status Report
5+
This file records the most recent project health check and changes. Updated after the latest development tasks on October 21, 2025.
66

7-
#### 🎯 **TypeScript Compilation**
8-
-**0 Errors** - All files compile successfully
9-
-**Frontend**: No TypeScript errors
10-
-**Backend**: No TypeScript errors
7+
### Key points
8+
- ✅ Repository synced with remote `origin/main` (latest pull applied)
9+
- ✅ Backend dev server runs on port 5000 (MongoDB connection is optional in dev)
10+
- ✅ Frontend dev server runs on port 8080 (Vite)
11+
- ✅ Browse and Sell pages added and wired into routes
12+
- ✅ Commit made and pushed to `main` with recent fixes
1113

12-
#### 🔧 **Configuration Files**
13-
14-
**Frontend (`vite.config.ts`):**
15-
- ✅ Fixed: Removed invalid plugin configuration
16-
- ✅ Status: Clean configuration with react() plugin only
17-
- ✅ Port: 8080 configured correctly
18-
- ✅ Path alias: `@` mapped to `./src`
14+
---
1915

20-
**Backend (`package.json`):**
21-
- ✅ Entry point: `server.ts` (root level)
22-
- ✅ Dev script: `ts-node-dev --respawn --transpile-only server.ts`
23-
- ✅ Port: 5000 (from .env)
16+
### 🔧 Recent changes (Oct 21, 2025)
2417

25-
#### 🖼️ **Image Import Fix**
26-
- ✅ Created: `frontend/src/vite-env.d.ts`
27-
- ✅ Declares: .png, .jpg, .jpeg, .svg, .gif, .webp, .ico, .bmp
28-
- ✅ Image exists: `frontend/src/assets/ex4.png`
18+
- backend: updated `package.json` dev script to `src/server.ts` and made MongoDB connection optional (guarded when `MONGO_URI` not set).
19+
- backend: updated `src/app.ts` to avoid failing start when `MONGO_URI` is missing/invalid.
20+
- frontend: added `Browse.tsx` and `Sell.tsx` pages and registered routes in `App.tsx`.
21+
- frontend: updated `Home.tsx` to call `navigate('/browse')` and `navigate('/sell')`.
22+
- repo: removed/disabled commitlint hook and deleted `commitlint.config.js`.
23+
- repository: changes committed and pushed to `main` (commit: d9a03d8).
2924

30-
#### 🖱️ **Button Click Handlers**
31-
-**Buy Button**: Has `onClick={handleBuyClick}` handler
32-
-**Sell Button**: Has `onClick={handleSellClick}` handler
33-
-**Navigation**: `useNavigate` imported from react-router-dom
34-
-**Console Logging**: Both buttons log to console when clicked
35-
-**Ready for**: Future navigation to /browse and /sell pages
25+
---
3626

37-
#### 📁 **Project Structure**
27+
### 📁 Current quick project map
3828

3929
```
4030
UniLoot/
4131
├── backend/
42-
│ ├── server.ts ✓ (entry point)
43-
│ ├── .env ✓
44-
│ ├── package.json ✓
45-
│ ├── tsconfig.json ✓
46-
│ └── src/
47-
│ ├── app.ts ✓
48-
│ ├── controllers/
49-
│ │ └── healthController.ts ✓
50-
│ └── routes/
51-
│ └── healthRoutes.ts ✓
52-
32+
│ ├── src/
33+
│ │ ├── server.ts
34+
│ │ └── app.ts (DB connection optional)
35+
│ ├── package.json (dev -> src/server.ts)
36+
│ └── .env (optional MONGO_URI)
5337
└── frontend/
54-
├── vite.config.ts ✓ (FIXED)
55-
├── .env ✓
56-
├── package.json ✓
57-
├── tsconfig.json ✓
58-
└── src/
59-
├── vite-env.d.ts ✓ (NEW - Fixed image imports)
60-
├── main.tsx ✓
61-
├── App.tsx ✓
62-
├── assets/
63-
│ └── ex4.png ✓
64-
├── components/
65-
│ ├── Home.tsx ✓ (FIXED - Added click handlers)
66-
│ └── ui/ ✓ (46 components)
67-
├── pages/
68-
│ └── Index.tsx ✓
69-
└── lib/
70-
└── utils.tsx ✓
38+
├── src/
39+
│ ├── App.tsx (routes include /browse and /sell)
40+
│ ├── pages/
41+
│ │ ├── Browse.tsx (new)
42+
│ │ └── Sell.tsx (new)
43+
│ └── components/
44+
│ └── Home.tsx (Buy/Sell navigation enabled)
45+
└── vite.config.ts
7146
```
7247

73-
#### 🌐 **API Endpoints**
74-
75-
**Backend (Port 5000):**
76-
-`GET /api/health` - Health check endpoint
77-
- ✅ CORS enabled
78-
- ✅ Body parser configured
79-
- ✅ Morgan logging active
80-
81-
**Frontend (Port 8080):**
82-
- ✅ Home page: `/`
83-
- ✅ React Router configured
84-
- ✅ All UI components loaded
85-
86-
#### 🧪 **Testing Instructions**
87-
88-
1. **Test Button Clicks:**
89-
```
90-
1. Open browser: http://localhost:8080/
91-
2. Open DevTools Console (F12)
92-
3. Click "Buy" button
93-
→ Should see: "Buy button clicked - Navigate to browse page"
94-
4. Click "Sell" button
95-
→ Should see: "Sell button clicked - Navigate to sell page"
96-
```
97-
98-
2. **Test Backend:**
99-
```
100-
Open: http://localhost:5000/api/health
101-
Expected: {"status":"ok","timestamp":"..."}
102-
```
103-
104-
3. **Test Hot Reload:**
105-
```
106-
1. Edit any file in frontend/src/
107-
2. Save
108-
3. Browser should auto-refresh
109-
```
110-
111-
#### 📝 **Changes Made in This Recheck**
112-
113-
1. **Fixed `vite.config.ts`**
114-
- Removed invalid `mode === "development"` from plugins array
115-
- Simplified to `plugins: [react()]`
116-
117-
2. **Created `vite-env.d.ts`**
118-
- Added type declarations for all image formats
119-
- Resolved "Cannot find module" error for .png imports
120-
121-
3. **Re-applied Button Click Handlers**
122-
- Added `useNavigate` hook
123-
- Added `handleBuyClick` and `handleSellClick` functions
124-
- Added `onClick` props to both buttons
125-
- Added console.log for debugging
126-
127-
#### 🚀 **Next Development Steps**
128-
129-
**To Make Buttons Navigate (When Ready):**
130-
131-
1. Create Browse Page:
132-
```tsx
133-
// frontend/src/pages/Browse.tsx
134-
const Browse = () => {
135-
return (
136-
<div className="container mx-auto p-6">
137-
<h1>Browse Products</h1>
138-
{/* Add product listing here */}
139-
</div>
140-
);
141-
};
142-
export default Browse;
143-
```
144-
145-
2. Create Sell Page:
146-
```tsx
147-
// frontend/src/pages/Sell.tsx
148-
const Sell = () => {
149-
return (
150-
<div className="container mx-auto p-6">
151-
<h1>Sell Your Items</h1>
152-
{/* Add sell form here */}
153-
</div>
154-
);
155-
};
156-
export default Sell;
157-
```
158-
159-
3. Update App.tsx Routes:
160-
```tsx
161-
import Browse from "./pages/Browse";
162-
import Sell from "./pages/Sell";
163-
164-
// Add routes:
165-
<Route path="/browse" element={<Browse />} />
166-
<Route path="/sell" element={<Sell />} />
167-
```
168-
169-
4. Uncomment navigation in Home.tsx:
170-
```tsx
171-
const handleBuyClick = () => {
172-
navigate('/browse');
173-
};
174-
175-
const handleSellClick = () => {
176-
navigate('/sell');
177-
};
178-
```
179-
180-
#### 🎉 **Project Health: EXCELLENT**
181-
182-
-**0** Compilation Errors
183-
-**0** Runtime Errors
184-
-**0** TypeScript Errors
185-
-**0** Configuration Issues
186-
- ✅ Backend Running Smoothly
187-
- ✅ Frontend Running Smoothly
188-
- ✅ All Dependencies Installed
189-
- ✅ All Click Handlers Working
190-
- ✅ HMR (Hot Module Replacement) Active
191-
- ✅ Ready for Development
48+
---
49+
50+
### ✅ Health checks performed (local)
51+
52+
- Pulled latest code from `origin/main` — success
53+
- Started backend dev server (logs show `Server running on port 5000`) — success (skips DB connect when MONGO_URI missing)
54+
- Started frontend dev server (Vite) on `http://localhost:8080/` — success
19255

19356
---
19457

195-
**Last Checked:** October 17, 2025
196-
**Status:** 🟢 **PRODUCTION READY** (for current features)
197-
**Developer:** Ready to build amazing features! 🚀
58+
### � Next recommended tasks
59+
60+
1. If you need database-backed features locally, set `MONGO_URI` in `backend/.env` to a valid MongoDB connection string (mongodb:// or mongodb+srv://).
61+
2. Wire frontend product listing/detail pages to backend APIs (controllers/routes were added in the recent pull).
62+
3. Add tests or a small smoke-test script that pings `/api/health` and the frontend root.
63+
64+
---
65+
66+
**Last updated:** October 21, 2025
67+
68+
**Committed by:** changes pushed to `main` (commit d9a03d8)

backend/.env.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
# --- JWT Configuration ---
3+
# Secret key for signing access tokens. Should be a long, random string.
4+
JWT_SECRET=your_jwt_secret_key_here
5+
6+
# Secret key for signing refresh tokens. Should be a long, random string, different from JWT_SECRET.
7+
JWT_REFRESH_SECRET=your_jwt_refresh_secret_key_here
8+
9+
# Access token expiration time (e.g., 10m, 1h, 1d)
10+
ACCESS_TOKEN_EXPIRY=10m
11+
12+
# Refresh token expiration time (e.g., 7d, 30d)
13+
REFRESH_TOKEN_EXPIRY=7d
14+
15+
# --- Server Configuration ---
16+
# Port for the server to run on
17+
PORT=4000

0 commit comments

Comments
 (0)