How swifweb/web works
Project type and purpose
• This is an open-source Swift library (“SwifWeb”) exposing the DOM, CSS, and virtually every modern Web API to Swift developers, plus a lightweight SPA/PWA framework for building web applications.
• It is not a standalone service but a layered library intended to be consumed (via Swift Package Manager) by user projects and orchestrated by the companion CLI tool “webber.”
File structure
• Top-level Packaging:
• Package.swift, README.md, LICENSE, .gitignore
• “Sources/” contains all Swift modules, grouped by functionality:
• WebFoundation – low-level JS/Web interop primitives, URL, Blob, State, Console, etc.
• Individual Web API wrappers – e.g. DOM, CSS, FetchAPI, WebSocketAPI, StorageAPI, ServiceWorker, CanvasAPI, GeolocationAPI, etc.
• Web – the high-level SPA/PWA framework (AppBuilder, Controllers, Routing, Pages, Middleware, WebApp, etc.)
• Worker/WorkersAPI – wrappers for Worker/SharedWorker APIs
• “Tests/” holds unit tests for ServiceWorker and Web modules.
README
• Confirms library purpose: “build your awesome reactive web app in beloved Swift”
• Mentions CLI workflow: webber new, webber serve, webber release
Components
a. Foundation layer (“WebFoundation”)
b. API wrapper layer (grouped functional modules: DOM, CSS, FetchAPI, Events, StorageAPI, ServiceWorker, WebSocketAPI, etc.)
c. Framework layer (“Web” module – AppBuilder, Controllers, Routing, Pages, Middleware)
d. Orchestration/CLI (“webber” tool, .webber folder)
e. Tests (indicate where tests plug in)
f. User-facing applications that consume the library (i.e. SPA / PWA projects generated by webber)
Relationships and interactions
• Tests connect to the modules they verify.
Architectural patterns & design principles
• Layered Architecture: clear separation of concerns from low-level interop to high-level app constructs.
• Modular design: each Web API lives in its own module, promoting extensibility.
• MVC-like in the “Web” framework: Controllers, Views (DOM/CSS builders), Routing.
• Dependency Inversion: high-level modules depend on abstract protocols in lower layers.
Relevant technologies
• Swift 5.7
• Swift Package Manager (Package.swift)
• Browser JavaScript engine (JSValuable, JSClass in WebFoundation)
• Command-line tool “webber” (not in this repo, but referenced)