2 minute read

Terminal OS is a fully interactive terminal emulator that runs in your web browser, built to showcase my professional portfolio in a unique and engaging way. In this post, I’ll dive into the technical architecture and implementation details.

Architecture Overview

Terminal OS is built on a modular architecture with clear separation of concerns:

Terminal OS
├── Core Terminal Engine (xterm.js)
├── Virtual File System
├── Command System (Modular Apps)
├── Window Manager
├── Theme System
└── Effects & Visual Enhancements

Core Technologies

xterm.js

The foundation of Terminal OS is xterm.js, a powerful terminal emulator for the web. It provides:

  • Full VT100/xterm compatibility
  • GPU-accelerated rendering (WebGL)
  • Unicode support
  • Accessibility features
  • Extensible addon system

JavaScript/ES6+

All terminal logic is written in modern JavaScript using:

  • ES6+ classes for modularity
  • Async/await for API calls
  • Event-driven architecture
  • Functional programming patterns

Jekyll

The site is built with Jekyll for static site generation, allowing:

  • Easy content management
  • GitHub Pages integration
  • Fast loading times
  • SEO optimization

Key Components

1. Virtual File System

The virtual filesystem (filesystem.js) provides a complete directory structure:

class VirtualFileSystem {
  constructor() {
    this.fs = {
      '/': { type: 'directory', children: {} },
      '/home/user': { /* user files */ },
      '/companies': { /* company records */ },
      '/achievements': { /* achievement logs */ }
    };
  }
}

Features:

  • Directory navigation (cd, ls)
  • File reading (cat)
  • Path resolution and normalization
  • Support for relative and absolute paths

2. Command System

Each command is implemented as a modular app class:

class WhoAmIApp {
  constructor(terminal, filesystem, windowManager, os) {
    this.terminal = terminal;
    // ...
  }
  
  async run(args) {
    // Command implementation
  }
}

This modular approach makes it easy to:

  • Add new commands
  • Maintain existing ones
  • Test individual components
  • Reuse functionality

3. Boot Sequence

The boot sequence (boot-sequence.js) simulates a real computer startup:

  1. BIOS: Hardware checks and POST
  2. Boot Loader: OS selection and kernel loading
  3. Init: System services initialization

This creates an immersive experience that sets the tone for the terminal.

4. Real-time GitHub Integration

The terminal integrates with GitHub’s API to fetch live data:

async fetchRepositories() {
  const response = await fetch(
    `https://api.github.com/users/${username}/repos`
  );
  // Process and display repositories
}

Features:

  • Live repository listing
  • Real-time star counts
  • Language detection
  • Update timestamps

5. Theme System

Multiple themes are available:

  • Matrix: Classic green phosphor (default)
  • Amber: Vintage amber terminal
  • Hacker: Bright green on black
  • Cyberpunk: Neon colors

Themes are managed through a centralized ThemeManager class.

Advanced Features

Search Functionality

  • Terminal content search (Ctrl+F)
  • Result highlighting
  • Case-sensitive/insensitive options

Syntax Highlighting

  • File type detection
  • ANSI color codes
  • Support for multiple languages

State Persistence

  • Terminal state serialization
  • Command history
  • Theme preferences (localStorage)

Performance Optimizations

  1. Lazy Loading: Commands loaded on demand
  2. Caching: GitHub API responses cached
  3. Debouncing: Input handling optimized
  4. WebGL Rendering: GPU acceleration for smooth scrolling

Browser Compatibility

Terminal OS works on:

  • Chrome/Edge (recommended)
  • Firefox
  • Safari
  • Mobile browsers (responsive design)

Future Enhancements

Planned improvements include:

  • xterm.js advanced addons (Search, Unicode11, Serialize, Image)
  • Enhanced cat command with line numbers and syntax highlighting
  • Web3OS integration for decentralized capabilities
  • More interactive commands and mini-games

Open Source

The Terminal OS codebase is available on GitHub. Feel free to explore, fork, and contribute!

Repository: oyi77/oyi77.github.io

Conclusion

Terminal OS demonstrates the power of modern web technologies to create immersive, interactive experiences. By combining xterm.js with a modular architecture, we’ve created a unique portfolio that showcases both technical skills and professional achievements.

Try it yourself at /terminal/!


Built with ❤️ using xterm.js, JavaScript, and Jekyll