The Parental Control API is a backend system that allows parents to manage and monitor children's digital screen time, control content access, and generate usage reports. This API provides features such as user authentication, content filtering, screen time management, and generating reports of users' digital activity.
This project aims to provide an efficient backend system for parental control applications, offering parents the ability to maintain healthy boundaries on their children's digital activities.
- User Authentication: Secure registration and login using JSON Web Tokens (JWT).
- Content Filtering: Allows users to add, view, and remove content restrictions.
- Screen Time Management: Set daily screen time limits, log screen time sessions, and track violations if limits are exceeded.
- Reporting: Generates detailed reports on user activities, including screen time logs, content restrictions, total usage duration, daily screen time violations, and average usage summaries.
- Node.js: JavaScript runtime environment for backend development.
- Express.js: Fast and lightweight web application framework for Node.js.
- MySQL: Relational database used for persistent data storage.
- JWT: Used for authenticating users securely.
- Postman: For testing API endpoints during development.
- Node.js (>= 14.x.x)
- MySQL installed and running
- npm or yarn for dependency management
-
Clone the Repository:
git clone https://github.com/your-username/parental-control-api.git cd parental-control-api
-
Install Dependencies:
npm install
-
Set Up MySQL Database:
-
Create a new database in MySQL named
parental_control
:CREATE DATABASE parental_control;
-
Import tables and setup from
db_setup.sql
(if available).
-
-
Configure Environment Variables:
-
Create a
.env
file in the root directory and add the following:DB_HOST=localhost DB_USER=root DB_PASS=yourpassword DB_NAME=parental_control JWT_SECRET=your_jwt_secret PORT=4000
-
-
Run the Application:
npx nodemon src/index.js
The server should now be running at
http://localhost:4000
.
- Register User:
POST /api/auth/register
- Body:
{ "username": "user1", "password": "password" }
- Body:
- Login User:
POST /api/auth/login
- Body:
{ "username": "user1", "password": "password" }
- Body:
- Set Screen Time Limit:
POST /api/screen-time/set
- Body:
{ "dailyLimit": 180, "startTime": "09:00:00", "endTime": "21:00:00" }
- Body:
- Start Screen Time:
POST /api/screen-time/start
- Stop Screen Time:
POST /api/screen-time/stop
- Get Screen Time Logs:
GET /api/screen-time/logs
- Add Content Restriction:
POST /api/content/add
- Body:
{ "url": "example.com" }
- Body:
- Get Content Restrictions:
GET /api/content/list
- Remove Content Restriction:
DELETE /api/content/remove/:id
- Get User Report:
GET /api/reports/user/{userId}
- Provides:
- Screen Time Logs
- Content Restrictions
- Total Screen Time Duration
- Daily Durations Summary
- Average Daily Time
- Violations (if daily limits are exceeded)
- Provides:
Column | Type | Details |
---|---|---|
id | INT | Primary Key, Auto Increment |
username | VARCHAR(255) | Unique |
password | VARCHAR(255) | Hashed Password |
created_at | TIMESTAMP | Default Current Time |
VARCHAR(255) | (Optional) |
Column | Type | Details |
---|---|---|
id | INT | Primary Key, Auto Increment |
user_id | INT | Foreign Key referencing users.id |
daily_limit | INT | Limit in minutes |
start_time | TIME | Optional Start Time |
end_time | TIME | Optional End Time |
created_at | TIMESTAMP | Default Current Time |
Column | Type | Details |
---|---|---|
id | INT | Primary Key, Auto Increment |
user_id | INT | Foreign Key referencing users.id |
start_time | TIMESTAMP | Default Current Time |
end_time | TIMESTAMP | NULL until session ends |
- Using Postman: The Postman collection (
Parental_Control_API_Testing.postman_collection.json
) is available to automate endpoint testing. ## Postman Collection
A Postman collection is included in this repository for easy testing of the Parental Control API.
You can find it in the postman
folder:
postman/Parental_Control_API_Collection.json
To use it, import this file into Postman and set up the necessary environment variables for testing.
- Test Coverage:
- User Authentication
- Screen Time Limits
- Content Restriction Features
- Report Generation
This project is in the final stages of development. It provides essential features for parental control, such as screen time management, content restrictions, and reporting. Future iterations could focus on enhancing report details, supporting multiple platforms, or creating a front-end interface.
This backend API could be deployed and connected to a front-end application, providing parents an interface to:
- Register accounts
- Set up daily screen time limits
- Add content restrictions for devices
- Monitor children’s screen usage and content accessed
- Automate Logging: Automatically log user activity based on usage events.
- Advanced Analytics: Implement machine learning to predict potential content of concern.
- Front-end Interface: Develop a front-end interface for easy access.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or contributions:
- Email: wasimu285@egmail.com
- GitHub: wasim285