Spaces:
Sleeping
Sleeping
| # SnapLocal Implementation Guide | |
| ## β MVP Features Implemented (Complete) | |
| ### Backend (Node.js + MongoDB) | |
| #### 1. **Package System** β | |
| - **Model**: `server/src/models/Package.js` | |
| - **Routes**: `server/src/routes/packageRoutes.js` | |
| - **Endpoints**: | |
| - `GET /api/packages/photographer/:photographerId` - Get photographer's packages | |
| - `GET /api/packages/:id` - Get single package | |
| - `POST /api/packages` - Create new package (auth required) | |
| - `PUT /api/packages/:id` - Update package (auth required) | |
| - `DELETE /api/packages/:id` - Delete package (auth required) | |
| #### 2. **Photographer Verification** β | |
| - **Model**: `server/src/models/Verification.js` | |
| - **Routes**: `server/src/routes/verificationRoutes.js` | |
| - **Endpoints**: | |
| - `GET /api/verification/status/:photographerId` - Get verification status | |
| - `POST /api/verification/submit` - Upload documents (auth required) | |
| - `POST /api/verification/:verificationId/approve` - Admin approve | |
| - `POST /api/verification/:verificationId/reject` - Admin reject | |
| #### 3. **Photo Delivery** β | |
| - **Model**: `server/src/models/PhotoDelivery.js` | |
| - **Routes**: `server/src/routes/deliveryRoutes.js` | |
| - **Endpoints**: | |
| - `GET /api/delivery/booking/:bookingId` - Get delivery status | |
| - `POST /api/delivery/booking/:bookingId` - Create delivery record | |
| - `POST /api/delivery/:deliveryId/upload` - Upload photos (auth required) | |
| - `POST /api/delivery/:deliveryId/complete` - Mark as delivered | |
| - `POST /api/delivery/:deliveryId/request-revision` - Request revisions | |
| #### 4. **Invoice Generator** β | |
| - **Model**: `server/src/models/Invoice.js` | |
| - **Routes**: `server/src/routes/invoiceRoutes.js` | |
| - **Endpoints**: | |
| - `GET /api/invoices/:id` - Get invoice | |
| - `GET /api/invoices/user/:userId` - Get user's invoices | |
| - `POST /api/invoices` - Create invoice | |
| - `PUT /api/invoices/:id/payment` - Update payment status | |
| - `GET /api/invoices/:id/download` - Download invoice | |
| #### 5. **Smart Tags (Enhanced Search)** β | |
| - Implemented in `Photographer.js` model with tags array | |
| - Frontend Search component with tag filters | |
| #### 6. **Additional Models Created** β | |
| - **Loyalty Points** (`server/src/models/LoyaltyPoints.js`) | |
| - **Report System** (`server/src/models/Report.js`) | |
| - **Trip Planner** (`server/src/models/TripPlan.js`) | |
| - **Dynamic Pricing** (`server/src/models/DynamicPrice.js`) | |
| - **Deals/Discounts** (`server/src/models/Deal.js`) | |
| --- | |
| ### Frontend (React + Vite) | |
| #### Components Created β | |
| **Photographer Dashboard Components:** | |
| - `PackagePanel.jsx` - Create and manage packages | |
| - `PackageCard.jsx` - Individual package card display | |
| - `CreatePackageModal.jsx` - Modal form for creating/editing packages | |
| - `VerificationPanel.jsx` - Verification document upload and status | |
| - `DeliveryPanel.jsx` - Photo upload and delivery management | |
| - `InvoiceView.jsx` - Invoice display and download | |
| **Customer Dashboard Components:** | |
| - `TrendingSpots.jsx` - Popular photography locations | |
| - `LastMinuteDeals.jsx` - Time-limited discount offers | |
| - `Leaderboard.jsx` - Top photographers by rating | |
| - `ShootTimeline.jsx` - Booking progress timeline | |
| **Utilities:** | |
| - `src/utils/invoiceGenerator.js` - Invoice HTML generation and PDF export | |
| --- | |
| ## π± Technology Stack | |
| ### Backend | |
| - **Express.js** - REST API server | |
| - **MongoDB** - Database | |
| - **Mongoose** - ODM | |
| - **JWT** - Authentication | |
| - **Socket.io** - Real-time messaging (already in place) | |
| ### Frontend | |
| - **React 19.2.4** - UI framework | |
| - **Vite 8.0.0** - Build tool | |
| - **Tailwind CSS 4.2.1** - Styling | |
| - **Lucide React** - Icons | |
| - **Axios** - HTTP client | |
| --- | |
| ## π How to Run | |
| ### Prerequisites | |
| - Node.js 18+ | |
| - MongoDB running locally or cloud URL in `.env` | |
| - npm or yarn | |
| ### 1. Install Dependencies | |
| ```bash | |
| # Backend | |
| cd server | |
| npm install | |
| # Frontend | |
| cd ../client | |
| npm install | |
| ``` | |
| ### 2. Configure Environment | |
| Create `server/.env`: | |
| ```env | |
| MONGODB_URI=mongodb://localhost:27017/snaplocal | |
| PORT=5000 | |
| JWT_SECRET=your_secret_key | |
| ``` | |
| ### 3. Start Development Servers | |
| ```bash | |
| # Terminal 1: Backend | |
| cd server | |
| npm run dev | |
| # Server runs on http://localhost:5000 | |
| # Terminal 2: Frontend | |
| cd client | |
| npm run dev | |
| # Client runs on http://localhost:5173 | |
| ``` | |
| --- | |
| ## π API Usage Examples | |
| ### Create a Package (Photographer) | |
| ```javascript | |
| // POST http://localhost:5000/api/packages | |
| { | |
| "name": "Premium Wedding Package", | |
| "description": "8 hours coverage with 300+ edited photos", | |
| "price": 15000, | |
| "priceUnit": "session", | |
| "duration": 8, | |
| "deliverables": { | |
| "numPhotos": 350, | |
| "numEdited": 200, | |
| "numLocations": 2, | |
| "includesAlbum": true | |
| }, | |
| "tags": ["wedding", "bride", "groom"] | |
| } | |
| ``` | |
| ### Submit Verification | |
| ```javascript | |
| // POST http://localhost:5000/api/verification/submit | |
| { | |
| "idDocumentUrl": "https://example.com/aadhar.jpg", | |
| "portfolioUrls": [ | |
| "https://example.com/photo1.jpg", | |
| "https://example.com/photo2.jpg" | |
| ] | |
| } | |
| ``` | |
| ### Upload Photos for Delivery | |
| ```javascript | |
| // POST http://localhost:5000/api/delivery/{deliveryId}/upload | |
| { | |
| "photoUrls": [ | |
| "https://example.com/photo1.jpg", | |
| "https://example.com/photo2.jpg", | |
| // ... more photos | |
| ] | |
| } | |
| ``` | |
| ### Create Invoice | |
| ```javascript | |
| // POST http://localhost:5000/api/invoices | |
| { | |
| "bookingId": "booking_id_here", | |
| "photographerId": "photographer_id", | |
| "customerId": "customer_id", | |
| "items": [ | |
| { | |
| "description": "Premium Wedding Photography", | |
| "quantity": 1, | |
| "unitPrice": 15000, | |
| "total": 15000 | |
| } | |
| ], | |
| "subtotal": 15000, | |
| "tax": 2700, | |
| "taxRate": 18, | |
| "totalAmount": 17700 | |
| } | |
| ``` | |
| --- | |
| ## π― Dashboard Features | |
| ### Photographer Dashboard | |
| 1. **Overview** - Statistics (bookings, revenue, pending, rating) | |
| 2. **My Profile** - Edit bio, specialty, rate, experience | |
| 3. **Portfolio** - Upload images/videos | |
| 4. **Packages** β - Create and manage service packages | |
| 5. **Verification** β - Upload documents for verification badge | |
| 6. **Availability** - Set weekly schedule | |
| 7. **Bookings** - Manage booking requests with timeline | |
| 8. **Photo Delivery** β - Upload and deliver photos to customers | |
| 9. **Reports** - View and respond to customer complaints | |
| ### Customer Dashboard | |
| 1. **Search** - Find photographers (enhanced with tag filters) | |
| 2. **Trending Spots** β - Popular photography locations | |
| 3. **Last-Minute Deals** β - Time-limited discounts | |
| 4. **Nearby Photographers** - Map view with location filtering | |
| 5. **My Bookings** - Manage reservations and download photos | |
| 6. **Leaderboard** β - Top-rated photographers | |
| 7. **Loyalty/Rewards** - Points and tier benefits | |
| 8. **Trip Planner** - Plan photo shoot trips | |
| --- | |
| ## π File Structure Summary | |
| ``` | |
| server/src/ | |
| βββ models/ | |
| β βββ Package.js β NEW | |
| β βββ Verification.js β NEW | |
| β βββ PhotoDelivery.js β NEW | |
| β βββ Invoice.js β NEW | |
| β βββ LoyaltyPoints.js β NEW | |
| β βββ Report.js β NEW | |
| β βββ TripPlan.js β NEW | |
| β βββ DynamicPrice.js β NEW | |
| β βββ Deal.js β NEW | |
| βββ routes/ | |
| β βββ packageRoutes.js β NEW | |
| β βββ verificationRoutes.jsβ NEW | |
| β βββ deliveryRoutes.js β NEW | |
| β βββ invoiceRoutes.js β NEW | |
| β βββ reportRoutes.js β NEW | |
| β βββ loyaltyRoutes.js β NEW | |
| β βββ tripPlanRoutes.js β NEW | |
| β βββ dealRoutes.js β NEW | |
| βββ index.js β UPDATED | |
| client/src/ | |
| βββ components/ | |
| β βββ PackagePanel.jsx β NEW | |
| β βββ PackageCard.jsx β NEW | |
| β βββ CreatePackageModal.jsxβ NEW | |
| β βββ VerificationPanel.jsx β NEW | |
| β βββ DeliveryPanel.jsx β NEW | |
| β βββ InvoiceView.jsx β NEW | |
| β βββ TrendingSpots.jsx β NEW | |
| β βββ LastMinuteDeals.jsx β NEW | |
| β βββ Leaderboard.jsx β NEW | |
| β βββ ShootTimeline.jsx β NEW | |
| βββ utils/ | |
| βββ invoiceGenerator.js β NEW | |
| ``` | |
| --- | |
| ## β¨ Next Steps (Phase 2+) | |
| ### Advanced Features | |
| 1. **AI-Powered Features** | |
| - Style matching (upload reference photo for similar photographers) | |
| - Dynamic pricing suggestions based on demand | |
| - Smart recommendations | |
| 2. **Enhanced Search** | |
| - Geolocation-based photographer search | |
| - Advanced filters (availability, price range, ratings, tags) | |
| 3. **Performance Analytics** | |
| - Charts and graphs for photographer earnings/bookings | |
| - Customer analytics for trends | |
| 4. **Trip Planning** | |
| - Itinerary builder | |
| - Recommended photography spots | |
| - Travel packages | |
| 5. **Additional Features** | |
| - Watermark protection for portfolio images | |
| - Live photographer availability map | |
| - Video introductions for photographers | |
| - Social sharing buttons | |
| --- | |
| ## π Security Notes | |
| - All protected routes require JWT authentication | |
| - Password hashing with bcryptjs (already implemented) | |
| - CORS enabled for development | |
| - Input validation needed (in production) | |
| - Rate limiting recommended for API endpoints | |
| --- | |
| ## π Database Schema Overview | |
| ### Package | |
| ``` | |
| { | |
| photographerId, name, description, price, priceUnit, duration, | |
| deliverables: { numPhotos, numEdited, numLocations, includesAlbum }, | |
| active, bookingCount, tags, timestamps | |
| } | |
| ``` | |
| ### Verification | |
| ``` | |
| { | |
| photographerId, status (pending|verified|rejected), | |
| idDocument, portfolioSamples[], submittedAt, verifiedAt, | |
| adminNotes, rejectionReason, timestamps | |
| } | |
| ``` | |
| ### Invoice | |
| ``` | |
| { | |
| invoiceNumber, bookingId, photographerId, customerId, | |
| items[], subtotal, tax, taxRate, discount, totalAmount, | |
| paymentStatus, paidAt, timestamps | |
| } | |
| ``` | |
| ### PhotoDelivery | |
| ``` | |
| { | |
| bookingId, photographerId, customerId, photos[], | |
| status (pending|partially_delivered|delivered|revision_requested), | |
| deliveredAt, downloadLink, linkExpiresAt, revisionNotes, timestamps | |
| } | |
| ``` | |
| --- | |
| ## π Code Examples | |
| ### Use PackagePanel in Dashboard | |
| ```jsx | |
| import PackagePanel from '../components/PackagePanel'; | |
| export default function PhotographerDashboard() { | |
| const { user } = useAuth(); | |
| return <PackagePanel photographerId={user.id} />; | |
| } | |
| ``` | |
| ### Use DeliveryPanel in Booking Page | |
| ```jsx | |
| import DeliveryPanel from '../components/DeliveryPanel'; | |
| export default function BookingDetail({ bookingId }) { | |
| return ( | |
| <DeliveryPanel | |
| bookingId={bookingId} | |
| photographerId={currentPhotographerId} | |
| role="photographer" | |
| /> | |
| ); | |
| } | |
| ``` | |
| ### Generate and Download Invoice | |
| ```jsx | |
| import { downloadInvoiceAsPDF } from '../utils/invoiceGenerator'; | |
| const handleDownload = (invoice, photographer, customer) => { | |
| downloadInvoiceAsPDF(invoice, photographer, customer); | |
| }; | |
| ``` | |
| --- | |
| ## π Troubleshooting | |
| ### Port Already in Use | |
| ```bash | |
| # Kill process on port 5000 | |
| lsof -i :5000 | |
| kill -9 <PID> | |
| ``` | |
| ### MongoDB Connection Failed | |
| - Ensure MongoDB is running: `mongod` | |
| - Check MONGODB_URI in `.env` | |
| - Verify connection string format | |
| ### Components Not Loading | |
| - Clear Vite cache: `rm -rf client/node_modules/.vite` | |
| - Restart dev server | |
| --- | |
| ## π Future Enhancements | |
| - [ ] Payment gateway integration (Stripe/Razorpay) | |
| - [ ] Email notifications for bookings | |
| - [ ] SMS alerts for photographers | |
| - [ ] Multi-language support | |
| - [ ] Mobile app (React Native) | |
| - [ ] Admin dashboard | |
| - [ ] Analytics and reporting | |
| - [ ] Advanced booking calendar with time slots | |
| - [ ] Subscription tiers for photographers | |
| - [ ] Automated invoice generation and payment reminders | |
| --- | |
| ## π Support | |
| For issues or questions: | |
| 1. Check the Feature Implementation Map: `/FEATURE_IMPLEMENTATION_MAP.md` | |
| 2. Review API routes in respective `server/src/routes/` files | |
| 3. Check component prop requirements in `client/src/components/` | |
| --- | |
| **Version**: 1.0.0 MVP | |
| **Last Updated**: March 18, 2026 | |
| **Status**: β Complete and Running | |