Add comprehensive API documentation for LCC backend

This commit introduces a detailed README file outlining the LCC Backend API, including endpoint descriptions, request/response formats, and authentication methods. It covers various domains such as system configuration, transport rates, user management, calculations, and reporting. This documentation aims to assist developers in understanding and utilizing the API effectively.
This commit is contained in:
Jan 2025-03-18 10:56:55 +01:00
parent 19d8d236fa
commit 812441a9e0
2 changed files with 1800 additions and 78 deletions

1708
readme.md Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,3 @@
-- Property management tables -- Property management tables
CREATE TABLE IF NOT EXISTS `property_set` CREATE TABLE IF NOT EXISTS `property_set`
( (
@ -14,19 +12,30 @@ CREATE TABLE IF NOT EXISTS `property_set`
INDEX `idx_property_set_id` (id) INDEX `idx_property_set_id` (id)
) COMMENT 'Manages versioned sets of properties with temporal validity'; ) COMMENT 'Manages versioned sets of properties with temporal validity';
CREATE TABLE IF NOT EXISTS `system_property_type`
(
-- Stores system-wide configuration property types
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(255) NOT NULL,
`external_mapping_id` VARCHAR(16),
`data_type` VARCHAR(16) NOT NULL,
`validation_rule` VARCHAR(64),
CONSTRAINT `chk_system_data_type_values` CHECK (`data_type` IN
('INT', 'PERCENTAGE', 'BOOLEAN', 'CURRENCY', 'ENUMERATION',
'TEXT'))
) COMMENT 'Stores system-wide configuration property types';
CREATE TABLE IF NOT EXISTS `system_property` CREATE TABLE IF NOT EXISTS `system_property`
( (
-- Stores system-wide configuration properties -- Stores system-wide configuration properties
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`property_set_id` INT NOT NULL, `property_set_id` INT NOT NULL,
`description` VARCHAR(255) NOT NULL, `system_property_type_id` INT NOT NULL,
`short_description` VARCHAR(16),
`data_type` VARCHAR(16) NOT NULL,
`validation_rule` VARCHAR(64),
`property_value` VARCHAR(500), `property_value` VARCHAR(500),
CONSTRAINT `chk_system_data_type_values` CHECK (`data_type` IN FOREIGN KEY (`property_set_id`) REFERENCES `property_set` (`id`),
('INT', 'PERCENTAGE', 'BOOLEAN', 'CURRENCY', 'ENUMERATION', 'TEXT')), FOREIGN KEY (`system_property_type_id`) REFERENCES `system_property_type` (`id`),
FOREIGN KEY (`property_set_id`) REFERENCES `property_set` (`id`) INDEX `idx_system_property_type_id` (system_property_type_id),
INDEX `idx_property_set_id` (id)
) COMMENT 'Stores system-wide configuration properties'; ) COMMENT 'Stores system-wide configuration properties';
-- country -- country
@ -35,6 +44,7 @@ CREATE TABLE IF NOT EXISTS `country`
`id` INT NOT NULL AUTO_INCREMENT, `id` INT NOT NULL AUTO_INCREMENT,
`iso_code` CHAR(2) NOT NULL COMMENT 'ISO 3166-1 alpha-2 country code', `iso_code` CHAR(2) NOT NULL COMMENT 'ISO 3166-1 alpha-2 country code',
`region_code` CHAR(5) NOT NULL COMMENT 'Geographic region code (EMEA/LATAM/APAC/NAM)', `region_code` CHAR(5) NOT NULL COMMENT 'Geographic region code (EMEA/LATAM/APAC/NAM)',
`name` VARCHAR(128) NOT NULL,
`is_deprecated` BOOLEAN NOT NULL DEFAULT FALSE, `is_deprecated` BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE INDEX `idx_country_iso_code` (`iso_code`), UNIQUE INDEX `idx_country_iso_code` (`iso_code`),
@ -45,13 +55,14 @@ CREATE TABLE IF NOT EXISTS `country`
CREATE TABLE IF NOT EXISTS `country_property_type` CREATE TABLE IF NOT EXISTS `country_property_type`
( (
`id` INT NOT NULL AUTO_INCREMENT, `id` INT NOT NULL AUTO_INCREMENT,
`description` VARCHAR(255) NOT NULL, `name` VARCHAR(255) NOT NULL,
`short_description` VARCHAR(16), `external_mapping_id` VARCHAR(16),
`data_type` VARCHAR(16) NOT NULL, `data_type` VARCHAR(16) NOT NULL,
`validation_rule` VARCHAR(64), `validation_rule` VARCHAR(64),
`is_required` BOOLEAN NOT NULL DEFAULT FALSE, `is_required` BOOLEAN NOT NULL DEFAULT FALSE,
CONSTRAINT `chk_country_data_type_values` CHECK (`data_type` IN CONSTRAINT `chk_country_data_type_values` CHECK (`data_type` IN
('INT', 'PERCENTAGE', 'BOOLEAN', 'CURRENCY', 'ENUMERATION', 'TEXT')), ('INT', 'PERCENTAGE', 'BOOLEAN', 'CURRENCY', 'ENUMERATION',
'TEXT')),
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
INDEX `idx_property_type_data_type` (`data_type`) INDEX `idx_property_type_data_type` (`data_type`)
) COMMENT 'Defines available property types for country-specific configurations'; ) COMMENT 'Defines available property types for country-specific configurations';
@ -60,11 +71,11 @@ CREATE TABLE IF NOT EXISTS `country_property`
( (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`country_id` INT NOT NULL, `country_id` INT NOT NULL,
`property_type_id` INT NOT NULL, `country_property_type_id` INT NOT NULL,
`property_set_id` INT NOT NULL, `property_set_id` INT NOT NULL,
`property_value` VARCHAR(500), `property_value` VARCHAR(500),
FOREIGN KEY (`country_id`) REFERENCES `country` (`id`), FOREIGN KEY (`country_id`) REFERENCES `country` (`id`),
FOREIGN KEY (`property_type_id`) REFERENCES `country_property_type` (`id`), FOREIGN KEY (`country_property_type_id`) REFERENCES `country_property_type` (`id`),
FOREIGN KEY (`property_set_id`) REFERENCES `property_set` (`id`) FOREIGN KEY (`property_set_id`) REFERENCES `property_set` (`id`)
) COMMENT 'Stores country-specific property values with versioning support'; ) COMMENT 'Stores country-specific property values with versioning support';
@ -85,7 +96,8 @@ CREATE TABLE IF NOT EXISTS `sys_user`
CREATE TABLE IF NOT EXISTS `sys_group` CREATE TABLE IF NOT EXISTS `sys_group`
( (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`group_name` CHAR(64) NOT NULL, `group_name` VARCHAR(64) NOT NULL,
`group_description` VARCHAR(128) NOT NULL,
UNIQUE INDEX `idx_group_name` (`group_name`) UNIQUE INDEX `idx_group_name` (`group_name`)
) COMMENT 'Defines user groups for access management'; ) COMMENT 'Defines user groups for access management';
@ -106,10 +118,11 @@ CREATE TABLE IF NOT EXISTS `sys_user_node`
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`user_id` INT NOT NULL, `user_id` INT NOT NULL,
`country_id` INT NOT NULL, `country_id` INT NOT NULL,
`description` VARCHAR(255) NOT NULL, `name` VARCHAR(254) NOT NULL,
`address` VARCHAR(500) NOT NULL, `address` VARCHAR(500) NOT NULL,
`geo_lat` DECIMAL(7, 4) CHECK (geo_lat BETWEEN -90 AND 90), `geo_lat` DECIMAL(7, 4) CHECK (geo_lat BETWEEN -90 AND 90),
`geo_lng` DECIMAL(7, 4) CHECK (geo_lng BETWEEN -180 AND 180), `geo_lng` DECIMAL(7, 4) CHECK (geo_lng BETWEEN -180 AND 180),
`is_deprecated` BOOLEAN DEFAULT FALSE,
FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`), FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`),
FOREIGN KEY (`country_id`) REFERENCES `country` (`id`) FOREIGN KEY (`country_id`) REFERENCES `country` (`id`)
) COMMENT 'Contains user generated logistic nodes'; ) COMMENT 'Contains user generated logistic nodes';
@ -121,7 +134,7 @@ CREATE TABLE node
( (
id INT PRIMARY KEY, id INT PRIMARY KEY,
country_id INT NOT NULL, country_id INT NOT NULL,
description VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL,
address VARCHAR(500) NOT NULL, address VARCHAR(500) NOT NULL,
external_mapping_id VARCHAR(32), external_mapping_id VARCHAR(32),
predecessor_required BOOLEAN NOT NULL DEFAULT FALSE, predecessor_required BOOLEAN NOT NULL DEFAULT FALSE,
@ -231,7 +244,7 @@ CREATE TABLE material
part_number CHAR(12) NOT NULL, part_number CHAR(12) NOT NULL,
normalized_part_number CHAR(12) NOT NULL, normalized_part_number CHAR(12) NOT NULL,
hs_code CHAR(8), hs_code CHAR(8),
description VARCHAR(500) NOT NULL, name VARCHAR(500) NOT NULL,
is_deprecated BOOLEAN NOT NULL DEFAULT FALSE, is_deprecated BOOLEAN NOT NULL DEFAULT FALSE,
CONSTRAINT `chk_normalized_part_number` UNIQUE (`normalized_part_number`) CONSTRAINT `chk_normalized_part_number` UNIQUE (`normalized_part_number`)
); );
@ -268,12 +281,13 @@ CREATE TABLE packaging
CREATE TABLE packaging_property_type CREATE TABLE packaging_property_type
( (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`description` VARCHAR(500) NOT NULL, `name` VARCHAR(255) NOT NULL,
`data_type` CHAR(16), `data_type` VARCHAR(16),
`validation_rule` CHAR(64), `validation_rule` VARCHAR(64),
`is_required` BOOLEAN NOT NULl DEFAULT FALSE, `is_required` BOOLEAN NOT NULl DEFAULT FALSE,
CONSTRAINT `chk_packaging_data_type_values` CHECK (`data_type` IN CONSTRAINT `chk_packaging_data_type_values` CHECK (`data_type` IN
('INT', 'PERCENTAGE', 'BOOLEAN', 'CURRENCY', 'ENUMERATION', 'TEXT')) ('INT', 'PERCENTAGE', 'BOOLEAN', 'CURRENCY', 'ENUMERATION',
'TEXT'))
); );
CREATE TABLE packaging_property CREATE TABLE packaging_property
@ -288,25 +302,16 @@ CREATE TABLE packaging_property
INDEX idx_packaging_id (packaging_id) INDEX idx_packaging_id (packaging_id)
); );
CREATE TABLE calculation
(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
material_id INT NOT NULL,
supplier_node_id INT NOT NULL,
packaging_id INT DEFAULT NULL,
FOREIGN KEY (material_id) REFERENCES material (id),
FOREIGN KEY (supplier_node_id) REFERENCES node (id),
FOREIGN KEY (packaging_id) REFERENCES packaging (id),
INDEX idx_material_id (material_id),
INDEX idx_supplier_node_id (supplier_node_id),
INDEX idx_packaging_id (packaging_id)
);
CREATE TABLE premiss CREATE TABLE premiss
( (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
calculation_id INT NOT NULL, material_id INT NOT NULL,
supplier_node_id INT,
user_supplier_node_id INT,
packaging_id INT DEFAULT NULL,
user_id INT NOT NULL, user_id INT NOT NULL,
createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
material_cost DECIMAL(15, 2) COMMENT 'aka MEK_A in EUR', material_cost DECIMAL(15, 2) COMMENT 'aka MEK_A in EUR',
is_fca_enabled BOOLEAN DEFAULT FALSE, is_fca_enabled BOOLEAN DEFAULT FALSE,
oversea_share DECIMAL(7, 4), oversea_share DECIMAL(7, 4),
@ -322,7 +327,10 @@ CREATE TABLE premiss
hu_unit_count INT UNSIGNED DEFAULT NULL, hu_unit_count INT UNSIGNED DEFAULT NULL,
hu_stackable BOOLEAN DEFAULT TRUE, hu_stackable BOOLEAN DEFAULT TRUE,
hu_mixable BOOLEAN DEFAULT TRUE, hu_mixable BOOLEAN DEFAULT TRUE,
FOREIGN KEY (calculation_id) REFERENCES calculation (id), FOREIGN KEY (material_id) REFERENCES material (id),
FOREIGN KEY (supplier_node_id) REFERENCES node (id),
FOREIGN KEY (user_supplier_node_id) REFERENCES sys_user_node (id),
FOREIGN KEY (packaging_id) REFERENCES packaging (id),
FOREIGN KEY (user_id) REFERENCES sys_user (id), FOREIGN KEY (user_id) REFERENCES sys_user (id),
CONSTRAINT `chk_premiss_state_values` CHECK (`state` IN CONSTRAINT `chk_premiss_state_values` CHECK (`state` IN
('DRAFT', 'COMPLETED', 'ARCHIVED', 'DELETED')), ('DRAFT', 'COMPLETED', 'ARCHIVED', 'DELETED')),
@ -330,8 +338,11 @@ CREATE TABLE premiss
('MM', 'CM', 'M')), ('MM', 'CM', 'M')),
CONSTRAINT `chk_premiss_displayed_weight_unit` CHECK (`hu_displayed_weight_unit` IN CONSTRAINT `chk_premiss_displayed_weight_unit` CHECK (`hu_displayed_weight_unit` IN
('G', 'KG')), ('G', 'KG')),
INDEX idx_calculation_id (calculation_id), INDEX idx_material_id (material_id),
INDEX idx_user_id (user_id) INDEX idx_supplier_node_id (supplier_node_id),
INDEX idx_packaging_id (packaging_id),
INDEX idx_user_id (user_id),
INDEX idx_user_supplier_node_id (user_supplier_node_id)
); );
@ -350,9 +361,11 @@ CREATE TABLE premiss_sink
CREATE TABLE premiss_route CREATE TABLE premiss_route
( (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
premiss_sink_node_id INT NOT NULL, premiss_sink_id INT NOT NULL,
is_fastest BOOLEAN DEFAULT FALSE,
is_cheapest BOOLEAN DEFAULT FALSE,
is_selected BOOLEAN DEFAULT FALSE, is_selected BOOLEAN DEFAULT FALSE,
FOREIGN KEY (premiss_sink_node_id) REFERENCES premiss_sink (id) FOREIGN KEY (premiss_sink_id) REFERENCES premiss_sink (id)
); );
CREATE TABLE premiss_route_node CREATE TABLE premiss_route_node
@ -361,7 +374,7 @@ CREATE TABLE premiss_route_node
premiss_route_id INT NOT NULL, premiss_route_id INT NOT NULL,
node_id INT DEFAULT NULL, node_id INT DEFAULT NULL,
user_node_id INT DEFAULT NULL, user_node_id INT DEFAULT NULL,
description VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL,
address VARCHAR(500), address VARCHAR(500),
is_sink BOOLEAN DEFAULT FALSE, is_sink BOOLEAN DEFAULT FALSE,
is_intermediate BOOLEAN DEFAULT FALSE, is_intermediate BOOLEAN DEFAULT FALSE,
@ -474,6 +487,7 @@ CREATE TABLE calculation_job_route_section_result
cbm_price DECIMAL(15, 2) NOT NULL COMMENT 'calculated price per cubic meter', cbm_price DECIMAL(15, 2) NOT NULL COMMENT 'calculated price per cubic meter',
weight_price DECIMAL(15, 2) NOT NULL COMMENT 'calculated price per kilogram', weight_price DECIMAL(15, 2) NOT NULL COMMENT 'calculated price per kilogram',
annual_cost DECIMAL(15, 2) NOT NULL COMMENT 'annual costs for this route section, result depends on calculation method (mixed or unmixed, stacked or unstacked, per volume/per weight resp. container rate/price matrix)', annual_cost DECIMAL(15, 2) NOT NULL COMMENT 'annual costs for this route section, result depends on calculation method (mixed or unmixed, stacked or unstacked, per volume/per weight resp. container rate/price matrix)',
transit_time INT UNSIGNED NOT NULL,
FOREIGN KEY (premiss_route_section_id) REFERENCES premiss_route_section (id), FOREIGN KEY (premiss_route_section_id) REFERENCES premiss_route_section (id),
FOREIGN KEY (calculation_job_transportation_result_id) REFERENCES calculation_job_transportation_result (id), FOREIGN KEY (calculation_job_transportation_result_id) REFERENCES calculation_job_transportation_result (id),
INDEX idx_premiss_route_section_id (premiss_route_section_id), INDEX idx_premiss_route_section_id (premiss_route_section_id),