Skip to content

Commit fb9b483

Browse files
committed
restyle: replace blue-purple AI cliché palette with warm amber/gold, remove backgrounds from logos, rewrite copy to be more human, remove CTA section
- New brand palette: rich amber (#b45309) primary, warm stone secondary - Card icons: no background, stroke-only with distinct colors per category - Landing page: removed CTA section, asymmetric card grid, natural Persian copy - Frontend: updated all components (Navigation, Footer, Hero, AdCard, Modals, etc.) - Removed generic fade-in/slide-up animations, using custom cubic-bezier easing - All purple-blue gradients replaced with warm earth tones
1 parent 6af89a2 commit fb9b483

38 files changed

Lines changed: 1152 additions & 1145 deletions

‎Backend/.env.example‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
# برای MongoDB لوکال:
77
MONGODB_URI=mongodb://localhost:27017/amlak_db
88

9+
# سرور با احراز هویت (حتماً USER و PASS را بگذارید؛ در غیر این صورت delete/write خطا می‌دهد):
10+
# MONGODB_URI=mongodb://USERNAME:PASSWORD@HOST:27017/amlak_db?authSource=admin
11+
# اگر authSource را جدا می‌خواهی:
12+
# MONGODB_AUTH_SOURCE=admin
13+
914
# برای MongoDB Atlas (کلود):
1015
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/amlak_db?retryWrites=true&w=majority
1116

@@ -26,18 +31,19 @@ JWT_EXPIRE=7d
2631
# پورت سرور بک‌اند
2732
PORT=5000
2833

29-
# محیط اجرا (development یا production)
30-
NODE_ENV=development
34+
# روی سرور حتماً production بگذار تا استاتیک فرانت درست سرو شود
35+
NODE_ENV=production
3136

3237
# ==========================================
3338
# تنظیمات CORS (دسترسی از دامنه‌های دیگر)
3439
# ==========================================
3540

36-
# آدرس فرانت‌اند (برای development)
41+
# آدرس دقیق فرانت (بدون / آخر). این مبدأ هم به CORS اضافه می‌شود — برای production مثال:
42+
# FRONTEND_URL=https://amlak.mmdcode.top
3743
FRONTEND_URL=http://localhost:5173
3844

39-
# در production می‌تونی چند آدرس بذاری با کاما:
40-
ALLOWED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com
45+
# هر دامنهٔ اضافه (با کاما). amlak.mmdcode.top از قبل داخل کد merge می‌شود؛ فقط اگر دامنهٔ دیگری داری بگذار:
46+
# ALLOWED_ORIGINS=https://app.example.com
4147

4248
# محدودیت سراسری درخواست‌ها (Rate Limit)
4349
API_RATE_LIMIT_WINDOW_MS=900000
@@ -52,3 +58,12 @@ MAX_FILE_SIZE=5242880
5258

5359
# پوشه ذخیره تصاویر
5460
UPLOAD_DIR=uploads
61+
62+
# ==========================================
63+
# اسکریپت seed (scripts/seedDatabase.js)
64+
# ==========================================
65+
# اگر روی سرور پوشه frontend/public/images/properties ندارید، آدرس پایه همان مسیر استاتیک را بدهید
66+
# (بدون / آخر هم OK است). نام فایل‌ها پیش‌فرض مثل download-images: property-01.jpg … property-30.jpg
67+
# SEED_PROPERTY_IMAGES_BASE_URL=https://amlak.mmdcode.top/images/properties
68+
# اختیاری — اگر نام فایل‌های شما فرق دارد، با کاما جدا کنید:
69+
# SEED_PROPERTY_IMAGE_FILENAMES=img1.jpg,img2.jpg,photo-a.png

‎Backend/config/database.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ const mongoose = require('mongoose');
33
// MongoDB Connection Configuration
44
const connectDB = async () => {
55
try {
6-
const conn = await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/amlak_db');
6+
const uri = process.env.MONGODB_URI || 'mongodb://localhost:27017/amlak_db';
7+
const opts = {};
8+
if (process.env.MONGODB_AUTH_SOURCE) {
9+
opts.authSource = process.env.MONGODB_AUTH_SOURCE;
10+
}
11+
const conn = await mongoose.connect(uri, opts);
712

813
console.log('✅ MongoDB Connected Successfully!');
914
console.log(`🗄️ Database: ${conn.connection.name}`);

‎Backend/scripts/seedDatabase.js‎

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
const mongoose = require('mongoose');
1010
const fs = require('fs');
1111
const path = require('path');
12+
const { URL } = require('url');
1213
const User = require('../models/User');
1314
const Ad = require('../models/Ad');
1415
require('dotenv').config({ path: path.resolve(__dirname, '..', '.env') });
@@ -81,7 +82,37 @@ function generateCoordinates(provinceName) {
8182
return { lat: parseFloat(lat.toFixed(6)), lng: parseFloat(lng.toFixed(6)) };
8283
}
8384

84-
// Get random local property images
85+
/** Same naming as frontend/download-images.cjs (property-01.jpg … property-30.jpg) */
86+
function getDefaultRemotePropertyFilenames() {
87+
const names = [];
88+
for (let i = 1; i <= 30; i += 1) {
89+
names.push(`property-${String(i).padStart(2, '0')}.jpg`);
90+
}
91+
return names;
92+
}
93+
94+
function parseRemoteFilenamesFromEnv() {
95+
const raw = process.env.SEED_PROPERTY_IMAGE_FILENAMES;
96+
if (!raw || !String(raw).trim()) return null;
97+
return String(raw)
98+
.split(',')
99+
.map((s) => s.trim())
100+
.filter(Boolean);
101+
}
102+
103+
/** Base URL for seeded property images on the server (no trailing slash), e.g. https://amlak.mmdcode.top/images/properties */
104+
function getRemotePropertyImagesBaseUrl() {
105+
const u = process.env.SEED_PROPERTY_IMAGES_BASE_URL;
106+
if (!u || !String(u).trim()) return '';
107+
return String(u).replace(/\/+$/, '');
108+
}
109+
110+
function joinRemotePropertyUrl(base, filename) {
111+
const baseWithSlash = base.endsWith('/') ? base : `${base}/`;
112+
return new URL(filename, baseWithSlash).href;
113+
}
114+
115+
// Get random local property images, or full URLs from SEED_PROPERTY_IMAGES_BASE_URL when no local folder
85116
function getRandomPropertyImages(count = 3) {
86117
const candidateDirs = [
87118
// Preferred (this repo keeps demo images under frontend/public)
@@ -115,11 +146,26 @@ function getRandomPropertyImages(count = 3) {
115146
}
116147
}
117148

118-
// If no local images, copy from Unsplash URLs (fallback)
149+
// Remote/CDN: same paths as static hosting (e.g. /images/properties on production domain)
150+
if (availableImages.length === 0) {
151+
const remoteBase = getRemotePropertyImagesBaseUrl();
152+
if (remoteBase) {
153+
const filenames = parseRemoteFilenamesFromEnv() || getDefaultRemotePropertyFilenames();
154+
const remoteUrls = filenames.map((name) => joinRemotePropertyUrl(remoteBase, name));
155+
const shuffled = remoteUrls.sort(() => 0.5 - Math.random());
156+
const picked = shuffled.slice(0, Math.min(count, shuffled.length));
157+
console.log(
158+
` 📎 Using ${picked.length} remote property image URL(s) from ${remoteBase}`
159+
);
160+
return picked;
161+
}
162+
}
163+
164+
// If no local images and no remote base
119165
if (availableImages.length === 0) {
120166
console.log(
121167
' ⚠️ No local property images found in expected folders (frontend/public/images/properties / frontend/dist/images/properties / public/images/properties). ' +
122-
'Run: (cd frontend && npm run download:images)'
168+
'Either run (cd frontend && npm run download:images), or set SEED_PROPERTY_IMAGES_BASE_URL to your hosted folder (e.g. https://yourdomain.com/images/properties).'
123169
);
124170
return [];
125171
}

‎Backend/server.js‎

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,43 @@ const app = express();
1313
const PORT = process.env.PORT || 5000;
1414
const isProduction = process.env.NODE_ENV === 'production';
1515

16-
const allowedOrigins = isProduction
17-
? (process.env.ALLOWED_ORIGINS
18-
? process.env.ALLOWED_ORIGINS.split(',').map((origin) => origin.trim()).filter(Boolean)
19-
: ['https://amlak.mmdcode.top'])
20-
: [
21-
'http://localhost:3000',
22-
'http://localhost:5173',
23-
'http://localhost:5174',
24-
'http://127.0.0.1:3000',
25-
'http://127.0.0.1:5173',
26-
'http://127.0.0.1:5174'
27-
];
16+
/** دامنهٔ واقعی فرانت (وقتی API روی ساب‌دامنهٔ دیگری است) — همیشه با dev و ALLOWED_ORIGINS ادغام می‌شود تا اگر NODE_ENV روی سرور ست نشده بود CORS نشکند. */
17+
const productionOriginDefaults = [
18+
'https://amlak.mmdcode.top',
19+
'https://www.amlak.mmdcode.top'
20+
];
21+
22+
const devOrigins = [
23+
'http://localhost:3000',
24+
'http://localhost:5173',
25+
'http://localhost:5174',
26+
'http://127.0.0.1:3000',
27+
'http://127.0.0.1:5173',
28+
'http://127.0.0.1:5174'
29+
];
30+
31+
const fromEnvList = process.env.ALLOWED_ORIGINS
32+
? process.env.ALLOWED_ORIGINS.split(',').map((origin) => origin.trim()).filter(Boolean)
33+
: [];
34+
35+
const frontendUrlRaw = process.env.FRONTEND_URL?.trim();
36+
const fromFrontendUrl = frontendUrlRaw
37+
? [frontendUrlRaw.replace(/\/+$/, '')]
38+
: [];
39+
40+
const allowedOrigins = [...new Set([
41+
...productionOriginDefaults,
42+
...devOrigins,
43+
...fromEnvList,
44+
...fromFrontendUrl
45+
])];
2846

2947
const corsOptions = {
3048
origin(origin, callback) {
3149
if (!origin || allowedOrigins.includes(origin)) {
3250
return callback(null, true);
3351
}
34-
52+
console.warn(`CORS blocked origin: ${origin}`);
3553
return callback(new Error('Not allowed by CORS'));
3654
},
3755
credentials: true
@@ -154,4 +172,5 @@ app.listen(PORT, () => {
154172
console.log(`🚀 Server running on port ${PORT}`);
155173
console.log(`📱 Environment: ${process.env.NODE_ENV || 'development'}`);
156174
console.log(`🌐 URL: http://localhost:${PORT}`);
175+
console.log(`🔓 CORS allowed origins (${allowedOrigins.length}): ${allowedOrigins.join(', ')}`);
157176
});

‎frontend/index.html‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,13 @@
3030
<!-- PWA Manifest -->
3131
<link rel="manifest" href="/manifest.json" />
3232
<meta name="theme-color" content="#3b82f6" />
33+
<meta name="mobile-web-app-capable" content="yes" />
3334
<meta name="apple-mobile-web-app-capable" content="yes" />
3435
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
3536
<meta name="apple-mobile-web-app-title" content="املاک ایران" />
36-
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
37+
<link rel="apple-touch-icon" href="/vite.svg" />
3738

38-
<!-- Performance Optimizations -->
39-
<link rel="preconnect" href="https://fonts.googleapis.com">
40-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
41-
<link rel="dns-prefetch" href="https://fonts.googleapis.com">
42-
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
43-
44-
<!-- Fonts -->
45-
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
39+
<!-- Vazirmatn is bundled via npm (vazirmatn package) in main.jsx — no Google Fonts (avoids timeout in restricted networks) -->
4640

4741
<!-- Structured Data -->
4842
<script type="application/ld+json">

‎frontend/package-lock.json‎

Lines changed: 0 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎frontend/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"react": "^18.3.1",
3636
"react-chartjs-2": "^5.3.0",
3737
"react-dom": "^18.3.1",
38-
"react-leaflet": "^5.0.0",
3938
"react-router-dom": "^6.28.0",
4039
"vazirmatn": "^33.0.3"
4140
},

‎frontend/src/App.jsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const AppContent = memo(() => {
116116
}, [navigate]);
117117

118118
return (
119-
<div className="App min-h-screen bg-gradient-to-br from-blue-50 via-white to-purple-50 dark:from-slate-900 dark:via-slate-800 dark:to-slate-900 transition-colors duration-300">
119+
<div className="App min-h-screen bg-warm-50 dark:bg-warm-900 transition-colors duration-300">
120120
<ToastContainer />
121121

122122
<Navigation

0 commit comments

Comments
 (0)