How arashsameni/manocomputer works
Project type and purpose
• This is a full-stack, cross-platform desktop application (Electron + React frontend, Flask backend) that implements an assembler and hardware simulator for Mano’s basic computer.
• The user types or loads .asm code in the UI, clicks “Assemble,” and the code is sent to the backend to be assembled into machine instructions and then simulated through a CPU/RAM model.
File structure
• Top level
• Example_Codes/ – sample .asm programs
• backend/ – Flask API + core simulation logic
• frontend/ – Electron wrapper around a React SPA
• backend modules
• api.py – HTTP endpoints (e.g., /assemble, /run)
• assembler.py – parses .asm into binary
• computer.py – drives fetch-decode-execute cycles
• ram.py, register.py, conditions.py – low-level simulation primitives
• frontend structure
• public/ – static HTML, preload scripts for Electron
• src/ – React entry (index.js), contexts (ComputerContext, ThemeContext), components (CodeEditor, FilesBar, StatusBar, Simulator), assets (syntax highlighter)
• package.json & .env – build and runtime configs for Electron and React
README
• Confirms tech stack: React + Electron, Flask backend.
• Usage section shows two separate processes: flask run + npm run electron-dev.
Main components and interactions
a. Frontend (Electron + React)
– Electron Main Process: launches browser window, loads React app
– React Renderer: UI components grouped under
• LeftSideBar (AboutUs, CodeEditor, FilesBar, StatusBar)
• Simulator pane (Ram view, Registers view)
– Contexts hold theme and simulator state
b. Backend (Flask)
– API Layer (api.py): receives HTTP POST with assembly source or run commands
– Assembler Layer (assembler.py): tokenizes, resolves symbols, produces machine code
– Simulation Layer (computer.py + ram.py + register.py + conditions.py): steps through instructions, updates PC, registers, RAM
c. Data flow
1. User edits or loads .asm in CodeEditor
2. On “Assemble,” React calls POST http://localhost:5000/assemble
3. Flask/api.py invokes assembler, returns object with machine words
4. React updates ComputerContext with new memory image
5. On “Run Step/Toggle,” React calls /step or uses client-side stepping (optional)
6. Simulation results (register values, memory snapshot) flow back to UI
d. External services & files
– Example_Codes folder for file loading in FilesBar
– Prism.js for syntax highlighting, Electron for desktop packaging
Architectural patterns & design principles
• Clear separation of concerns:
• Presentation (React/Electron)
• Application/API (Flask)
• Domain logic (Assembler + Simulator modules)
• Context API in React for global simulator state
• Modular simulation primitives (ram.py, register.py, conditions.py) to keep simulator testable and extensible