DataInsightHub is a Node.js backend application designed to process and analyze personal user data to generate personalized insights and recommendations. It features secure user authentication, data upload and storage, custom algorithms for data analysis, and optional real-time notifications with third-party API integrations. This project is perfect for showcasing backend development, particularly in handling sensitive user data and generating valuable insights.
- Secure User Authentication: Register and login using JWT-based authentication.
- Data Upload and Storage: Upload user data to be analyzed and stored securely.
- Personalized Insights: Generate data-driven insights and recommendations for users.
- Real-Time Notifications: Optional integration for real-time notifications (e.g., email alerts).
- Third-Party API Integrations: Optional integrations with external APIs for enriched data.
- Node.js: Runtime for the backend application.
- Express: Web framework for building the API.
- MongoDB: NoSQL database for storing user data.
- JWT: Token-based authentication for secure access.
- bcryptjs: Password hashing for security.
- dotenv: Manages environment variables.
- passport: User authentication middleware.
- Node.js and npm must be installed on your machine.
-
Clone the repository:
git clone https://github.com/Nuraj250/DataInsightHub.git
-
Navigate to the project directory:
cd DataInsightHub
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env
file in the root directory and add the following:DB_URI=mongodb://localhost:27017/data-insight-hub JWT_SECRET=your_jwt_secret SESSION_SECRET=your_session_secret
-
Run the application:
npm start
The server will run on port
5000
by default.
-
POST /auth/register: Register a new user.
- Body:
{ "username": "user1", "password": "password123" }
- Response:
{ "token": "JWT_TOKEN" }
- Body:
-
POST /auth/login: Login a user.
- Body:
{ "username": "user1", "password": "password123" }
- Response:
{ "token": "JWT_TOKEN" }
- Body:
-
POST /data/upload: Upload user data (authenticated).
- Body:
{ "data": { "activityLevel": 7, "steps": 12000 } }
- Response:
{ "message": "Data uploaded successfully", "data": { "activityLevel": 7, "steps": 12000 } }
- Body:
-
GET /data: Retrieve uploaded data (authenticated).
- Response:
[{ "activityLevel": 7, "steps": 12000 }]
- Response:
- GET /insights: Generate insights based on uploaded data (authenticated).
- Response:
[{ "recommendation": "Increase your activity level." }]
- Response:
DataInsightHub
├── config
│ ├── db.js # MongoDB connection setup
│ ├── jwt.js # JWT generation and verification
│ └── passport.js # Passport authentication strategy
├── controllers
│ ├── authController.js # Handles registration and login
│ ├── dataController.js # Handles data upload and retrieval
│ └── insightsController.js # Handles insights generation
├── middleware
│ ├── authMiddleware.js # JWT authentication middleware
│ └── validationMiddleware.js # Data validation middleware
├── models
│ ├── userModel.js # User schema for MongoDB
│ └── dataModel.js # Data schema for MongoDB
├── routes
│ ├── authRoutes.js # Authentication routes
│ └── dataRoutes.js # Data handling routes
├── services
│ ├── insightService.js # Service to generate insights from data
│ └── dataService.js # Data processing service
├── utils
│ ├── generateToken.js # Token generation utility
│ └── logger.js # Logging utility
├── .env # Environment variables
├── .gitignore # Git ignore file to exclude node_modules
├── app.js # Main application entry point
├── package.json # Project metadata and dependencies
└── README.md # Project documentation
To contribute:
- Fork the repository.
- Create a feature branch.
- Commit your changes.
- Push to your fork and submit a pull request.
MIT License.