Skip to main content

Core Entities

Core entities separate platform access from real-world business identity. The central concept is parties: every person, company, agency, provider, administrator, and authority should be represented as a party.

parties

Purpose

Central business identity entity. A party can be a physical person or a company.

It can represent a landlord, tenant, guarantor, property manager, service provider, agency, accountant, tax authority, condominium administrator, or utility provider.

Suggested attributes

FieldDescription
idPrimary identifier.
party_typePERSON or COMPANY.
first_namePerson first name. Nullable for companies.
last_namePerson last name. Nullable for companies.
company_nameLegal or commercial company name. Nullable for persons.
fiscal_codeItalian fiscal code or equivalent identifier.
vat_numberVAT number for companies or professionals.
date_of_birthBirth date for physical persons.
place_of_birthBirth place for physical persons.
nationalityNationality or country code.
emailBusiness contact email.
phoneBusiness contact phone.
addressStreet address.
cityCity.
countryCountry.
notesFree-form operational notes.
created_atCreation timestamp.
updated_atLast update timestamp.

Relationships

RelationshipDescription
parties to usersOne party may have zero, one, or many platform users.
parties to property_partiesOne party may be linked to many properties with different roles.
parties to contract_partiesOne party may be linked to many contracts with different roles.
parties to bank_account_holdersOne party may hold or co-hold many logical bank accounts.
parties to service_provider_profilesOne party may be extended as a service provider.

Notes and design rationale

parties is the business identity table. It prevents duplicate identity models such as separate landlord, tenant, supplier, and agency tables. Role-specific meaning is expressed through relationship tables.

users

Purpose

Existing platform authentication table. It stores login data, access data, password credentials, and future authorization metadata.

Suggested attributes

The existing application owns the exact structure of users. The target model requires only the following conceptual link.

FieldDescription
idExisting user identifier.
party_idNullable foreign key to parties.id for legacy compatibility.

Relationships

RelationshipDescription
users.party_id to parties.idMany users may belong to the same party.

Notes and design rationale

Users are not the business identity. They are login identities. party_id may be nullable for legacy users, but every active platform user should eventually be linked to one party.

A company party can have multiple users with different platform profiles or permissions in the future.

roles

Purpose

Defines the available platform roles. A role represents a functional profile that determines what a user can see and do on the platform.

Attributes

FieldDescription
idPrimary identifier.
codeUnique role code (e.g. ADMIN, DEV, OWNER, MANAGER, VIEWER).
nameHuman-readable role name.
descriptionDescription of the role scope and access level.
is_activeWhether the role is currently assignable.
created_atCreation timestamp.

Default roles

CodeNameScope
ADMINAmministratoreFull platform access including configuration.
DEVSviluppatoreAccess to technical sections, logs, and system tools.
OWNERProprietarioManagement of own properties, contracts, and transactions.
MANAGERGestoreDelegated operational access to assigned properties and contracts.
VIEWERVisualizzatoreRead-only access to authorised data.

Relationships

RelationshipDescription
roles to user_rolesOne role can be assigned to many users.

user_roles

Purpose

Many-to-many join table between users and roles. One user can hold multiple roles simultaneously. Each assignment records who granted it and when.

Attributes

FieldDescription
idPrimary identifier.
user_idPlatform user receiving the role. References users.id.
role_idRole being assigned. References roles.id.
granted_by_user_idUser who granted the assignment. Nullable (system-assigned on bootstrap).
created_atTimestamp of the assignment.

Constraints

ConstraintDescription
UNIQUE (user_id, role_id)A user cannot hold the same role twice.

Relationships

RelationshipDescription
user_roles.user_id to users.idMany role assignments can belong to one user.
user_roles.role_id to roles.idMany users can share the same role.
user_roles.granted_by_user_id to users.idAudit link to the granting user.

Notes and design rationale

Roles are defined centrally in roles and assigned via user_roles. This allows multi-role users (e.g. a user who is both OWNER and MANAGER). Role logic is enforced at the application layer — the database only stores the assignment.

service_provider_profiles

Purpose

Extends parties when a party acts as a service provider. The provider remains a party and can still appear in other roles.

Examples include electricity providers, gas providers, water providers, internet providers, phone providers, condominium administrators, tax authorities, insurance companies, maintenance companies, and agencies.

Suggested attributes

FieldDescription
idPrimary identifier.
party_idProvider party.
provider_typeENERGY, GAS, WATER, INTERNET, PHONE, CONDOMINIUM, TAX_AUTHORITY, INSURANCE, MAINTENANCE, AGENCY, or OTHER.
vat_numberProvider VAT number if different or normalized separately.
customer_service_emailSupport email.
customer_service_phoneSupport phone.
websiteProvider website.
notesOperational notes.

Relationships

RelationshipDescription
service_provider_profiles.party_id to parties.idEach provider profile belongs to one party.
property_services.provider_party_id to parties.idServices reference the provider party directly.

Notes and design rationale

Provider details are optional and role-specific. They should not pollute the base parties table.

Graphical local diagrams

parties

users / roles / user_roles

service_provider_profiles