How ebertmi/webbox works
Project Overview and Purpose
• Type: Web-based editor with support for secure remote code execution (“sourcebox”), implemented as a full-stack web application.
• Purpose: It lets users (students and admins) interact with code examples, documents (using the IPYNB standard), and presentations. The app supports multiple client applications (IDE, dashboard/administration, notebook/presentation) and uses websockets for real-time event tracking.
Main Components
a. Client-Side Applications:
• IDE: A React-based coding environment located in directories such as client/js, common/components/ide, and common/models/project.
• Dashboard/Administration: React and Redux based client (see common/components/admin, common/containers/admin) which is also isomorphically rendered from the server.
• Notebook & Presentation: React-based implementations using Immutable.js; referenced in common/components/notebook, common/components/presentation.
b. Server-Side:
• API/Controllers: Structured under lib/controllers (for authentication, courses, documents, dashboards, etc.), which tie the requests (defined via routes in lib/routes and common/route) to the corresponding business logic.
• Templating & Views: Uses the Jade engine (files in lib/views) to render pages for server-side responses.
• Websocket/Realtime Communication: Handled by lib/controllers/websocket.js and configuration in the server startup (webbox.babel.js) to allow bidirectional communication.
• Command-Line Interface (CLI): Tools under bin/ (e.g., cli.js) that allow administrative user management.
c. Database:
• RethinkDB: The application’s data store for documents, code examples, and user data. The models in both common/models and lib/models are built using the Thinky ORM to interact with RethinkDB.
• Migration scripts (migrations folder) are also used to manage database schema changes.
d. Other Key Integrations:
• Configuration: Provided through the config module with multiple JSON files (default, development, production) and a custom config module in config/webbox.config.js.
• Authentication & Authorization: Handled via various auth files in lib/auth and checks in lib/roles.
• Email and Notification: Implemented via lib/mail (templates and utilities).
Relationships and Interactions
• The client side makes HTTP requests to RESTful API endpoints (as defined in lib/api) and establishes websocket connections (lib/controllers/websocket) with the server.
• The server’s controllers process incoming requests, interact with the models (via Thinky), and render responses (using Jade templates or JSON for API responses).
• The separation between the three clients creates clear boundaries in communication. For example, the IDE uses a custom model (EventEmitter-based) to notify changes, whereas the Notebook/Presentation leverage Immutable.js.
• A migration component is positioned as a utility that touches the database for schema updates.
• The CLI becomes a side component that allows for administrative operations away from the main HTTP request flow.
Architectural Patterns and Designs
• MVC-Style: The structure clearly separates routes, controllers (lib/controllers), and views/templates (lib/views). Models using Thinky encapsulate the business logic.
• Real-time Communication: The use of websockets to push events between server and client.
• Modular Frontend Applications: Different client apps (IDE, dashboard, notebook/presentation) share common React components (under common/components) yet have distinct models (e.g., using plain objects versus Immutable.js).
• Dependency Injection & Configuration: Use of the config module to allow environment-specific configuration.
Detail
• Do not over-simplify the components. Instead separate even minor utilities (migration scripts, authentication modules, web socket handling) if their interactions are critical for understanding the overall architecture.