A social media platform for pet lovers built with Node.js, Express, Firebase, and EJS.
- 🐾 Social Feed: Share posts, photos, and videos of your pets
- 💬 Comments & Likes: Engage with the community
- 👥 User Profiles: Customizable profiles with cover photos
- 🔍 Search: Find other pet owners and posts
- 🛒 Marketplace: Buy and sell pet-related items
- 🔔 Notifications: Stay updated with real-time notifications
- 📱 Responsive Design: Works on desktop and mobile devices
- Backend: Node.js, Express.js
- Database: Firebase Firestore
- Storage: Firebase Storage (for images and videos)
- Authentication: JWT (JSON Web Tokens)
- Template Engine: EJS
- Styling: Bootstrap 5
- Deployment: Vercel (serverless functions)
- Node.js >= 20.0.0
- npm or yarn
- Firebase project with:
- Firestore Database enabled
- Storage enabled
- Service Account with Storage Admin permissions
-
Clone the repository:
git clone <repository-url> cd pethud2.0
-
Install dependencies:
npm install
-
Set up environment variables:
cp .env.example .env.local
Edit
.env.localand add your Firebase credentials:FIREBASE_SERVICE_ACCOUNT: Your Firebase service account JSON (as a single-line string)FIREBASE_PROJECT_ID: Your Firebase project IDFIREBASE_STORAGE_BUCKET: Your Firebase Storage bucket nameJWT_SECRET: A strong random string for JWT signing- Other optional variables (see
.env.example)
-
Configure Firebase Storage CORS:
node setup-cors.js
This is required for direct browser uploads (especially videos). See CORS_SETUP.md for details.
-
Start the development server:
npm run dev
Or:
npm start(usesPORTfrom env, default 3000). On macOS you can use./run-pethub.shto install deps and start. -
Open your browser: Navigate to
http://localhost:4000(or the port set byPORT)
pethud2.0/
├── controller/ # Route controllers
│ ├── postController.js
│ ├── profileController.js
│ ├── marketplaceController.js
│ └── ...
├── routes/ # Express routes
│ ├── posts.js
│ ├── users.js
│ └── ...
├── views/ # EJS templates
│ ├── index.ejs
│ ├── profile.ejs
│ └── ...
├── middlewares/ # Express middlewares
│ ├── auth.js
│ └── ...
├── firebase/ # Firebase configuration
│ └── config.js
├── utils/ # Utility functions
│ ├── firestoreHelpers.js
│ └── mailer.js
├── public/ # Static assets (only these are served; do not duplicate under project root)
│ ├── images/
│ └── stylesheets/
├── setup-cors.js # One-time CORS setup for Firebase Storage
├── configure-cors.js # Alternative CORS setup (requires gcloud CLI)
└── bin/www # Server entry (npm start)
See .env.example for all available environment variables. Key variables:
FIREBASE_SERVICE_ACCOUNT: Firebase service account JSON (required)FIREBASE_PROJECT_ID: Firebase project IDFIREBASE_STORAGE_BUCKET: Firebase Storage bucket nameJWT_SECRET: Secret key for JWT tokensGMAIL_USER: Gmail address for sending emailsGMAIL_APP_PASSWORD: Gmail app password
See VERCEL_SETUP.md for detailed deployment instructions.
Quick steps:
- Install Vercel CLI:
npm i -g vercel - Login:
vercel login - Link project:
vercel link - Set environment variables in Vercel Dashboard
- Deploy:
vercel --prod
Before deploying, make sure to configure CORS on your Firebase Storage bucket:
node setup-cors.jsSee CORS_SETUP.md for detailed instructions.
The application supports direct client-side uploads to Firebase Storage to avoid Vercel's 4.5MB payload limit. Large files (especially videos) are uploaded directly from the browser to Firebase Storage.
Uses JWT (JSON Web Tokens) for authentication. Tokens are stored in HTTP-only cookies for security.
Uses Firebase Firestore for data storage:
users: User profiles and settingsposts: User posts with mediamarketplace_ads: Marketplace listings- Other collections as needed
npm run dev: Start development servernpm start: Start production servernode setup-cors.js: Configure CORS for Firebase Storage
- ✅ Never commit
.env.localor Firebase service account keys - ✅ Use strong
JWT_SECRETin production - ✅ Configure CORS with specific origins in production
- ✅ Keep Firebase service account keys secure
- ✅ Use environment variables for all sensitive data
If you get CORS errors when uploading files:
- Run
node setup-cors.jsto configure CORS - Wait 2-5 minutes for changes to propagate
- Clear browser cache
- See CORS_SETUP.md for detailed help
- Make sure
FIREBASE_SERVICE_ACCOUNTis set correctly - Verify your service account has Storage Admin permissions
- Check that Firestore and Storage are enabled in Firebase Console
- Check file size limits (50MB max)
- Verify CORS is configured
- Check browser console for specific error messages
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
[Add your license here]
For issues and questions, please open an issue on GitHub.