Skip to content

TsvetanG2/Multi-tenant-DocApp-with-independent-database-for-each-tenant-domain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-tenant Doc App with Independent Databases

Overview

This repository contains a multi-tenant doctor appointments application with independent databases for each tenant domain. It is designed to provide a scalable and secure solution for managing appointments across multiple tenants while ensuring data isolation and privacy.

Features

  • Multi-tenancy: Each tenant (organization or domain) has its own isolated database.
  • Multi-user dashboard, records and calendar: Each doctor has it's own calendar, dashboard and records. Each patient registered under the doctor via "Add Records" will be assigned only to that doctor.
  • Doctor Appointments: Manage appointments with a calendar view and dashboard categorizing appointments into active, archived, and completed.
  • Patient Records: Maintain patient records, ensuring that only patients with existing records can be added to appointments.
  • Patient Appointments: Multiple patients can be added to a single event, only if the record of the patient exist.
  • User Authentication and Authorization: Secure user authentication and role-based access control (RBAC).
  • RESTful API: Exposes a RESTful API for integration with other services.
  • Scalable and Extendable: Built to accommodate growth and additional features.

How it works:

  • For each created tenant with domain, there will be a seperated database independent from the other tenants. You can create users and doctors. Assign the user to the doctor and assign the doctor to the domain(tenant) via the admin panel.
  • Each doctor creates its own patients and appointments. Each element is being assigned to him by their id in the database and cannot be viewed, changed or deleted by other users(doctors).

Repository Structure

  • DoctorsApp/: Main application directory containing all the core functionalities and modules.
  • manage.py: Command-line utility for administrative tasks.
  • requirements.txt: List of dependencies required to run the application.

Installation

  1. Clone the repository:
    git clone https://github.com/TsvetanG2/Multi-tenant-DocApp-with-independent-database-for-each-tenant-domain.git
    cd Multi-tenant-DocApp-with-independent-database-for-each-tenant-domain
    
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Set-up the database in settings.py
    DATABASES = {
     "default": {
         "ENGINE": 'django_tenants.postgresql_backend',
         "NAME": "your_database",
         "USER": "your_user",
         "PASSWORD": "your_password",
         "HOST": "your_default_host",
         "PORT": "your_default_port",
     }

}

Run App

  1. Make Migrations:
    python manage.py makemigrations
    
  2. Migrate:
    python manage.py migrate_schemas --shared
    python manage.py migrate
    
  3. Create a superuser, so you can add a tenant and domain:
    python manage.py createsuperuser
    
  • How to add tenant superuser
    python manage.py create_tenant_superuser
    
  1. Run App:
    python manage.py runserver
    

Usage

  • Once you run the app you will be prompted to your_default_host:your_dafault_port . A Django default homepage will appear that installation has been completed.
  • In order to access the main admin panel you have to go to:
     your_default_host:your_dafault_port/admin Example(example.com:8000/admin)
    
  • There you can add tenant and domain. First add a tenant, then assign the tenant to the domain. To access the domain go to:
     your_custom_domain_name:your_default_port Example(example.com:8000)
    
  • Same way you can access admin if you add /admin by the end of the port.
  • Create a user via the admin panel, then create a doctor and assign the doctor to the user and the domain.
  • Login via adding /login page by adding it by the end of the port.
  • Use the user's credentials to access the app.

Contributing and Ideas

  • Contributions are welcome! Please fork the repository and create a pull request with your changes

License

This project is licensed under the MIT License - see the LICENSE file for details.

App Screenshots

Django Default Page Django_default_page

Django Admin Panel Default_admin_to_add_tenants_and_domains

Tenant-Domain Admin Panel Tenant_domain_admin_panel

Tenant-Domain Login Page Tenant_users_login_page

Tenant-Domain Home Page Records_display_on_default_page

Tenant-Domain Add Record Page Add_record_of_patient_page

Tenant-Domain Calendar Page Calendar_page

Tenant-Domain Dashboard Page Dashboard_page