A simple web application for managing personal data, optimized for mobile devices.
- Input name and birth date to retrieve personal information
- View personal data including name, birth date, baptism date, mobile phone, home phone, address, and emergency contact
- Validate or edit personal information
- Track and display when personal data was last validated
- Password-protected admin page to view all users' personal data
- Mobile-responsive design
- Frontend: Angular 19
- Backend: Node.js with Express.js
- Storage: MySQL/MariaDB database
- Node.js (v14 or higher)
- npm (v6 or higher)
- MySQL/MariaDB database (or Docker for running the included container)
- Clone the repository
- Install dependencies:
npm install- Create a
.envfile in the root directory with the following content:
# MySQL Database Configuration (required)
MYSQL_HOST=localhost
MYSQL_USER=personal-data
MYSQL_PASSWORD=your_mysql_password
MYSQL_DATABASE=personal-data
# Server Configuration
PORT=3000
# Admin Credentials
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin123
Fill in the MySQL configuration values as described in the MySQL Database Configuration section.
To run both the frontend and backend concurrently with auto-reload:
npm run devThis will start:
- Angular frontend at http://localhost:4200
- Express backend at http://localhost:3000
Both the frontend and backend will automatically reload when changes are detected.
npm startnpm run servernpm run server:devThis will start the backend server with nodemon, which automatically restarts the server when changes are detected.
- Open the application in your browser at http://localhost:4200
- Enter a name and birth date on the initial form
- For testing, you can use:
- Name: "John Doe", Birth Date: "1990-05-15"
- Name: "Jane Smith", Birth Date: "1985-10-25"
- For testing, you can use:
- View your personal information
- Click "Validate" to confirm the data is correct
- The system will store the current date and time as the last validation date
- The last validation date will be displayed in the personal information section
- Click "Edit" to modify your personal information
- Save your changes
- Navigate to http://localhost:4200/admin/login
- Enter the admin credentials:
- Username: admin
- Password: admin123
- After successful login, you'll be redirected to the admin dashboard
- The dashboard displays all users' personal data in a card layout
- Click "Logout" to end your admin session
The application includes comprehensive unit tests for Angular components and services. To run the frontend tests:
npm testThis will execute the Angular tests using Karma and Jasmine.
The backend API is tested using Jest and Supertest. To run the backend tests:
npm run test:backendTo run the tests in watch mode (automatically re-run when files change):
npm run test:backend:watchThis application is configured for easy deployment to Render.com. Follow these steps to deploy:
-
Create a new Web Service on Render.com
-
Connect your GitHub repository
-
Configure the following settings:
- Name: Choose a name for your service
- Environment: Node
- Build Command:
npm install - Start Command:
npm run start:prod - Plan: Select an appropriate plan (Free tier works for testing)
-
Add the following environment variables:
NODE_ENV: Set toproductionPORT: Render will set this automatically, but you can specify a custom port if neededMYSQL_HOST: Your MySQL host (e.g., MySQL database service URL)MYSQL_USER: Your MySQL usernameMYSQL_PASSWORD: Your MySQL passwordMYSQL_DATABASE: Your MySQL database name (typically 'personal-data')ADMIN_USERNAME: Set a secure username for admin access (optional, defaults to 'admin')ADMIN_PASSWORD: Set a secure password for admin access (optional, defaults to 'admin123')ALLOWED_ORIGINS: Comma-separated list of allowed origins for CORS (optional, if not set, only same-origin requests will be allowed)
-
Click "Create Web Service"
Render will automatically build and deploy your application. The deployment process includes:
- Installing dependencies
- Building the Angular application (via the postinstall script)
- Starting the Node.js server in production mode
Before deploying to Render.com, you can test the production build locally:
- Build the Angular application:
npm run build- Start the server in production mode:
npm run start:prod- Open your browser and navigate to http://localhost:3000
This will serve the application exactly as it would be served in production, using the built Angular files from the dist directory.
The application uses MySQL/MariaDB database for storing personal data. You have two options for setting up the database:
The easiest way to set up the database is using Docker Compose, which is included in the project:
- Make sure you have Docker and Docker Compose installed on your system
- Start the MySQL container using Docker Compose:
docker-compose up -d
- This will create a MariaDB container with the following configuration:
- Database name: personal-data
- Username: personal-data
- Password: Ll0X6UjXvw8u (you should change this in production)
- Port: 3306
- Update your
.envfile with these values:MYSQL_HOST=localhost MYSQL_USER=personal-data MYSQL_PASSWORD=Ll0X6UjXvw8u MYSQL_DATABASE=personal-data
If you already have a MySQL or MariaDB server:
- Create a new database:
CREATE DATABASE `personal-data`; - Create a new user with appropriate permissions:
CREATE USER 'personal-data'@'%' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON `personal-data`.* TO 'personal-data'@'%'; FLUSH PRIVILEGES;
- Update your
.envfile with your database details:MYSQL_HOST=your_mysql_host MYSQL_USER=personal-data MYSQL_PASSWORD=your_password MYSQL_DATABASE=personal-data
To import the sample data to your MySQL database:
- If using Docker Compose, the database will be initialized automatically when first started
- If using an existing MySQL server, you can import the provided migration script:
mysql -u personal-data -p personal-data < mysql-migration.sql
The application will also automatically create the necessary tables if they don't exist when it starts up.
src/app/components/- Angular componentsinitial-form/- Component for the initial name and birth date formpersonal-data/- Component for displaying personal dataedit-personal-data/- Component for editing personal dataadmin-login/- Component for admin loginadmin-dashboard/- Component for displaying all users' data (admin only)
src/app/services/- Angular servicesuser.service.ts- Service for user data operationsauth.service.ts- Service for authentication
src/app/guards/- Angular route guardsauth.guard.ts- Guard to protect admin routes
server.js- Express backend serverdb.js- Database module for MySQL database.env- Environment variables configuration filedocker-compose.yml- Docker Compose configuration for MySQL databasemysql-migration.sql- SQL script to create tables and import sample data to MySQLmigration.sql- Original SQL script for Turso (kept for reference)generate-migration.js- Node.js script to generate a complete SQL migration scriptserver.test.js- Backend API testsjest.config.js- Jest configuration for backend tests