This guide covers the complete installation process for OdontologyApp, including system requirements, database setup, environment configuration, and deployment options.
# Install MySQL Server 8.0sudo apt updatesudo apt install mysql-server# Start MySQL servicesudo systemctl start mysqlsudo systemctl enable mysql# Secure MySQL installationsudo mysql_secure_installation
2
Create Database User
Login to MySQL and create a dedicated user:
# Login as rootsudo mysql -u root -p# Create database userCREATE USER 'odontology_user'@'localhost' IDENTIFIED BY 'your_secure_password';# Grant privileges (database will be created in next step)GRANT ALL PRIVILEGES ON ontology_db.* TO 'odontology_user'@'localhost';# Flush privilegesFLUSH PRIVILEGES;# Exit MySQLEXIT;
Replace your_secure_password with a strong password. Save these credentials - you’ll need them for the environment configuration.
mysql -u odontology_user -p ontology_db -e "SELECT id, name, username, role FROM users;"
Expected output:
+----+------------------+------------+-----------+| id | name | username | role |+----+------------------+------------+-----------+| 1 | Andrea Rojas | admin | admin || 2 | Dr. Carlos Soto | doctor | doctor || 3 | Lucía Mendoza | secretaria | secretary |+----+------------------+------------+-----------+
# Navigate to your project directorycd /var/www # or your preferred location# Clone the repository (replace with your actual repository)git clone https://github.com/your-org/odontologyapp.gitcd odontologyapp
OdontologyApp uses environment variables for database configuration and secrets.
1
Create .env file
Create a .env file in the project root:
touch .env
2
Add database configuration
Open .env and add the following configuration:
# Database ConfigurationDB_HOST=localhostDB_USER=odontology_userDB_PASS=your_secure_passwordDB_NAME=ontology_db# Application SettingsNODE_ENV=development# Optional: Custom port (default is 5173 in dev)PORT=5173
Security Note: Never commit the .env file to version control. Add it to .gitignore:
echo ".env" >> .gitignore
3
Configure database connection
The database connection is configured in src/lib/server/db.js:
// src/lib/server/db.jsimport mysql from "mysql2/promise";import { DB_HOST, DB_USER, DB_PASS, DB_NAME } from "$env/static/private";export const pool = mysql.createPool({ host: DB_HOST, // localhost user: DB_USER, // odontology_user password: DB_PASS, // your password database: DB_NAME, // ontology_db waitForConnections: true, connectionLimit: 10, // Max 10 concurrent connections queueLimit: 0, // Unlimited queue});
The connection pool automatically manages database connections, creating up to 10 concurrent connections for optimal performance.
The server will start on http://localhost:5173 with hot module replacement enabled.Expected output:
VITE v7.3.1 ready in 1234 ms ➜ Local: http://localhost:5173/ ➜ Network: http://192.168.1.100:5173/ ➜ press h to show help
2
Access the application
Open your browser and navigate to:
http://localhost:5173/login
You should see the OdontologyApp login screen.
3
Login with default credentials
Test the installation by logging in:
Username: adminPassword: admin123
If successful, you’ll be redirected to the dashboard.
The development server runs with --host flag enabled, allowing access from other devices on your network. This is useful for testing on mobile devices.
Generates production-ready output in build/ directory
Expected output:
vite v7.3.1 building for production...✓ 1234 modules transformed..svelte-kit/output/client/_app/version.json 0.05 kB │ gzip: 0.05 kB.svelte-kit/output/client/_app/immutable/assets/... x.xx kB │ gzip: x.xx kB...✓ built in 12.34s
3
Preview production build (optional)
Test the production build locally:
npm run preview
This starts a local server serving the production build.
# Check if MySQL is runningsudo systemctl status mysql# Start MySQL if stoppedsudo systemctl start mysql# Verify MySQL is listening on correct portsudo netstat -tlnp | grep 3306
Ensure proper indexes exist for frequently queried fields:
-- Check existing indexesSHOW INDEX FROM patients;SHOW INDEX FROM appointments;-- Add indexes if neededCREATE INDEX idx_patient_cedula ON patients(cedula);CREATE INDEX idx_appointment_date ON appointments(appointment_date, appointment_time);CREATE INDEX idx_user_username ON users(username);