A production-ready React application for a flour milling company, integrated with Firebase.
- تهيئة المشروع: تأكد من تثبيت Node.js.
- إعداد Firebase:
- اذهب إلى Firebase Console.
- أنشئ مشروعاً جديداً باسم
alshifa-mills. - قم بتفعيل Authentication (Email/Password).
- قم بتفعيل Firestore Database.
- قم بتفعيل Storage.
- الربط: انسخ إعدادات Firebase وضعها في ملف
src/firebaseConfig.ts(انظر المثال أدناه). - التشغيل: استخدم
npm startأوnpm run dev.
/
├── index.html # Entry point (includes Tailwind CDN & Fonts)
├── index.tsx # Main Application Logic (SPA)
├── firestore.rules # Security Rules for Firestore
├── public/ # Static assets
└── src/ # (Virtual Structure inside index.tsx)
├── components/ # Header, Hero, ProductCard
├── services/ # FirebaseService
└── types/ # TypeScript Interfaces
To make the "Real Code" work, replace the FirebaseService mock in index.tsx with this actual implementation:
import { initializeApp } from "firebase/app";
import { getFirestore, collection, getDocs, addDoc } from "firebase/firestore";
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_PROJECT.firebaseapp.com",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_PROJECT.appspot.com",
messagingSenderId: "...",
appId: "..."
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
export const FirebaseService = {
async getProducts() {
const snapshot = await getDocs(collection(db, "products"));
return snapshot.docs.map(doc => ({ id: doc.id, ...doc.data() }));
},
// ... other methods
};- Install CLI:
npm install -g firebase-tools - Login:
firebase login - Initialize:
firebase init- Select Hosting.
- Select Firestore (to deploy rules).
- Public directory:
dist(or wherever your build goes). - Configure as SPA: Yes.
- Build:
npm run build - Deploy:
firebase deploy
The application currently contains a seed list in INITIAL_PRODUCTS. To upload these to Firestore:
- Uncomment the
FirebaseService.seedProducts()logic (if added). - Or manually add them via the Firebase Console using the structure defined in
index.tsx.
The included firestore.rules file ensures that:
- Public: Can view products, news, events.
- Public: Can create orders and job applications.
- Admin: Can manage all data.
- Framework: Tailwind CSS.
- Font: 'Cairo' (Google Fonts) for Arabic support.
- Icons: Lucide React.
- Colors: Amber/Orange palette reflecting wheat/bread.