How seeed-studio/sensecraft-web-toolkit works
Project Type & Purpose
• This is a front-end Single-Page Application (SPA) built with Vue.js (via Vite) and Vuetify.
• Purpose: Provide a visual programming toolkit for AIoT devices (SenseCraft platform), including device flashing, configuration, and interaction.
File Structure
• Top-level build & config:
• config/ (Vite configs, plugins for compression, image minification, visualizer)
• docker/ (Dockerfile + Nginx config)
• GitHub workflows & Husky (CI/CD, linting, commit hooks)
• Makefile, package.json, env files
• src/ directory (runtime code):
• src/main.ts + index.html → app bootstrap
• src/App.vue + pages/ + components/ → UI layer
• src/router/ → navigation & route guards
• src/store/ → Vuex store modules (app state, device state, tab-bar)
• src/sscma/ → device-communication library (serial, XModem, device abstractions for Grove AI WE2, Xiao ESP32S3)
• src/utils/ → helper services (env, event bus, firebase, flash, timer, route listener)
• src/hooks/ → composable logic (device manager, permission, themes, loading, detection)
• src/assets/ → static images, styles, world.json
• Config files: eslint, prettier, stylelint, tsconfig
README Insights
• Built with Vue.js & Vuetify
• Deployable via Vite build → dist → served by any static server (e.g., Nginx or http-server)
• Customizable for different SenseCraft environments
Main Components & Their Relationships
a. Browser (User’s machine)
• Hosts the Vue SPA served by Nginx (in production) or Vite dev server
b. Vue Application
• UI Layer: pages & reusable components
• Router: client-side routing & guards
• Store: centralized state management
• Service Layer:
• sscma library → direct device communication (Web Serial / USB)
• utils/firebase → optional cloud services
• utils/flash → firmware flashing logic
• hooks/composables → isolate business logic
c. External Systems
• SenseCraft backend API (config, telemetry) – endpoint defined via env variables
• IoT Devices (Grove AI WE2, Xiao ESP32S3) via serial protocols (XModem, custom drivers)
• Firebase (for authentication, data storage)
d. Build & Deployment Pipeline
• GitHub Actions → run lint/tests → build Docker image
• Docker + Nginx → serve built files
• CI/CD pushes to hosting or edge servers
Architectural Patterns & Principles
• Modular SPA: clear separation between UI, state, and services
• Composable MVVM (Vue + Composition API)
• Plugin-based build (Vite + custom plugins for optimization)
• Layered design:
• Presentation (components/pages)
• Application (router + store)
• Infrastructure (sscma, utils, external APIs)