How robpruzan/algoviz works
Main Architectural Layers and Components
• Frontend:
• Pages & UI: This is primarily found under the “app” directory which contains pages for editing, creating, visualizing graphs, and sign-in/out (e.g., app/page.tsx, app/editor, app/visualizer).
• State Management & Context: Redux (in redux/) and various context providers (e.g., AuthProvider, CanvasProvider) in the “app” folder, plus custom hooks for canvas interactions and code storage.
• Backend/API:
• API Endpoints: The “app/api” folder houses dynamic routes for creating, editing, deleting, and fetching algorithms, playgrounds, and code execution (including a separate exec endpoint).
• Authentication: Managed via NextAuth integrated in the “app/api/auth/[…nextauth]” folder.
• Code Execution Server: An endpoint that takes code from the editor, processes it (likely via the “code-runner” module), and streams back the output to the browser for direct visualization on the canvas.
• Database and Persistence:
• Prisma is used for database interactions, as indicated by the “prisma” folder (with plenty of migration files) and the “lib/prisma.ts” file.
• Desktop Integration:
• There’s a “src-tauri” directory, which shows the project is also set up to be built as a desktop application using Tauri and Rust.
• Utility and Library Modules:
• “lib” contains utilities for canvas drawing, work with language snippets, and socket functionality.
• “hooks” and “context” provide custom logic for animations, network interactions, and algorithm visualization.
Interactions and Data Flow
• Frontend Communication: The frontend is made up of multiple pages (coding editor, graph visualizer, admin pages) that use React context providers, Redux for state management, and custom hooks to manage UI state and handle events.
• Code Execution: A dedicated endpoint under “app/api/exec/route.ts” handles code execution requests. Once the user submits code, the server processes it (using code-runner utilities) and returns visualized data (graph state changes, call stacks, etc.).
• Desktop Integration: Optionally, show a branch for Tauri which encapsulates a similar frontend view packaged into a desktop app through the “src-tauri” module.
Architectural Patterns and Technologies
• Full-Stack Separation: Clearly differentiate between the frontend (React/Next.js, Redux, Context) and the backend (Next.js API routes, custom code execution logic, database access via Prisma).
• Code Execution Pipeline: Emphasize that there is an interactive code execution server that takes user-submitted code, processes it, and then relays execution state back to the UI.
• Reusable Components and Hooks: Note the emphasis on modularity in the front end through context providers, UI components, and hooks.
Technologies and Libraries
• That Next.js underpins both the frontend and server-side routes.
• Use of Redux, NextAuth, Prisma, and Tauri, along with various custom hooks (for handling canvas interactions, code execution monitoring, etc.) and utility libraries (for canvas drawing, socket communication, etc.).