How anmolsaini16/mapcn works
Purpose and Runtime
mapcn is a Next.js/React site and distributable component registry for ready-to-use MapLibre GL map UI components. It uses Tailwind and shadcn/ui conventions, with CARTO/OpenStreetMap-compatible basemap providers. Primary application shell: src/app/layout.tsx, src/app/(main)/layout.tsx, and src/styles/globals.css.
Site Entry Points
The landing page presents component examples at src/app/(main)/(home)/page.tsx. Documentation is routed under src/app/(main)/docs, while the block catalog is served by src/app/(main)/blocks/page.tsx. Individual installable block previews use dynamic routes at src/app/(view)/view/[name]/page.tsx.
Core Map Component Layer
The foundational React/MapLibre-facing implementation is src/registry/map.tsx. Documentation examples exercise its declarative map, layer, marker, popup, route, control, GeoJSON, cluster, and arc capabilities, notably under src/app/(main)/docs/_components/examples and src/app/(main)/docs/basic-map/page.tsx. This registry code is the source material consumers install or adapt.
Registry and Distribution Boundary
Registry metadata describes published components in registry.json; generated/public registry payloads are in public/r/registry.json and per-block JSON files such as public/r/analytics-map.json. The registry block source lives under src/registry/blocks, for example src/registry/blocks/analytics-map/page.tsx, src/registry/blocks/store-locator/page.tsx, and src/registry/blocks/logistics-network/page.tsx. This separates reusable block source from the website that documents and previews it.
Block Preview and Source Flow
The blocks catalog loads block definitions through src/lib/blocks.ts, renders previews using src/app/(main)/blocks/_components/block-preview.tsx, and exposes inspectable source with src/app/(main)/blocks/_components/block-viewer-code.tsx. src/lib/get-block-file-source.ts provides the source-reading boundary. Dynamic /view/[name] pages provide focused rendered previews, likely suitable for iframe embedding via src/app/(main)/blocks/_components/iframe-preview.tsx.
Documentation and Discovery
Docs pages are organized by capability (src/app/(main)/docs/markers/page.tsx, src/app/(main)/docs/routes/page.tsx, src/app/(main)/docs/geojson/page.tsx) and assembled with src/app/(main)/docs/_components/docs.tsx, navigation/sidebar components, and live previews. Shared site navigation and responsive header behavior are centralized in src/lib/site-navigation.ts, src/components/header.tsx, and src/components/command-search.tsx.
LLM-Facing Content
Catch-all LLM routes at src/app/(main)/llm/[[...slug]]/route.ts and src/app/llms.txt/route.ts expose machine-oriented documentation/content. Their generation and prompt logic are bounded in src/lib/llm-content.ts and src/lib/llm-prompts.ts, distinct from browser-rendered docs.
Infrastructure and External Dependencies
The runtime is Next.js with React/TypeScript, Tailwind/PostCSS, and shadcn/ui-style primitives under src/components/ui. Map rendering depends on MapLibre GL and external tile/style/data services selected by consumers; CARTO basemaps are the documented default and carry commercial-use terms. Registry import normalization is maintained by scripts/fix-registry-imports.ts.
Main entry points: blocks Block source · layout.tsx Application shell · page.tsx Block catalog · registry.json Registry metadata
Components 20
Next.js site
- Application shell · Provides global and main-site layout styling.
src/app/layout.tsx - Landing page
src/app/(main)/(home)/page.tsx - Documentation · Capability pages with live map examples.
src/app/(main)/docs/_components/docs.tsx - Map examples
src/app/(main)/docs/_components/examples - Site navigation
src/lib/site-navigation.ts - Header and search
src/components/header.tsx - Block catalog
src/app/(main)/blocks/page.tsx - Block definitions
src/lib/blocks.ts - Block preview
src/app/(main)/blocks/_components/block-preview.tsx - Source viewer · Reads inspectable block source.
src/lib/get-block-file-source.ts - Focused block preview · Renders an individual block by name.
src/app/(view)/view/[name]/page.tsx
Map components
- Map component API · Declarative maps, layers, markers, popups, routes, controls, GeoJSON, clusters, and arcs.
src/registry/map.tsx - Tile, style, and data services · Consumer-selected services; CARTO is the documented default.
Registry distribution
- Block source
src/registry/blocks - Registry metadata
registry.json - Published registry payloads · Generated component and per-block installation payloads.
public/r/registry.json - Registry import normalizer
scripts/fix-registry-imports.ts
LLM content
- LLM routes · Serves machine-oriented documentation content.
src/app/(main)/llm/[[...slug]]/route.ts - LLM content generator
src/lib/llm-content.ts - llms.txt route
src/app/llms.txt/route.ts
Connections 22
- Application shell → Landing page: renders
- Application shell → Documentation: hosts
- Application shell → Block catalog: hosts
- Site navigation → Header and search: drives
- Header and search → Application shell: shared by
- Landing page → Map examples: presents
- Documentation → Map examples: embeds
- Map examples → Map component API: exercises
- Map component API → Tile, style, and data services: renders with
- Block catalog → Block definitions: loads
- Block catalog → Block preview: renders
- Block definitions → Block source: selects
- Block preview → Block source: previews
- Source viewer → Block source: reads
- Focused block preview → Block source: renders
- Block source → Map component API: composes
- Registry metadata → Block source: describes
- Registry import normalizer → Registry metadata: normalizes imports for
- Registry metadata → Published registry payloads: publishes as
- Block source → Published registry payloads: distributed as
- LLM routes → LLM content generator: generates from
- llms.txt route → LLM content generator: serves