How piyushvirani/librange works
Purpose and Entry Points
LibRange is a client-side React application for locating MacOdrum Library items from call numbers. It maps a user-entered call number to both a physical shelf range and a broader library section. Browser startup is src/main.tsx; application orchestration is in src/App.tsx.
UI Interaction Layer
The UI is organized around call-number input, result presentation, and a visual location display:
• src/components/CallNumberForm.tsx
• src/components/ResultPanel.tsx
• src/components/MapView.tsx
App.tsx owns the lookup workflow and passes input/results between these components. MapView is the physical-location boundary, consuming range/floor information rather than performing call-number parsing itself.
Call-Number Normalization Pipeline
User input is transformed into a comparable ordering key before data lookup:
• src/lib/parseCallNumber.ts
• src/lib/getCallNumberKey.ts
• src/types/ParsedCallNumber.ts
This isolates human-readable library call-number syntax from lookup logic. Parsing yields structured call-number data; key generation provides a sortable representation used to compare input against configured spans.
Physical Range Resolution
Shelf lookup is driven by physical range records:
• src/lib/findRange.ts
• src/data/ranges.json
• src/types/RangeRecord.ts
Each range contains independent left- and right-side spans plus floor and range identifiers. findRange computes comparison keys at runtime from the stored human-readable boundaries, then determines the matching physical range/side. Result shape is represented by src/types/RangeMatch.ts.
General Section Resolution
Section labeling is a separate, parallel lookup rather than a property inferred from a physical shelf:
• src/lib/findSection.ts
• src/data/sections.json
• src/types/SectionRecord.ts
This separation is intentional: one physical range may span multiple general sections. The application independently resolves the section span and combines it with physical lookup output for display. src/types/SectionMatch.ts defines the resulting section match.
Data and Control Flow
The main flow is: form submission → parse/normalize call number → resolve physical range from ranges.json → resolve section from sections.json → render textual result and map location. Invalid or unmatched input remains at the application/UI boundary; lookup libraries operate on normalized values and static record data.
Runtime and Delivery
The project is TypeScript + React, bundled with Vite:
• package.json
• vite.config.ts
• src/main.tsx
There is no backend, database, or external service indicated. Shelf and section data is versioned in the frontend bundle. Production artifacts are present under dist/index.html and dist/assets/.
Main entry points: App.tsx Lookup orchestration · findRange.ts Physical range resolver · getCallNumberKey.ts Sortable key generator · findSection.ts Section resolver
Components 18
React UI
- Browser entry
src/main.tsx - Lookup orchestration · Coordinates validation, parallel lookups, and rendered results.
src/App.tsx - Call number form
src/components/CallNumberForm.tsx - Result panel
src/components/ResultPanel.tsx - Map view · Consumes resolved range and floor information only.
src/components/MapView.tsx
Lookup pipeline
- Call number parser · Converts library syntax into structured data.
src/lib/parseCallNumber.ts - Parsed call number
src/types/ParsedCallNumber.ts - Sortable key generator · Creates comparable ordering keys.
src/lib/getCallNumberKey.ts - Physical range resolver · Matches a call number against left and right shelf spans.
src/lib/findRange.ts - Range match
src/types/RangeMatch.ts - Section resolver · Independently matches broader library section spans.
src/lib/findSection.ts - Section match
src/types/SectionMatch.ts
Bundled reference data
- Shelf ranges · Physical ranges with side spans, floor, and identifiers.
src/data/ranges.json - Range record
src/types/RangeRecord.ts - Section spans · General section boundaries independent of shelf ranges.
src/data/sections.json - Section record
src/types/SectionRecord.ts
Other components
- Vite build · Bundles the client application for production.
vite.config.ts - Production bundle
dist/index.html
Connections 21
- Vite build → Browser entry: bundles
- Vite build → Production bundle: emits
- Browser entry → Lookup orchestration: mounts
- Lookup orchestration → Call number form: collects input
- Call number form → Lookup orchestration: submits call number
- Lookup orchestration → Call number parser: parses
- Call number parser → Parsed call number: produces
- Call number parser → Sortable key generator: normalizes
- Sortable key generator → Physical range resolver: comparison key
- Sortable key generator → Section resolver: comparison key
- Shelf ranges → Physical range resolver: range spans
- Range record → Shelf ranges: defines records
- Physical range resolver → Sortable key generator: keys stored boundaries
- Physical range resolver → Range match: returns
- Section spans → Section resolver: section spans
- Section record → Section spans: defines records
- Section resolver → Section match: returns
- Lookup orchestration → Physical range resolver: resolves range
- Lookup orchestration → Section resolver: resolves section
- Lookup orchestration → Result panel: renders combined result
- Lookup orchestration → Map view: passes range and floor