Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hebahamdan2/draw-insight-backend
This repository provides a Node.js and Express.js backend for analyzing children's psychological health app through drawings, featuring secure APIs for managing parents, children, and drawings.
https://github.com/hebahamdan2/draw-insight-backend
backend cloudinary expressjs mongodb mongoose nodejs postman
Last synced: 5 days ago
JSON representation
This repository provides a Node.js and Express.js backend for analyzing children's psychological health app through drawings, featuring secure APIs for managing parents, children, and drawings.
- Host: GitHub
- URL: https://github.com/hebahamdan2/draw-insight-backend
- Owner: HebaHamdan2
- Created: 2024-12-04T15:22:31.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-01-17T18:58:28.000Z (7 days ago)
- Last Synced: 2025-01-17T19:47:14.086Z (7 days ago)
- Topics: backend, cloudinary, expressjs, mongodb, mongoose, nodejs, postman
- Language: JavaScript
- Homepage: https://documenter.getpostman.com/view/28559046/2sAYQakqzb
- Size: 2.9 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Draw insight - Backend
## Overview
This repository provides a backend application built with Node.js and Express.js to support an app for analyzing and recording children's psychological health based on their drawings. This backend provides secure APIs for managing parents, children, and their drawings, while integrating services for authentication, validation, email notifications, and cloud-based file storage.## Features
- **Parent Management**:
- Parents can sign up, verify their email, and sign in.
- Passwords are securely hashed using `bcryptjs`.
- JSON Web Tokens (JWT) are used for authentication.- **Child Profiles**:
- Each parent can create and manage multiple child profiles.
- Each child profile is associated with psychological health records stored via their drawings.- **Drawing Records**:
- Drawings can be uploaded for each child profile.
- The uploaded drawing is analyzed by a trained deep learning model from the previous repository can be found [here](https://github.com/HebaHamdan2/ChildDrawingClassifier-api) , and the result is recorded.- **Cloudinary Integration**:
- Profile images and drawing images are securely stored in Cloudinary.- **Validation and Middleware**:
- Input validation is implemented using `Joi`.
- Authentication and authorization are handled via custom middleware.- **Email Notifications**:
- Email confirmation and notifications are sent using `nodemailer`.## Data Models
### **Parent Model**
### Fields:
- **`username`**: Parent's username.
- **`profilePic`**: Optional profile picture.
- **`email`**: Unique email for authentication.
- **`password`**: Hashed password for security.
- **`confirmEmail`**: Email verification status.
- **`sendCode`**: Temporary code for email confirmation or password recovery.
- **`changePasswordTime`**: Timestamp of the last password change.
- **`address`**: Parent's address.### Virtual Fields:
- **`children`**: Links to the `Child` model (1-to-many relationship).### **Child Model**
### Fields:
- **`name`**: Child's name.
- **`dateOfBirth`**: Child's date of birth.
- **`gender`**: Child's gender (`Male`/`Female`).
- **`profilePic`**: Optional profile picture.
- **`parentId`**: Links to the `Parent` model.### Virtual Fields:
- **`drawings`**: Links to the `Drawing` model (1-to-many relationship).### **Drawing Model**
### Fields:
- **`imageUrl`**: Drawing's Cloudinary URL and public ID.
- **`prediction`**: Psychological analysis result.
- **`childId`**: Links to the `Child` model.
- **`parentId`**: Links to the `Parent` model.## **Relationships**
1. **Parent → Children**:
One parent can have multiple children.
- Defined via the virtual field `children` in the `Parent` model.2. **Child → Drawings**:
One child can have multiple drawings.
- Defined via the virtual field `drawings` in the `Child` model.3. **Parent → Drawings**:
Drawings are indirectly linked to parents using `parentId` in the `Drawing` model.## Technology Stack
- **Backend**: Node.js, Express.js
- **Database**: MongoDB with Mongoose for data modeling
- **Authentication**: JWT, `bcryptjs`
- **Validation**: `Joi`
- **File Upload**: `multer`, Cloudinary
- **Environment Management**: `dotenv`
- **Email Service**: `nodemailer`
- **Cross-Origin Resource Sharing**: `cors`
- **Testing & Documentation:** Postman## Setup Instructions
### 1. Clone the Repository
```bash
git clone https://github.com/HebaHamdan2/Draw-Insight-backend.git
cd Draw-Insight-backend
```
### 2. Install Dependencies
```bash
npm install
```
### 3. Environment Variables
- Create a .env file in the root directory and set the following variables:
```bash
DB=
PASSWORDSENDER=
EMAILSENDER=
SALT_ROUND=
CONFIRMEMAILSECRET=
APP_NAME=
LOGINSECRET=
BEARERKEY=
cloud_name=
api_key=
api_secret=
```
### 4. Run the Server
- Start the server in development mode:
```bash
npm run dev
```
## ContributingContributions are welcome! Please feel free to create an issue or submit a pull request for enhancements or bug fixes.