How 1mlm/aui-map works
Purpose and Entry Points
AUI Map is a public, interactive campus-map PWA for Al Akhawayn University. The primary public route is src/app/page.tsx; global document/UI setup is in src/app/layout.tsx. It also exposes an authenticated admin surface under src/app/admin/(dashboard)/page.tsx and a share-target endpoint at src/app/share-target/route.ts.
Public Map Experience
The map is a client-side interactive composition centered on src/map/MapExperience.tsx and src/map/MapCanvas.tsx. It renders campus pins, supports pan/zoom, search, tag filtering, responsive detail views, directions, and attachment display through components such as src/map/MapDetailPanel.tsx and src/map/AttachmentCarousel.tsx. Browser-only capabilities—geolocation, compass, wake lock, and install prompts—are isolated in map hooks/components including src/map/useUserLocation.ts and src/map/useCompassHeading.ts.
Map Data Boundary
Server-side map data is assembled by src/map/getMapData.ts, transformed into UI map entities by src/map/mapItemFromDb.ts, and typed in src/map/types.ts. Prisma models and relational constraints are the durable source of truth in prisma/schema.prisma, with schema evolution captured under prisma/migrations/. This boundary separates database-shaped pins, tags, attachments, links, suggestions, contributions, QR tracking, and panoramas from interactive map state.
Community Contributions
Unauthenticated visitors can submit pin suggestions and upload contributed media. Client interactions originate in src/map/SuggestionForm.tsx, src/map/suggestionActions.ts, and src/map/contributeActions.ts; uploads enter via src/app/api/contribute/upload/route.ts. These flows persist reviewable records rather than directly changing published map content, creating a moderation boundary before admin approval.
Administration and Moderation
The admin App Router area uses dashboard layout and server actions to manage published content and incoming work. Key domains are pins (src/app/admin/(dashboard)/pins/actions.ts), tags (src/app/admin/(dashboard)/tags/actions.ts), submissions (src/app/admin/(dashboard)/submissions/actions.ts), and suggestions (src/app/admin/(dashboard)/suggestions/actions.ts). Authentication begins at src/app/admin/login/actions.ts and is enforced through src/utils/requireAuth.ts.
Media and Panorama Pipeline
Admin attachment uploads are handled separately at src/app/api/admin/attachments/upload/route.ts; cloud storage integration is encapsulated in src/utils/cloudinaryUpload.ts and src/utils/cloudinary.ts. The repository also supports placement and viewing/capture of panoramas via src/app/admin/(dashboard)/panoramas/PanoramaPlacer.tsx, src/map/PanoramaLayer.tsx, and src/map/panoramaCapture/PanoramaCapture.tsx.
Runtime, Infrastructure, and Offline Delivery
This is a Next.js 16 App Router application running React 19 and TypeScript. PostgreSQL on Neon is accessed through Prisma (src/utils/prisma.ts); media infrastructure includes Vercel Blob per the project stack and Cloudinary-oriented utility modules present in the codebase. PWA/offline behavior is delivered by Serwist through src/app/sw.ts, src/app/serwist/[path]/route.ts, and the offline fallback src/app/~offline/page.tsx. Deployment-facing behavior is configured in next.config.ts and request mediation is likely centralized in src/proxy.ts.
Components 21
Public map
- Public route
src/app/page.tsx - Global layout
src/app/layout.tsx - Map experience · Owns interactive map state and responsive views.
src/map/MapExperience.tsx - Map canvas · Renders pins with pan, zoom, search, filters, and directions.
src/map/MapCanvas.tsx - Details & attachments
src/map/MapDetailPanel.tsx - Location & compass · Isolates browser-only location, heading, wake-lock, and install behavior.
src/map/useUserLocation.ts - Share target
src/app/share-target/route.ts
Contributions
- Suggestion form
src/map/SuggestionForm.tsx - Contribution actions · Creates reviewable suggestions and contributed-media records.
src/map/suggestionActions.ts - Contribution upload API
src/app/api/contribute/upload/route.ts
Admin & media
- Admin login
src/app/admin/login/actions.ts - Admin dashboard · Moderates incoming work and manages published content.
src/app/admin/(dashboard)/page.tsx - Content moderation · Manages pins, tags, submissions, and suggestions.
src/app/admin/(dashboard)/pins/actions.ts - Admin attachment API
src/app/api/admin/attachments/upload/route.ts - Panorama tools · Places, captures, and displays panoramas.
src/app/admin/(dashboard)/panoramas/PanoramaPlacer.tsx
Data & delivery
- Map data assembly · Loads database records and maps them to UI entities.
src/map/getMapData.ts - Prisma access
src/utils/prisma.ts - PostgreSQL schema · Source of truth for map content, moderation records, media, QR tracking, and panoramas.
prisma/schema.prisma - Cloud media
src/utils/cloudinaryUpload.ts - Offline service worker · Serves cached PWA behavior and offline fallback.
src/app/sw.ts - Request proxy
src/proxy.ts
Connections 21
- Global layout → Public route: wraps
- Public route → Map experience: renders
- Map experience → Map canvas: drives
- Map experience → Details & attachments: shows selected item
- Map experience → Location & compass: uses
- Map experience → Map data assembly: receives map entities
- Map data assembly → Prisma access: queries
- Prisma access → PostgreSQL schema: persists
- Suggestion form → Contribution actions: submits
- Contribution actions → PostgreSQL schema: creates review records
- Contribution upload API → Cloud media: uploads media
- Contribution upload API → PostgreSQL schema: records contribution
- Admin login → Admin dashboard: authenticates access
- Admin dashboard → Content moderation: manages content
- Content moderation → PostgreSQL schema: moderates and publishes
- Admin attachment API → Cloud media: uploads attachments
- Panorama tools → PostgreSQL schema: stores panorama placement
- Panorama tools → Map experience: provides panorama view
- Offline service worker → Public route: caches and falls back
- Request proxy → Admin dashboard: mediates requests
- Share target → Map experience: shares into map flow