Architecture
swAItch follows SOLID principles with a clean, modular design that makes it easy to extend and maintain.Module Map
Data Flow
Design Principles
Open/Closed Principle
New IDE parsers are added by creating a new class that extendsBaseParser. No existing code is modified.
Dependency Inversion
Tools depend entirely on the centralswaitch.db, never directly on parsers. Parsers are orchestrated exclusively by sync.py.
Single Responsibility
| Module | Responsibility |
|---|---|
models.py | Data structures |
config.py | Path resolution |
parsers/base.py | Parser contract |
parsers/registry.py | Parser discovery |
parsers/cursor.py | Cursor-specific parsing |
db/models.py | SQLAlchemy local cache schemas |
db/session.py | SQLAlchemy connection pool |
sync.py | Synchronizing parsers into swaitch.db |
tools.py | MCP tool definitions (reads from DB) |
watcher.py | File system monitoring (triggers sync) |
server.py | Wiring everything together |
File Watcher
The watcher runs as an async background task during server lifespan:- Collects watch paths from all available parsers
- Uses
watchfiles(Rust-based) for efficient monitoring - On change → triggers
sync.pyin a background thread pool - Next tool call picks up fresh data instantly from the local
swaitch.dbsqlite file

