Skip to content

ADI4533/parent_alert_system

Repository files navigation

Parent Alert System with MySQL Database

A comprehensive child safety monitoring dashboard with MySQL database integration for managing children profiles and alerts.

Features

πŸ›‘οΈ Core Monitoring

  • Real-time Child Status Tracking - Monitor children's safety status and location
  • Alert Management - Comprehensive alert system with priority levels
  • Activity Logging - Track all system activities and events
  • Dashboard Overview - Real-time statistics and monitoring

πŸ‘₯ Children Management

  • Add/Edit/Delete Children - Full CRUD operations for child profiles
  • Status Tracking - Real-time status updates (safe, warning, danger)
  • Location Monitoring - Track child locations and activities
  • Age-appropriate Monitoring - Customized monitoring based on child age

πŸ”” Alert System

  • Create Alerts - Generate alerts for various events
  • Alert Severity - Low, medium, high priority levels
  • Alert Status - Active, resolved, dismissed states
  • Alert History - Complete audit trail of all alerts

Database Setup

1. MySQL Installation

Make sure you have MySQL installed and running on your system.

2. Create Database

Run the SQL schema file in MySQL Workbench or MySQL command line:

mysql -u root -p < database_schema.sql

Or copy and paste the contents of database_schema.sql into MySQL Workbench.

3. Database Configuration

Update the database configuration in config.js or set environment variables:

// config.js
module.exports = {
    database: {
        host: 'localhost',
        user: 'root',
        password: 'your_password',
        database: 'parent_alert_system',
        port: 3306
    }
};

Or use environment variables:

export DB_HOST=localhost
export DB_USER=root
export DB_PASSWORD=your_password
export DB_NAME=parent_alert_system
export DB_PORT=3306

Installation

  1. Clone the repository

    git clone <repository-url>
    cd parent-alert-system
  2. Install dependencies

    npm install
  3. Set up the database (see Database Setup above)

  4. Start the server

    npm start
  5. Access the application

    • Open your browser and navigate to http://localhost:3000
    • The dashboard will be available at the root URL

API Endpoints

Children Management

  • GET /api/children - Get all children
  • GET /api/children/:id - Get specific child
  • POST /api/children - Create new child
  • PUT /api/children/:id - Update child
  • DELETE /api/children/:id - Delete child
  • PUT /api/children/:id/status - Update child status

Alerts Management

  • GET /api/alerts - Get all alerts (with optional filters)
  • GET /api/alerts/active - Get active alerts only
  • POST /api/alerts - Create new alert
  • PUT /api/alerts/:id/status - Update alert status
  • DELETE /api/alerts/:id - Delete alert

Activity & Statistics

  • GET /api/activity - Get activity log
  • POST /api/activity - Log new activity
  • GET /api/dashboard/stats - Get dashboard statistics
  • GET /api/children/status - Get children status overview

Database Schema

Tables

  • children - Child profiles and status
  • alerts - Alert records with severity and status
  • activity_log - System activity tracking
  • screen_captures - Screen capture records (for future use)

Views

  • active_alerts_view - Active alerts with child information
  • children_status_view - Children with alert counts

Stored Procedures

  • AddChild - Add new child
  • UpdateChildStatus - Update child status and location
  • CreateAlert - Create new alert
  • ResolveAlert - Resolve an alert
  • GetDashboardStats - Get dashboard statistics

Usage

Adding Children

  1. Navigate to the dashboard
  2. Use the "Add Child" form
  3. Fill in child details (name, age, avatar, location)
  4. Submit the form

Managing Alerts

  1. View active alerts on the dashboard
  2. Click "Resolve" to mark alerts as resolved
  3. Click "Delete" to remove alerts
  4. Create new alerts via API or system events

Monitoring

  1. Dashboard: View overall statistics and child status
  2. Children List: See all children with their current status
  3. Alerts: Check active alerts and their details
  4. Activity Log: Review system activity history

File Structure

parent-alert-system/
β”œβ”€β”€ database_schema.sql    # MySQL database schema
β”œβ”€β”€ database.js            # Database connection and operations
β”œβ”€β”€ config.js              # Configuration settings
β”œβ”€β”€ server.js              # Express server with API endpoints
β”œβ”€β”€ js/
β”‚   β”œβ”€β”€ database-ui.js     # Frontend database operations
β”‚   β”œβ”€β”€ common.js          # Common utilities
β”‚   β”œβ”€β”€ script.js          # Main dashboard logic
β”‚   β”œβ”€β”€ alerts.js          # Alerts management
β”‚   β”œβ”€β”€ child-status.js    # Child status tracking
β”‚   └── settings.js        # Settings management
β”œβ”€β”€ css/
β”‚   └── style.css          # Main stylesheet
β”œβ”€β”€ index.html             # Main dashboard
β”œβ”€β”€ alert.html             # Alerts page
β”œβ”€β”€ child-status.html      # Child status page
β”œβ”€β”€ settings.html          # Settings page
└── package.json

Configuration

Database Settings

Update config.js with your MySQL connection details:

  • host - MySQL server host
  • user - MySQL username
  • password - MySQL password
  • database - Database name
  • port - MySQL port (default: 3306)

Environment Variables

You can also use environment variables for configuration:

  • DB_HOST - Database host
  • DB_USER - Database user
  • DB_PASSWORD - Database password
  • DB_NAME - Database name
  • DB_PORT - Database port
  • PORT - Server port (default: 3000)

Security Considerations

  • Database Security: Use strong passwords and limit database access
  • Input Validation: All user inputs are validated on both frontend and backend
  • SQL Injection Protection: Using parameterized queries with mysql2
  • Error Handling: Comprehensive error handling throughout the application

Development

Adding New Features

  1. Database: Add new tables/columns to database_schema.sql
  2. Backend: Extend database.js with new methods
  3. API: Add new endpoints in server.js
  4. Frontend: Update database-ui.js for new functionality
  5. UI: Add new HTML/CSS for user interface

Testing

  • Test database connections
  • Verify CRUD operations
  • Check API endpoints
  • Validate frontend functionality

Troubleshooting

Database Connection Issues

  1. Verify MySQL is running
  2. Check database credentials in config.js
  3. Ensure database exists: parent_alert_system
  4. Verify user permissions

API Errors

  1. Check server logs for error messages
  2. Verify database connection
  3. Check API endpoint URLs
  4. Validate request data format

License

This project is licensed under the ISC License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published