# EduCat - AI-Powered Note Revision Platform

EduCat is a modern web application that helps students improve their study notes using AI. Built with Node.js, Express, and EJS, it features file upload capabilities, AI-powered note revision, and an interactive chatbot.

## Features

- � **User Authentication**: Secure login and registration system
- �📁 **File Upload**: Upload notes in various formats (PDF, DOC, TXT, images)
- 🤖 **AI-Powered Revision**: Automatically improve, summarize, and generate study questions
- 💬 **Interactive Chatbot**: Chat with AI for study assistance
- 📊 **Dashboard**: Manage and track your uploaded notes
- 🎨 **Modern UI**: Beautiful, responsive design with Bootstrap
- 🔗 **Flowise Integration**: Connected to Flowise at https://flowise.suika.cc/

## Technologies Used

- **Backend**: Node.js, Express.js
- **Frontend**: EJS templates, Bootstrap 5, Font Awesome
- **Authentication**: bcrypt for password hashing, express-session
- **File Handling**: Multer for file uploads
- **AI Integration**: Flowise API integration
- **Session Management**: Express Session with flash messages
- **Styling**: Custom CSS with Bootstrap

## Installation

1. **Clone the repository**:
   ```bash
   git clone <repository-url>
   cd EduCat
   ```

2. **Install dependencies**:
   ```bash
   npm install
   ```

3. **Configure environment variables**:
   - Copy `.env.example` to `.env` (if exists) or create a new `.env` file
   - Update the following variables:
     ```
     PORT=3000
     SESSION_SECRET=your-secret-key-here
     FLOWISE_API_URL=https://flowise.suika.cc/api/v1/prediction
     FLOWISE_CHATFLOW_ID=your-chatflow-id-here
     ```

4. **Set up your Flowise chatflow**:
   - Go to https://flowise.suika.cc/
   - Create or find your chatflow
   - Copy the chatflow ID and update it in the `.env` file

5. **Start the application**:
   ```bash
   npm start
   ```
   
   For development with auto-reload:
   ```bash
   npm run dev
   ```

6. **Access the application**:
   - Open your browser and navigate to `http://localhost:3000`

## Usage

### Authentication
1. Visit `http://localhost:3000`
2. Click "Login" or "Register" to create an account
3. Use demo accounts:
   - **Admin**: username `admin`, password `password`
   - **Student**: username `student`, password `password`

### Uploading Notes
1. After logging in, click "Upload Notes" in the navigation
2. Drag and drop your file or click to browse
3. Select a file (PDF, DOC, TXT, or image)
4. Click "Upload & Process"

### Revising Notes
1. Go to your Dashboard to see uploaded files
2. Click "Revise with AI" on any file
3. Choose revision type:
   - **Improve & Enhance**: Makes notes more comprehensive
   - **Summarize**: Creates concise summaries
   - **Generate Questions**: Creates study questions
4. Click "Revise with AI" to process

### Using the Chatbot
1. Navigate to the "Chat" section
2. Type your questions about study materials or academic topics
3. Get instant AI-powered responses

## Project Structure

```
EduCat/
├── public/
│   ├── css/
│   │   └── style.css
│   ├── js/
│   │   └── main.js
│   └── images/
│       └── logo.png
├── views/
│   ├── partials/
│   │   ├── header.ejs
│   │   └── footer.ejs
│   ├── index.ejs
│   ├── upload.ejs
│   ├── revise.ejs
│   ├── chat.ejs
│   ├── dashboard.ejs
│   └── error.ejs
├── uploads/
├── server.js
├── package.json
└── .env
```

## API Endpoints

- `GET /` - Home page
- `GET /upload` - File upload page
- `POST /upload` - Handle file uploads
- `GET /revise/:fileId` - Note revision page
- `POST /api/revise` - AI revision endpoint
- `GET /chat` - Chat interface
- `POST /api/chat` - Chat API endpoint
- `GET /dashboard` - User dashboard

## Configuration

### Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `PORT` | Server port | `3000` |
| `SESSION_SECRET` | Session encryption key | `educat-secret-key` |
| `FLOWISE_API_URL` | Flowise API base URL | `https://flowise.suika.cc/api/v1/prediction` |
| `FLOWISE_CHATFLOW_ID` | Your Flowise chatflow ID | Required |

### File Upload Settings

- **Maximum file size**: 10MB
- **Allowed formats**: PDF, DOC, DOCX, TXT, JPG, JPEG, PNG, GIF
- **Upload directory**: `uploads/`

## Customization

### Styling
- Edit `public/css/style.css` to customize the appearance
- The design uses Bootstrap 5 with custom CSS variables

### AI Integration
- Modify the Flowise API calls in `server.js`
- Update prompts in the `/api/revise` endpoint
- Customize chat responses in the `/api/chat` endpoint

### Adding Features
- Add new routes in `server.js`
- Create corresponding EJS templates in `views/`
- Add client-side JavaScript in `public/js/main.js`

## Troubleshooting

### Common Issues

1. **File upload fails**:
   - Check file size (max 10MB)
   - Verify file format is supported
   - Ensure `uploads/` directory exists

2. **AI responses don't work**:
   - Verify Flowise API URL is correct
   - Check if your chatflow ID is valid
   - Ensure Flowise server is accessible

3. **Session issues**:
   - Verify SESSION_SECRET is set
   - Check if sessions are properly configured

### Development

To run in development mode with auto-reload:
```bash
npm install -g nodemon
npm run dev
```

## Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Test thoroughly
5. Submit a pull request

## License

This project is licensed under the MIT License.

## Support

For support or questions, please contact the EduCat development team.

---

**Made with ❤️ by the EduCat Team**
