Preisspiegel & Bidder Management
Relevant source files
The following files were used as context for generating this wiki page:
Preisspiegel & Bidder Management represents the core procurement (Vergabe) logic of the LV.AI system. It enables users to compare multiple construction bids (Bieterangebote) submitted in GAEB X84 format, identify price outliers based on legal frameworks like VOB/A, and maintain a history of submitted offers within a specific construction project.
Sources: app/(chat)/lv/preisspiegel-actions.ts:18-24, lib/gaeb/preisspiegel.ts:1-12
System Architecture and Data Flow
The Preisspiegel system follows a standard client-server architecture using Next.js Server Actions. The frontend handles file uploads and visualization, while the backend processes GAEB XML data and persists the results in a PostgreSQL database.
This diagram illustrates the end-to-end flow from uploading bidder files to receiving a cost comparison analysis.
Sources: app/(chat)/lv/preisspiegel-actions.ts:46-118, app/(chat)/lv/preisspiegel-client.tsx:75-103
Key Data Structures
The system uses specific interfaces to represent the state of a cost comparison:
| Interface | Purpose | Key Fields |
|---|---|---|
BieterAngebot | Represents a single parsed X84 offer. | bieterName, positions, gesamtsumme |
PreisspiegelPosition | A comparative view of one line item across all bidders. | oz, preise, tiefstpreis, durchschnitt |
PreisspiegelResult | The final analysis object returned to the UI. | bieter, ausreisser, bieterCount |
PreisspiegelAusreisser | Details of a detected price outlier. | oz, bieter, abweichungProzent, verdacht |
Sources: lib/gaeb/preisspiegel.ts:16-56
GAEB X84 Parsing Logic
The system processes X84 (Offer Submission) files. While a standard GAEB parser handles the basic structure, the preisspiegel module uses targeted regular expressions to extract pricing data that is specific to the X84 phase, such as Unit Price (UP) and Total Price (TP).
- Bidder Identification: Extracts the bidder name from the
<PrtName>tag where<PrtType>isBI. - Total Sum: Retrieves the final offer amount from the
<OfferTotal>tag. - Numerical Normalization: The
parseGermanNumberutility handles both German (comma decimal) and International (period decimal) notations found in various GAEB exports.
Sources: lib/gaeb/preisspiegel.ts:60-109, lib/gaeb/preisspiegel.ts:200-216
Outlier Detection and Compliance
The calculation engine identifies anomalies in pricing to assist in the evaluation required by VOB/A § 16. It classifies outliers into two categories based on their deviation from the mathematical average of all submitted prices for a specific position (OZ).
This logic helps detect potentially unsustainable low bids or excessive pricing for specific items.
Sources: lib/gaeb/preisspiegel.ts:160-184, lib/gaeb/preisspiegel.test.ts:182-208
Detection Thresholds
- Under-cost (Unterkosten): Triggered when a price is more than 20% below the average. The system adds a note regarding VOB/A § 16, suggesting an investigation into the bidder's cost basis.
- Over-cost (Ueberteuert): Triggered when a price is more than 30% above the average.
Sources: lib/gaeb/preisspiegel.ts:165-180
Database Schema
The system persists comparison results to ensure traceability of the procurement process. The schema uses Drizzle ORM to map offers to projects and users.
The data model separates the bidder header from the specific line-item prices to allow for detailed position-level comparison.
Sources: lib/db/migrations/0001_noisy_lockheed.sql:165-192, lib/db/schema.test.ts:100-115
Data Persistence Workflow
When a new Preisspiegel is generated:
- The system calls
deleteOffersByProject(projectId)to clear previous analysis for that project state. - It iterates through all valid bids.
createOfferinserts the bidder's metadata.replaceOfferPositionsinserts the individual pricing for every item in the LV.
Sources: app/(chat)/lv/preisspiegel-actions.ts:91-114, app/(chat)/lv/preisspiegel-actions.test.ts:107-118
User Interface and Interaction
The PreisspiegelClient component provides a workspace for managing the evaluation.
- Upload: Allows selecting multiple XML/GAEB files. It enforces a minimum requirement of 2 offers and a maximum of 10 for comparison.
- Ranking: Displays a table showing the bidders ordered by total price (Rang 1 being the cheapest).
- Visual Cues: Uses badges and color-coding to highlight the lowest (green) and highest (red) prices for every position.
- Alerts: Lists all detected outliers with specific legal hints.
Sources: app/(chat)/lv/preisspiegel-client.tsx:165-220, app/(chat)/lv/preisspiegel-client.tsx:280-320
Summary
Preisspiegel & Bidder Management automates the complex task of bid evaluation in the construction industry. By parsing standardized GAEB X84 files and applying statistical analysis and legal checks (VOB/A), it provides a transparent and efficient decision-making tool for award recommendations. All offer data is persisted in a structured relational format, allowing for project-wide cost control and historical review.