Skip to main content

Prerequisites

Before you begin, ensure you have the following installed on your system:
  • Node.js v18 or higher (v24.13.1 recommended)
  • MySQL 8.0 or higher
  • npm or bun package manager
  • Git for version control

Clone the Repository

Clone the OdontologyApp repository to your local machine:
git clone <repository-url>
cd OdontologyApp2

Install Dependencies

Install the project dependencies using your preferred package manager:
npm install

Database Setup

1

Create the Database

Create a new MySQL database for the application:
CREATE DATABASE IF NOT EXISTS ontology_db;
2

Import the Schema

Import the database schema from the provided SQL file:
mysql -u root -p ontology_db < database.sql
This will create all necessary tables including:
  • branches - Clinic branches
  • users - System users (admin, doctors, secretaries)
  • doctors - Doctor-specific information
  • patients - Patient records
  • appointments - Appointment scheduling
  • medical_records - Clinical records
  • And more…
3

Apply Permission Migrations

If you need the latest permission system, apply the migration:
mysql -u root -p ontology_db < migration_phase6_permissions.sql
4

Import Finance Stored Procedures (Optional)

For financial reporting features:
mysql -u root -p ontology_db < sp_finance.sql

Environment Configuration

Create a .env file in the root directory with your database credentials:
# Database Configuration
DB_HOST=localhost
DB_USER=root
DB_PASS=your_password
DB_NAME=ontology_db
The application uses SvelteKit’s $env/static/private module to load environment variables. Make sure your .env file is in the project root and never commit it to version control.

Run Development Server

Start the development server:
npm run dev
The application will be available at:
  • Local: http://localhost:5173
  • Network: http://<your-ip>:5173
The --host flag in the dev script allows access from other devices on your network.

Available Scripts

The following npm scripts are available in package.json:
ScriptCommandDescription
devvite dev --hostStart development server with network access
buildvite buildBuild for production
previewvite previewPreview production build locally
checksvelte-kit sync && svelte-checkType check the application
check:watchsvelte-kit sync && svelte-check --watchType check in watch mode
preparesvelte-kit syncSync SvelteKit types

Verify Installation

1

Check Server Status

Ensure the dev server is running without errors and displays the SvelteKit startup message.
2

Open the Application

Navigate to http://localhost:5173/login in your browser.
3

Test Database Connection

Try logging in or accessing any page that requires database interaction. If configured correctly, the application should connect to MySQL without errors.

Project Structure

OdontologyApp2/
├── src/
│   ├── lib/
│   │   ├── components/      # Reusable Svelte components
│   │   ├── server/          # Server-side utilities
│   │   │   ├── db.js        # MySQL connection pool
│   │   │   └── checkPermission.js
│   │   ├── config.js        # App configuration
│   │   ├── permissions.js   # RBAC permissions
│   │   ├── schemas.js       # Zod validation schemas
│   │   └── stores.js        # Svelte stores
│   ├── routes/              # SvelteKit routes
│   │   ├── api/            # API endpoints
│   │   ├── dashboard/      # Dashboard pages
│   │   ├── patients/       # Patient management
│   │   ├── appointments/   # Appointment scheduling
│   │   └── ...
│   ├── styles/             # Global styles
│   ├── app.html            # HTML template
│   ├── app.css             # Global CSS
│   └── hooks.server.js     # Server hooks
├── static/                 # Static assets
├── database.sql            # Database schema
├── migration_*.sql         # Database migrations
├── package.json
├── svelte.config.js        # SvelteKit configuration
└── vite.config.js          # Vite configuration

Troubleshooting

  • Verify MySQL is running: sudo systemctl status mysql
  • Check credentials in .env file
  • Ensure database ontology_db exists
  • Verify user has proper permissions
If port 5173 is already in use, Vite will automatically try the next available port. Check the terminal output for the actual port.
Run npm install again to ensure all dependencies are installed. Clear node_modules and reinstall if issues persist:
rm -rf node_modules package-lock.json
npm install
Run npm run check to see all type errors. The application uses JSDoc for type annotations, so check your IDE’s TypeScript support is enabled.

Next Steps

Contributing Guide

Learn how to contribute to the project

Testing Guide

Understand the testing approach

Deployment

Deploy to production

Architecture

Explore the system architecture

Build docs developers (and LLMs) love