Part of the architecture notes indexed in AGENTS.md. Keep each topic in its bullet here; AGENTS.md only lists the topics.
cc_core::mep: plumbing systems and electrical circuits (MepSystem, kind, code, color, board, voltage) live in Project::systems (tracked as settings); pipes, conduits and cable trays are ElementKind::Pipe/Conduit/CableTray(MepSegment) runs with an elevation at each end and the systems they belong to (a tray’s TypeData::CableTray holds width, height and TrayStyle; trays join only trays); a valve is ElementKind::Valve(Valve { host, at }), hosted by a pipe at a distance along it (its TypeData::Valve holds the ValveKind; diameter and system are its pipe’s; repair drops one whose host is not a pipe, remove_element, copies and pad_levels keep it with its pipe); plumbing fixtures and electrical devices are components whose ComponentDef::mep holds fixture units or the device kind and power, connected by Component::system; a component’s ComponentDef::connectors (name, system kind, position and direction expressions, diameter) are where runs join it (cc_geom::component_connectors): the network attaches each to a node of a system of its kind, and mep_connect starts branches there (components without connectors use their insertion point). cc_geom::mep makes the cylinders, tray channels (ModelGeometry::segments, SegmentGeom::tray) and valve bodies (ModelGeometry::valves) and cc_geom::mep_net the networks (ModelGeometry::mep: nodes where runs meet, edges, derived fittings, valves as nodes on their pipes, fixtures and devices attached to nodes), cc_geom::sizing sizes pipes and circuits from them, cc_views::mep draws plumbing and electrical plans (ViewKind::FloorPlan { mep: Some(..) }, the architecture faded; other floor plans leave MEP out; trays in electrical plans, valves in plumbing plans) and the device and valve symbols, cc_views::diagram the panel diagrams (ViewKind::Diagram, headings through the label of generate_labeled), cc_engine::commands::mep holds the commands and the circuit loads (cable_tray and valve the tray and valve commands; IFC export writes IfcCableCarrierSegment CABLETRAYSEGMENT and IfcValve). Systems come in families (SystemKind::class, SystemClass: plumbing, circuits, structured cabling Data, lightning protection Lightning); commands::mep::check_fits takes the families a member may join (pipes plumbing, conduits and trays circuits and cabling, lightning conductors lightning protection, devices their DeviceKind::class), and MepSystem::panel is a circuit’s board or a data system’s rack (DeviceKind::is_board). Lightning protection (cc_core::lightning): conductors are ElementKind::LightningConductor(LightningConductor { run: MepSegment, role }) (role air, down or earth; TypeData::LightningConductor holds the diameter and material; they join only each other), air terminals and earth electrodes are device components (DeviceKind::AirTerminal/EarthElectrode, built-in definitions in component::device_library, made on demand by commands::devices); cc_geom::lightning finds the roof under a point (surface_top, where terminals and conductors land) and checks coverage (check: roof samples against each air termination point alone by the rolling sphere over the eaves plane, plus the mesh width on flat parts; LpsClass gives the radius and mesh), commands in commands::lightning. Structured cabling: data outlets (MepData::Device::ports jacks) and racks are device components; each rack feeds a SystemKind::Data system created by rack_place; Project::outlet_cable estimates each outlet’s cables (mep::cable_length: up to the ceiling, across along the axes, down to the rack, plus slack), shown by cabling_list, element_get and the CableLength schedule field; commands in commands::cabling. Plans of the MepDiscipline::Communications and Lightning disciplines draw them (cc_views::discipline_of); IFC export writes conductors as IfcCableSegment CONDUCTORSEGMENT, terminals and electrodes as user-defined IfcProtectiveDevice, data outlets as IfcOutlet DATAOUTLET, racks as IfcCommunicationsAppliance, systems as IfcDistributionSystem LIGHTNINGPROTECTION/DATA.cc_core::pipe_series: a PipeSeries (id PipeSeriesId, Uid, unique code, name, standard, PipeMaterial, PipeUse, PipeJoint, pressure, SeriesSources) holds its sizes (PipeSize: label, outside de, wall e, inside di, meters; row) and the fittings sold for it (CatalogFitting: FittingRowKind, angle, size/size2, socket and laying lengths z, all optional; key), bounded by the module’s MAX_*/MIN_* and checked by check (errors name the row) and repair. Project::pipe_series is tracked as settings (EditCtx::pipe_series_mut; format 30). cc_core::pipe_file reads and writes series files (JSON, millimeters, FILE_FORMAT 1, read_series bounded and refusing unknown enums and bad rows, write_series one row per line); cc_core::pipe_catalog holds the 22 built-in series (assets/pipes/*.json, research notes in assets/pipes/notes; BUILT_IN, all, series(code), built_in_of, Region; names translated by the pipe-series-<code> keys), copied into a project on first use (Project::built_in_pipe_series). TypeData::Pipe has series, size (a row’s label) and a free type’s inside; Project::pipe_row gives a type’s series and row, ElementType::inside_diameter the row’s di, else inside. EditCtx::finish → sync_pipe_series (first, when settings or a pipe type changed) keeps a series type’s diameter at its row’s de in the same transaction and makes a type whose series or size is gone free (keeping the diameter); repair_pipe_series bounds series, makes codes and uids unique and drops dangling references. The templates’ pipe types are sizes of BR-PVC-SOLD and BR-PVC-ESG-N (metric) or US-PVC-SCH40 and US-PVC-DWV (imperial), and files before format 30 link the template’s pipe types by name and diameter (link_old_template_pipes). cc_geom::sizing measures speeds in the type’s inside diameter and sizes a run of a series within it (series_supply_row, series_drain_row; PipeSizing::size); mep_size_apply keeps a run in its series, making the missing row’s type (created). cc_engine::commands::pipes: pipe_catalog, pipe_series_list, pipe_series_get, pipe_series_import (code/path/text, on_clash, sizes), pipe_series_export, pipe_series_delete (detach), pipe_type_create; type_set takes series (code, name or id; null frees the type) and refuses a size the series lacks before the edit (check_size); type_get and element_get of a pipe add derived.inside_diameter, wall, series_code, size. Fitting matching, fitting geometry, cut lengths, schedules and IFC are not done yet.