Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ab7096a
Add root .gitignore to ignore secrets and builds
DevByRico Sep 6, 2025
31935db
Replace old scaffold with client/server app; add .gitignore and env e…
DevByRico Sep 6, 2025
83d1fbc
Add netlify spa redirects
DevByRico Sep 6, 2025
e6da951
readme
DevByRico Sep 6, 2025
5e2ce3b
readme fix
DevByRico Sep 6, 2025
84671a8
readme fix1
DevByRico Sep 6, 2025
ee10fd9
readme fix2
DevByRico Sep 6, 2025
601efd7
Refactor: cleaned and organized code structure based on feedback
DevByRico Oct 18, 2025
5e224c4
Fix: added trust proxy for Render
DevByRico Oct 18, 2025
388960b
Cleaned middleware duplicates and finalized trust proxy fix
DevByRico Oct 18, 2025
f61d970
Add Node engine and finalize server config for Render
DevByRico Oct 18, 2025
b907104
Fix: set trust proxy to 1 for safe rate limit handling on Render
DevByRico Oct 18, 2025
257eac3
Fix: updated API base env variable to match Netlify config
DevByRico Oct 18, 2025
29e8e75
Fix: remove duplicate providers and restore navigation
DevByRico Oct 18, 2025
17d7765
Fix: router context error and update react-router-dom
DevByRico Oct 18, 2025
68864a7
Fix: update react-router and react version to resolve navigation bug
DevByRico Oct 18, 2025
8069d8b
Fix router navigation crash (t is not a function)
DevByRico Oct 18, 2025
52e59e9
Fix: remove double BrowserRouter to fix navigation
DevByRico Oct 18, 2025
593371b
Fix: restore providers but keep single BrowserRouter
DevByRico Oct 18, 2025
be2e793
Fix booking navigation and add modern styled DetailsPage with 'Other'…
DevByRico Oct 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
node_modules
.DS_Store
# --- Node ---
node_modules/
**/node_modules/

# --- Build artifacts ---
dist/
build/
client/dist/
server/dist/
**/dist/
*.log

# --- Env (secrets) ---
.env
*.env
**/.env
**/*.env
.env.local
.env.development.local
.env.test.local
.env.production.local
client/.env
server/.env

# --- Package locks ---
package-lock.json
yarn.lock
pnpm-lock.yaml

# --- OS cruft ---
.DS_Store
Thumbs.db

# --- Editor ---
.vscode/
.idea/

build
# --- Vite cache ---
.vite/
**/.vite/

npm-debug.log*
yarn-debug.log*
yarn-error.log*
# --- Test coverage ---
coverage/

package-lock.json
# --- Misc ---
*.local
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

13 changes: 0 additions & 13 deletions README.md

This file was deleted.

129 changes: 129 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# πŸ’ˆ Barber Booking – Final Project

A modern full-stack barber appointment app with real-time slot availability, email confirmations (ICS calendar invite), and a protected admin dashboard.
Built with a focus on clean code, accessibility, and responsive design.

**Live site:** [https://barber-rico.netlify.app](https://barber-rico.netlify.app)
**API (Render):** [https://project-final-it0v.onrender.com](https://project-final-it0v.onrender.com)

---

## πŸ†• Project Update (Refactor Summary)

This version includes a full refactor and code cleanup based on feedback:

- Converted all components to **functional React** with hooks
- Simplified and reorganized file structure for readability
- Improved responsive design and dark/light theme consistency
- Ensured `.env` and `node_modules` are properly ignored in Git
- Verified all Technigo requirements are met

---

## ✨ Features

- Fast frontend (Vite + React + Tailwind)
- Dark/Light theme toggle (saved in localStorage)
- Calendar with selectable time slots (30-min increments)
- Smooth booking flow with confirmation screen
- Email confirmation + downloadable `.ics` calendar invite
- Admin dashboard (JWT-protected): list, mark as done, delete bookings
- Security middleware: rate limiting, Helmet, CORS
- SEO & PWA optimized (favicons, manifest, Open Graph tags)

---

## 🧱 Tech Stack

**Frontend**
- React (functional components)
- React Router
- Tailwind CSS
- Vite

**Backend**
- Node.js + Express
- MongoDB (Mongoose)
- Nodemailer (Mailtrap for dev)
- JWT authentication

**Hosting**
- Frontend β†’ **Netlify**
- Backend β†’ **Render**

---

## πŸ“ Project Structure

```bash
project-final/
β”œβ”€ client/ # React app (Vite)
β”‚ β”œβ”€ public/ # Favicon, manifest, logo, SEO assets
β”‚ β”œβ”€ src/
β”‚ β”‚ β”œβ”€ components/ # Header, ThemeToggle, ProtectedRoute, etc.
β”‚ β”‚ β”œβ”€ pages/ # SelectTime, DetailsPage, ConfirmPage, Admin
β”‚ β”‚ β”œβ”€ store/ # Contexts (Auth, Booking)
β”‚ β”‚ β”œβ”€ App.jsx, main.jsx, index.css, ...
β”‚ └─ index.html
└─ server/ # Express API
β”œβ”€ index.js # Routes, email, DB connection
β”œβ”€ package.json
└─ .env # πŸ”’ private config (not committed)
```

**Booking schema:**
```js
// Unique index prevents double-booking
bookingSchema.index({ date: 1, time: 1 }, { unique: true });
```

---

## πŸ”’ Security

- Admin JWT stored in **sessionStorage** (auto-clears when tab closes)
- Uses `helmet`, `cors`, and rate limiting
- MongoDB unique index on date+time
- `.env` is excluded from Git (with `.env.example` provided)

---

## 🌐 SEO & UX

- Semantic, accessible structure (WCAG friendly)
- `<title>` + meta descriptions and Open Graph tags
- Light/dark contrast verified
- Responsive across all breakpoints (320px β†’ 1920px)
- Smooth transitions and animations for better UX

---

## πŸ›  Troubleshooting

- **Admin login not working**
- Ensure `JWT_SECRET` exists in `.env` and restart server.

- **CORS error**
- Check that `CLIENT_URL` in `.env` matches your frontend URL.

- **Email not received**
- Use Mailtrap sandbox credentials in dev; check spam folder.

- **Duplicate booking**
- MongoDB unique index on date+time prevents double-booking (returns 409).

---

## βœ… Status

βœ” Functional React Components
βœ” Responsive and accessible UI
βœ” Code cleaned and organized after feedback
βœ” Meets all Technigo project requirements

---

## 🧩 Author

Built by **DevByRico** πŸŽ¨πŸ’»
_Refactored & improved based on Technigo feedback 2025._
5 changes: 0 additions & 5 deletions backend/.babelrc

This file was deleted.

8 changes: 0 additions & 8 deletions backend/README.md

This file was deleted.

20 changes: 0 additions & 20 deletions backend/package.json

This file was deleted.

22 changes: 0 additions & 22 deletions backend/server.js

This file was deleted.

38 changes: 38 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!-- client/index.html -->
<!doctype html>
<html lang="sv">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<title>BΓ€sta barbern – Boka</title>
<meta name="description" content="Boka klippning hos BΓ€sta barbern. Skin fade, skΓ€gg, barnklippning och pensionΓ€rspriser. Enkelt bokningsflΓΆde och snabb e-postbekrΓ€ftelse." />
<link rel="canonical" href="http://localhost:5173/" />
<meta name="robots" content="index,follow" />
<meta property="og:title" content="BΓ€sta barbern – Boka" />
<meta property="og:description" content="Boka klippning hos BΓ€sta barbern. Skin fade, skΓ€gg, barnklippning och pensionΓ€rspriser." />
<meta property="og:type" content="website" />
<meta property="og:image" content="/web-app-manifest-512x512.png" />
<meta property="og:url" content="http://localhost:5173/" />
<meta name="theme-color" content="#0ea5e9" />

<link rel="icon" href="/favicon.ico" sizes="any" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<link rel="manifest" href="/site.webmanifest" />
</head>
<body>
<div id="root"></div>

<script>
// Starta i ljuslΓ€ge om inget finns lagrat
(function () {
const saved = localStorage.getItem('theme');
const root = document.documentElement;
if (saved === 'dark') root.classList.add('dark');
else root.classList.remove('dark');
})();
</script>

<script type="module" src="/src/main.jsx"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "booking-client",
"private": true,
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"dayjs": "^1.11.18",
"framer-motion": "^11.0.8",
"lucide-react": "^0.546.0",
"react": "^18.3.1",
"react-calendar": "^6.0.0",
"react-dom": "^18.3.1",
"react-router-dom": "^6.28.0"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.4",
"vite": "^5.2.0"
},
"proxy": "http://localhost:5000"
}
6 changes: 6 additions & 0 deletions client/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
1 change: 1 addition & 0 deletions client/public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* /index.html 200
Binary file added client/public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions client/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/icon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions client/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-agent: *
Allow: /

Sitemap: http://localhost:5000/sitemap.xml
11 changes: 11 additions & 0 deletions client/public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Barber Shop",
"short_name": "Barber",
"icons": [
{ "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" }
],
"theme_color": "#0ea5e9",
"background_color": "#0ea5e9",
"display": "standalone"
}
5 changes: 5 additions & 0 deletions client/public/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>http://localhost:5000/</loc></url>
<url><loc>http://localhost:5000/admin/login</loc></url>
</urlset>
Loading