+
- [๐ฏ Project Overview](#-project-overview)
- [โจ Features](#-features)
- [๐๏ธ Architecture](#๏ธ-architecture)
@@ -44,27 +58,66 @@
- [๐ค Contributing](#-contributing)
- [๐ License](#-license)
+
+
**Greenstagram** is a revolutionary social media platform designed to connect eco-conscious individuals, promote sustainable living, and gamify environmental actions. Built with cutting-edge technologies and deployed on Microsoft Azure, it combines the best of social networking with environmental awareness.
+
| Metric | Value | Description |
|--------|-------|-------------|
| ๐ฑ **Lines of Code** | 25,000+ | TypeScript/JavaScript codebase |
@@ -77,11 +130,16 @@
---
+
+
## โจ Features
-
+

### ๐ฎ Gamification System
+
+

+
*Turn sustainability into an engaging experience*
@@ -190,6 +248,983 @@ Build meaningful connections within the eco-community:
Powerful search capabilities to find exactly what you need:
+
+
+```mermaid
+graph LR
+ A[Search Query] --> B{Search Type}
+ B -->|Users| C[๐ค User Profiles]
+ B -->|Posts| D[๐ Content Feed]
+ B -->|Tags| E[๐ท๏ธ Hashtag Topics]
+ B -->|Challenges| F[๐ฏ Active Challenges]
+
+ C --> G[Smart Filters]
+ D --> G
+ E --> G
+ F --> G
+
+ G --> H[Ranked Results]
+
+ style A fill:#22C55E,stroke:#16A34A,color:#fff
+ style H fill:#10B981,stroke:#059669,color:#fff
+ style B fill:#3B82F6,stroke:#2563EB,color:#fff
+```
+
+
+
+- **๐ฏ Multi-category Search**: Users, Posts, Hashtags, Challenges
+- **โก Real-time Results**: Instant search with debouncing
+- **๐ง Smart Filters**:
+ - Date range selection
+ - Content type filtering
+ - Difficulty level (for challenges)
+ - Location-based results
+- **๐ Trending Topics**: Discover popular environmental discussions
+- **๐ Geographic Search**: Find local eco-initiatives
+
+
+
+### ๐ค AI-Powered Features
+*Intelligent technology for environmental impact*
+
+

+
+
+
+#### ๐ฟ Plant Health Detection
+
+Revolutionary AI-powered plant identification and care system:
+
+
+
+|
+
+**Features:**
+- ๐ธ **Instant Plant ID**: Upload any plant photo
+- ๐ **PlantNet API**: 20,000+ species database
+- ๐ **Health Analysis**: AI condition assessment
+- ๐ **Care Recommendations**: Personalized guidance
+- ๐ก๏ธ **Environmental Needs**: Light, water, soil requirements
+- ๐ **Problem Detection**: Disease and pest identification
+
+**Technology Stack:**
+```typescript
+PlantNet API v2 + Custom ML Models
+โโโ Image Processing: Sharp.js
+โโโ Recognition Accuracy: 95%+
+โโโ Response Time: <2 seconds
+โโโ Species Coverage: 20,000+
+```
+
+ |
+
+
+
+
+ 
+
+**Try It Now!**
+
+ 
+
+
+
+ |
+
+
+
+#### ๐ง AI Content Moderation
+
+Maintain a positive, eco-focused community:
+
+- **๐ก๏ธ Automated Content Screening**: Flag inappropriate content
+- **๐ฑ Eco-Relevance Scoring**: Verify sustainability focus
+- **โ
Quality Assurance**: Ensure accurate environmental information
+- **๐ซ Spam Detection**: Block promotional content
+- **๐ฌ Sentiment Analysis**: Monitor community tone
+
+#### ๐ก Smart Recommendations
+
+Personalized content and challenge suggestions:
+
+```typescript
+const recommendationEngine = {
+ contentBasedFiltering: {
+ userInterests: ['recycling', 'gardening', 'zero-waste'],
+ similarContent: 'Find related eco-posts',
+ relevanceScore: 0.85
+ },
+ collaborativeFiltering: {
+ similarUsers: 'Users with matching interests',
+ trendingTopics: 'Hot environmental discussions',
+ engagementPredict: 'Likely to interact'
+ },
+ hybridApproach: {
+ personalizedFeed: 'Unique to each user',
+ diversityBoost: 'Expose to new eco-topics',
+ timingOptimization: 'Post when users are active'
+ }
+};
+```
+
+
+
+### ๐ Real-time Experience
+*Instant updates and live interactions*
+
+

+
+
+
+#### โก Socket.IO Integration
+
+Seamless real-time communication powered by WebSockets:
+
+
+๐ด Live Notifications
+
+```typescript
+// Real-time notification events
+const notificationTypes = {
+ newFollower: '๐ฅ Someone followed you',
+ likeReceived: 'โค๏ธ Your post was liked',
+ commentAdded: '๐ฌ New comment on your post',
+ challengeComplete: '๐ Challenge completed',
+ badgeEarned: '๐
New badge unlocked',
+ streakMilestone: '๐ฅ Streak milestone reached',
+ mentionReceived: '๐ข You were mentioned'
+};
+```
+
+- Instant push notifications
+- Badge unlocking animations
+- Real-time counter updates
+- Sound effects (optional)
+
+
+
+
+๐ Live Feed Updates
+
+```typescript
+// Dynamic content streaming
+socket.on('newPost', (post) => {
+ // Smooth animation insertion
+ feedStore.prependPost(post);
+ showNotificationToast('๐ New post available');
+});
+
+socket.on('postUpdate', (update) => {
+ // Live like/comment counters
+ updatePostMetrics(update);
+});
+```
+
+- New posts appear instantly
+- Live like/comment counts
+- Real-time user activity indicators
+- Smooth content transitions
+
+
+
+
+๐ฎ Live Challenges
+
+- Real-time participant counts
+- Live leaderboard updates
+- Challenge expiry countdowns
+- Instant completion notifications
+
+
+
+#### ๐ Progressive Web App (PWA)
+
+Full offline support and native-like experience:
+
+| Feature | Description | Technology |
+|---------|-------------|------------|
+| ๐ฑ **Installable** | Add to home screen | Web App Manifest |
+| ๐ **Offline Mode** | Browse cached content | Service Workers |
+| ๐ **Background Sync** | Queue actions offline | Background Sync API |
+| ๐ **Push Notifications** | Native notifications | Push API |
+| ๐ท **Camera Access** | Direct photo capture | MediaDevices API |
+| ๐ **Geolocation** | Location-based features | Geolocation API |
+| ๐พ **Local Storage** | Persist user data | IndexedDB + LocalStorage |
+
+
+
+

+
+## ๐๏ธ Architecture
+
+

+
+### ๐จ Technology Stack
+
+
+
+
+
+
+
+
+
+### Frontend
+
+
+
+**Core:**
+- โ๏ธ React 18.3.1
+- ๐ TypeScript 5.5.3
+- โก Vite 5.4.8
+- ๐จ Tailwind CSS 3.4.13
+
+**Libraries:**
+- ๐ TanStack Query v5
+- ๐ฌ Framer Motion
+- ๐จ Lucide Icons
+- ๐ก Socket.IO Client
+- ๐ React Hot Toast
+
+ |
+
+
+
+
+### Backend
+
+
+
+**Core:**
+- ๐ข Node.js 18.x
+- ๐ Express 4.21.1
+- ๐ TypeScript 5.7.2
+- ๐ MongoDB + Mongoose
+
+**Services:**
+- ๐ด Redis (Caching)
+- ๐ Socket.IO
+- ๐ JWT Authentication
+- ๐ Multer (File Upload)
+
+ |
+
+
+
+
+### DevOps
+
+
+
+**Platforms:**
+- โ๏ธ Microsoft Azure
+- ๐ณ Docker
+- ๐ง GitHub Actions
+- ๐ Azure Monitor
+
+**Tools:**
+- ๐ Application Insights
+- ๐ Azure Log Analytics
+- ๐ CI/CD Pipelines
+- ๐ Azure Key Vault
+
+ |
+
+
+
+### ๐ System Architecture Diagram
+
+```mermaid
+graph TB
+ subgraph "Client Layer"
+ A[React App
PWA + Vite]
+ B[Service Worker
Offline Support]
+ C[IndexedDB
Local Cache]
+ end
+
+ subgraph "API Gateway"
+ D[Express Server
REST + WebSocket]
+ E[Authentication
JWT Middleware]
+ F[Rate Limiting
Security Layer]
+ end
+
+ subgraph "Business Logic"
+ G[User Service
Profile Management]
+ H[Post Service
Content Management]
+ I[Challenge Service
Gamification]
+ J[AI Service
Plant Detection]
+ end
+
+ subgraph "Data Layer"
+ K[(MongoDB
Primary Database)]
+ L[(Redis
Cache + Sessions)]
+ M[Azure Blob
Media Storage]
+ end
+
+ subgraph "External Services"
+ N[PlantNet API
Plant ID]
+ O[Azure Monitor
Analytics]
+ P[Socket.IO
Real-time]
+ end
+
+ A --> D
+ B --> C
+ D --> E
+ E --> F
+ F --> G
+ F --> H
+ F --> I
+ F --> J
+
+ G --> K
+ H --> K
+ I --> K
+ G --> L
+ H --> L
+
+ J --> N
+ J --> M
+ H --> M
+
+ D --> P
+ D --> O
+
+ style A fill:#61DAFB,stroke:#21A1C4,color:#000
+ style D fill:#339933,stroke:#2E7D32,color:#fff
+ style K fill:#47A248,stroke:#3E8E41,color:#fff
+ style L fill:#DC382D,stroke:#C73028,color:#fff
+ style N fill:#22C55E,stroke:#16A34A,color:#fff
+ style O fill:#0078D4,stroke:#005A9E,color:#fff
+```
+
+### ๐ Data Flow Architecture
+
+
+๐ Request-Response Cycle
+
+```typescript
+// Complete request lifecycle with real-time updates
+
+1. Client Request
+ โโโ User Action โ React Component
+ โโโ TanStack Query โ API Call
+ โโโ Request with JWT โ Backend
+
+2. Backend Processing
+ โโโ JWT Validation โ Auth Middleware
+ โโโ Request Validation โ Zod Schema
+ โโโ Business Logic โ Service Layer
+ โโโ Database Operation โ MongoDB
+ โโโ Cache Check โ Redis
+
+3. Response & Updates
+ โโโ HTTP Response โ Client
+ โโโ Socket Emit โ Connected Clients
+ โโโ Cache Update โ Redis
+ โโโ Analytics Log โ Azure Monitor
+
+4. UI Update
+ โโโ Query Invalidation โ Refetch
+ โโโ Optimistic Update โ Instant UI
+ โโโ Animation Trigger โ Framer Motion
+ โโโ Notification โ Toast/Socket
+```
+
+
+
+---
+
+
+
+

+
+## ๐ Quick Start
+
+

+
+
+
+### โก Lightning Setup
+
+
+
+|
+
+**Prerequisites Checklist:**
+
+- [x] Node.js 18+ installed
+- [x] MongoDB 6.0+ running
+- [x] Git configured
+- [ ] Redis (optional, for caching)
+- [ ] Azure account (for deployment)
+
+ |
+
+
+**Quick Check Commands:**
+
+```bash
+node --version # v18.0.0+
+npm --version # v9.0.0+
+mongod --version # v6.0.0+
+git --version # v2.30.0+
+```
+
+ |
+
+
+
+### ๐ฅ Installation Steps
+
+
+Step 1: Clone Repository ๐ฝ
+
+```bash
+# Clone the repository
+git clone https://github.com/yourusername/greenstagram.git
+
+# Navigate to project directory
+cd greenstagram
+
+# Check repository status
+git status
+```
+
+
+

+
+
+
+
+
+Step 2: Install Dependencies ๐ฆ
+
+**Backend Setup:**
+```bash
+cd backend
+npm install
+
+# Install dev dependencies
+npm install --save-dev @types/node @types/express
+
+# Verify installation
+npm list --depth=0
+```
+
+**Frontend Setup:**
+```bash
+cd ../frontend
+npm install
+
+# Install peer dependencies if needed
+npm install --legacy-peer-deps
+
+# Verify installation
+npm list --depth=0
+```
+
+
+
+| Package Manager | Install Time | Bundle Size |
+|----------------|--------------|-------------|
+| ๐ฆ npm | ~3 min | 450 MB |
+| ๐ pnpm | ~1.5 min | 350 MB |
+| ๐งถ yarn | ~2 min | 400 MB |
+
+
+
+
+
+
+Step 3: Environment Configuration โ๏ธ
+
+**Backend `.env` file:**
+```bash
+# Create environment file
+cd backend
+cp .env.example .env
+
+# Edit with your values
+nano .env
+```
+
+```env
+# Server Configuration
+NODE_ENV=development
+PORT=5000
+FRONTEND_URL=http://localhost:3000
+
+# Database
+MONGODB_URI=mongodb://localhost:27017/greenstagram
+MONGODB_TEST_URI=mongodb://localhost:27017/greenstagram_test
+
+# Authentication
+JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
+JWT_EXPIRE=7d
+
+# Redis (Optional)
+REDIS_URL=redis://localhost:6379
+REDIS_PASSWORD=your-redis-password
+
+# PlantNet API
+PLANTNET_API_KEY=your-plantnet-api-key-here
+PLANTNET_API_URL=https://my-api.plantnet.org/v2
+
+# Azure (Production)
+AZURE_STORAGE_CONNECTION_STRING=your-azure-connection
+APPLICATIONINSIGHTS_CONNECTION_STRING=your-insights-connection
+
+# Security
+RATE_LIMIT_WINDOW_MS=900000
+RATE_LIMIT_MAX_REQUESTS=100
+CORS_ORIGIN=http://localhost:3000
+```
+
+**Frontend `.env` file:**
+```bash
+cd ../frontend
+cp .env.example .env
+nano .env
+```
+
+```env
+# API Configuration
+VITE_API_URL=http://localhost:5000/api
+VITE_SOCKET_URL=http://localhost:5000
+
+# Feature Flags
+VITE_ENABLE_PWA=true
+VITE_ENABLE_ANALYTICS=false
+
+# Environment
+VITE_NODE_ENV=development
+```
+
+
+
+> ๐ **Security Note:** Never commit `.env` files to version control!
+
+
+
+
+
+
+Step 4: Database Setup ๐๏ธ
+
+**Start MongoDB:**
+```bash
+# Windows (PowerShell)
+mongod --dbpath "C:\data\db"
+
+# macOS/Linux
+sudo mongod --dbpath /data/db
+
+# Using Docker
+docker run -d -p 27017:27017 --name greenstagram-mongo mongo:6.0
+```
+
+**Seed Initial Data (Optional):**
+```bash
+cd backend
+npm run seed
+
+# Or use MongoDB Compass to import sample data
+```
+
+
+
+```mermaid
+graph LR
+ A[MongoDB] -->|Connects| B[Backend Server]
+ B -->|Queries| A
+ B -->|Returns| C[Frontend App]
+
+ style A fill:#47A248,stroke:#3E8E41,color:#fff
+ style B fill:#339933,stroke:#2E7D32,color:#fff
+ style C fill:#61DAFB,stroke:#21A1C4,color:#000
+```
+
+
+
+
+
+
+Step 5: Start Development Servers ๐
+
+**Option 1: Separate Terminals**
+
+Terminal 1 - Backend:
+```bash
+cd backend
+npm run dev
+
+# Server running on http://localhost:5000
+# MongoDB connected successfully
+# Socket.IO initialized
+```
+
+Terminal 2 - Frontend:
+```bash
+cd frontend
+npm run dev
+
+# Vite dev server running on http://localhost:3000
+# React Fast Refresh enabled
+```
+
+**Option 2: Concurrent Start (Root Directory)**
+```bash
+# Install concurrently globally
+npm install -g concurrently
+
+# Start both servers
+npm run dev
+
+# Or use the startup script
+./start-dev.sh
+```
+
+**Option 3: Docker Compose**
+```bash
+# Start all services with Docker
+docker-compose up -d
+
+# View logs
+docker-compose logs -f
+
+# Stop services
+docker-compose down
+```
+
+
+
+

+
+### โ
Server Status Indicators
+
+| Service | Port | Status | URL |
+|---------|------|--------|-----|
+| ๐จ Frontend | 3000 | ๐ข Running | http://localhost:3000 |
+| ๐ง Backend | 5000 | ๐ข Running | http://localhost:5000/api |
+| ๐๏ธ MongoDB | 27017 | ๐ข Connected | mongodb://localhost:27017 |
+| ๐ด Redis | 6379 | ๐ก Optional | redis://localhost:6379 |
+| ๐ Socket.IO | 5000 | ๐ข Active | ws://localhost:5000 |
+
+
+
+
+
+### ๐ฏ First-Time Setup Checklist
+
+
+
+| Step | Task | Time | Status |
+|------|------|------|--------|
+| 1๏ธโฃ | Clone repository | 1 min | โฌ |
+| 2๏ธโฃ | Install dependencies | 3 min | โฌ |
+| 3๏ธโฃ | Configure environment | 2 min | โฌ |
+| 4๏ธโฃ | Start MongoDB | 1 min | โฌ |
+| 5๏ธโฃ | Launch servers | 1 min | โฌ |
+| 6๏ธโฃ | Create test account | 30 sec | โฌ |
+| 7๏ธโฃ | Test features | 2 min | โฌ |
+| **Total** | **Ready to develop** | **~10 min** | ๐ |
+
+
+
+### ๐ Verify Installation
+
+
+Run Health Checks ๐ฅ
+
+**Backend Health:**
+```bash
+curl http://localhost:5000/api/health
+
+# Expected response:
+{
+ "status": "healthy",
+ "timestamp": "2024-01-15T10:30:00Z",
+ "services": {
+ "database": "connected",
+ "redis": "connected",
+ "socketIO": "active"
+ },
+ "uptime": 3600,
+ "version": "1.0.0"
+}
+```
+
+**Frontend Health:**
+```bash
+curl http://localhost:3000
+
+# Should return HTML with React root div
+```
+
+**Database Connection:**
+```bash
+mongosh greenstagram --eval "db.stats()"
+
+# Should show database statistics
+```
+
+
+
+
+Test API Endpoints ๐งช
+
+```bash
+# Test authentication
+curl -X POST http://localhost:5000/api/auth/register \
+ -H "Content-Type: application/json" \
+ -d '{
+ "username": "eco_warrior",
+ "email": "test@greenstagram.com",
+ "password": "SecurePass123!",
+ "confirmPassword": "SecurePass123!"
+ }'
+
+# Test login
+curl -X POST http://localhost:5000/api/auth/login \
+ -H "Content-Type: application/json" \
+ -d '{
+ "email": "test@greenstagram.com",
+ "password": "SecurePass123!"
+ }'
+
+# Test protected endpoint (replace TOKEN with actual JWT)
+curl -X GET http://localhost:5000/api/users/profile \
+ -H "Authorization: Bearer YOUR_JWT_TOKEN"
+```
+
+
+
+### ๐ Troubleshooting Common Issues
+
+
+๐ด Port Already in Use
+
+**Problem:** `Error: listen EADDRINUSE: address already in use :::5000`
+
+**Solutions:**
+
+Windows:
+```powershell
+# Find process using port 5000
+netstat -ano | findstr :5000
+
+# Kill process (replace PID with actual process ID)
+taskkill /PID /F
+
+# Or change port in backend/.env
+PORT=5001
+```
+
+macOS/Linux:
+```bash
+# Find and kill process
+lsof -ti:5000 | xargs kill -9
+
+# Or use a different port
+PORT=5001 npm run dev
+```
+
+
+
+
+๐๏ธ MongoDB Connection Failed
+
+**Problem:** `MongoServerError: connect ECONNREFUSED`
+
+**Solutions:**
+
+1. **Check if MongoDB is running:**
+ ```bash
+ # Windows
+ sc query MongoDB
+
+ # macOS/Linux
+ systemctl status mongod
+ ```
+
+2. **Start MongoDB service:**
+ ```bash
+ # Windows
+ net start MongoDB
+
+ # macOS
+ brew services start mongodb-community
+
+ # Linux
+ sudo systemctl start mongod
+ ```
+
+3. **Use Docker alternative:**
+ ```bash
+ docker run -d -p 27017:27017 --name mongo mongo:6.0
+ ```
+
+4. **Check connection string in `.env`:**
+ ```env
+ MONGODB_URI=mongodb://localhost:27017/greenstagram
+ ```
+
+
+
+
+๐ฆ Dependency Installation Errors
+
+**Problem:** `npm ERR! peer dependency conflicts`
+
+**Solutions:**
+
+```bash
+# Clear npm cache
+npm cache clean --force
+
+# Delete node_modules and package-lock.json
+rm -rf node_modules package-lock.json
+
+# Reinstall with legacy peer deps
+npm install --legacy-peer-deps
+
+# Or use --force flag
+npm install --force
+
+# Alternative: Use yarn
+yarn install
+```
+
+
+
+
+๐ CORS Errors
+
+**Problem:** `Access to fetch blocked by CORS policy`
+
+**Solutions:**
+
+1. **Check backend CORS configuration:**
+ ```typescript
+ // backend/src/index.ts
+ const corsOptions = {
+ origin: process.env.FRONTEND_URL || 'http://localhost:3000',
+ credentials: true
+ };
+ ```
+
+2. **Verify frontend API URL:**
+ ```env
+ # frontend/.env
+ VITE_API_URL=http://localhost:5000/api
+ ```
+
+3. **Ensure credentials are included:**
+ ```typescript
+ // frontend/src/services/api.ts
+ const response = await fetch(url, {
+ credentials: 'include',
+ headers: { ... }
+ });
+ ```
+
+
+
+
+โ๏ธ React Build Errors
+
+**Problem:** TypeScript compilation errors
+
+**Solutions:**
+
+```bash
+# Update TypeScript
+npm install typescript@latest --save-dev
+
+# Clear Vite cache
+rm -rf node_modules/.vite
+
+# Restart dev server
+npm run dev
+
+# Check for missing types
+npm install --save-dev @types/react @types/react-dom
+```
+
+
+
+---
+
+
+
+

+
+## ๐ป Development Setup
+
+

+
+
+
+### ๐ ๏ธ Development Tools
+
+
+
+
+
+
+
+**Code Editor**
+
+[VS Code](https://code.visualstudio.com/)
+
+Recommended Extensions:
+- ESLint
+- Prettier
+- TypeScript
+- Tailwind CSS IntelliSense
+
+ |
+
+
+
+
+**API Testing**
+
+[Postman](https://www.postman.com/)
+[Thunder Client](https://www.thunderclient.com/)
+
+Test all API endpoints
+with collections
+
+ |
+
+
+
+
+**Database GUI**
+
+[MongoDB Compass](https://www.mongodb.com/products/compass)
+
+Visual interface for
+MongoDB operations
+
+ |
+
+
+
+
+**Version Control**
+
+[Git](https://git-scm.com/)
+[GitHub Desktop](https://desktop.github.com/)
+
+Source control
+and collaboration
+
+ |
+
+
+
- **๐ Multi-faceted Search**:
- Posts by content, hashtags, location
- Users by username, interests, eco-level