How cook1ek1w1/waypoint-maker works
Project Type and Purpose
• Waypoint Maker is a full‑stack Next.js web application for building, validating, and organizing waypoint missions for UAVs.
• It combines a rich React‑based frontend (pages, layouts, map and editing UI) with server‑side API routes and a database layer (Prisma).
File Structure
• src/app/… contains Next.js pages and API routes (including auth at src/app/api/auth).
• src/components/… hosts React UI components (dashboard, map layers, modals, toolbars, editors).
• src/lib/… implements core mission‑generation logic (dubins curves, optimisation, I/O routines).
• src/util/… houses utility modules (authentication client, context providers for map/waypoints/vehicle).
• prisma/schema.prisma defines the DB schema.
• Configuration files (next.config.js, postcss.config.js, tailwind.config.ts) set up build and styling.
README
• Confirms tech stack: Bun runtime, Next.js, Prisma.
• Outlines features: grouping, validation, layer toggling.
• Mentions environment variables and typical dev/test/build commands.
Main Components
a. Frontend Layer
• Next.js React UI (pages, components, contexts)
• Rendering module (Leaflet or custom mapController + layers)
• State management (React Contexts: WaypointContext, MapContext, VehicleTypeContext)
b. API Layer
• Next.js server‑side API routes (src/app/api/auth, other REST or RPC endpoints)
• Authentication handler (session, token verification)
c. Business Logic Layer
• Core libraries in src/lib: waypoint generation, optimisation algorithms, file import/export (missionIO)
• Utility modules for geometry, maths, data conversion
d. Persistence Layer
• Prisma ORM connected to a relational database (PostgreSQL, MySQL, etc.)
• prisma/schema.prisma defines entities (Waypoint, Mission, User, etc.)
e. External Services
• OAuth or external auth provider used by the auth API
• Optional “cloud sync” storage endpoint for mission I/O
f. Development Tooling & CI
• Bun runtime, build scripts, CI workflow (.github/workflows/bun-test.yml)
Relationships and Data Flows
• User → Browser → Next.js Frontend
• Frontend dispatches actions (create/edit waypoints, validate, group) → calls API routes
• API routes invoke business logic modules (lib/dubins, lib/optimisation, lib/missionIO)
• Business logic reads/writes via Prisma to the database
• Frontend subscribes to state via React Contexts, re‑renders map and UI
• External auth service is called during login flows
• Cloud sync endpoints are invoked from modal I/O components
Architectural Patterns & Principles
• Separation of Concerns: UI vs. API vs. core logic vs. persistence
• Modular design: each feature set lives in its own directory (map layers, modals, waypointIO, optimisation)
• Context-based state management for global state (React Context Providers)
• API facades: Next.js Routes expose clean handlers that delegate to utility libraries