## ποΈ Architecture
The project follows a modern full-stack architecture:
- *Frontend*: React.js application with component-based architecture
- *Backend*: Node.js/Express.js REST API with JWT authentication
- *AI Integration*: Local LM Studio integration for environmental AI assistance
- *Database*: MongoDB with Mongoose ODM
## π Project Structure
greentogether/
βββ backend/ # Node.js/Express backend
β βββ src/ # Source code
β βββ .env # Environment configuration
β βββ package.json # Backend dependencies
βββ frontend/ # React frontend
β βββ src/ # React components and pages
β βββ public/ # Static assets
β βββ package.json # Frontend dependencies
βββ README.md # This file
## π Getting Started
### Prerequisites
- Node.js (v14 or higher)
- npm or yarn
- MongoDB (local or cloud instance)
- LM Studio (for AI features)
### Installation
1. *Clone the repository*
Β bash
Β git clone
Β cd greentogether
Β
2. *Install backend dependencies*
Β bash
Β cd backend
Β npm install
Β
3. *Install frontend dependencies*
Β bash
Β cd ../frontend
Β npm install
Β
4. *Configure environment variables*
Β
Β Backend configuration (backend/.env):
Β env
Β PORT=4000
Β NODE_ENV=development
Β JWT_SECRET=your-jwt-secret-key
Β JWT_EXPIRE=24h
Β FRONTEND_URL=http://localhost:3000
Β
### Running the Application
#### Development Mode (Full Stack)
bash
cd backend
npm run dev:full
This command starts both the backend server and frontend development server concurrently.
#### Individual Services
*Backend only:*
bash
cd backend
npm run dev
*Frontend only:*
bash
cd frontend
npm start
*Production build:*
bash
cd backend
npm run build
npm start
## π§ Available Scripts
### Backend Scripts
- npm start - Start production server
- npm run dev - Start development server with nodemon
- npm test - Run Jest tests
- npm run build - Build frontend for production
- npm run dev:full - Start both backend and frontend concurrently
### Frontend Scripts
- npm start - Start development server
- npm run build - Build for production
- npm test - Run tests
## π Key Features
### Authentication & User Management
- JWT-based authentication system
- User profile management
- Secure password handling with bcryptjs
### AI Integration (GreenieAI)
- Local LM Studio integration for environmental AI chat
- RESTful API endpoint at /api/greenieai/chat
- Configurable AI parameters (temperature, max_tokens)
### Environmental Initiatives
- Community initiative tracking
- User engagement features
- Plant management system
### Frontend Components
- Responsive React components
- Video logo with animations
- Social media integration
- Contact information display
## π API Endpoints
### Authentication
- POST /api/auth/login - User login
- POST /api/auth/register - User registration
### User Management
- GET /api/users/profile - Get user profile (authenticated)
- PUT /api/users/profile - Update user profile (authenticated)
### AI Chat
- POST /api/greenieai/chat - Chat with GreenieAI
### Initiatives
- GET /api/initiatives - Get environmental initiatives
## π οΈ Technology Stack
### Backend
- *Express.js* - Web framework
- *MongoDB/Mongoose* - Database and ODM
- *JWT* - Authentication
- *bcryptjs* - Password hashing
- *CORS* - Cross-origin resource sharing
- *dotenv* - Environment configuration
- *express-validator* - Input validation
### Frontend
- *React.js* - UI framework
- *CSS3* - Styling with custom components
- *Font Awesome* - Icons for social links
### Development Tools
- *nodemon* - Development server auto-restart
- *concurrently* - Run multiple commands
- *Jest* - Testing framework
## π Environment Configuration
The application uses environment variables for configuration:
- PORT - Backend server port (default: 4000)
- NODE_ENV - Environment mode
- JWT_SECRET - Secret key for JWT tokens
- JWT_EXPIRE - JWT token expiration time
- FRONTEND_URL - Frontend URL for CORS
## π€ AI Integration Setup
To use the GreenieAI features:
1. Install and configure LM Studio
2. Start LM Studio server on http://localhost:1234
3. Ensure the AI model is loaded and accessible
4. The backend will automatically connect to LM Studio via the /v1/chat/completions endpoint
## π§ͺ Testing
Run tests for the backend:
bash
cd backend
npm test
## π Deployment
1. Build the frontend:
Β bash
Β cd backend
Β npm run build
Β
2. Start the production server:
Β bash
Β npm start
Β
## π€ Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request
## π License
This project is licensed under the MIT License - see the LICENSE file for details.
*GreenTogether* - Building a sustainable future, one initiative at a time. ππ