How irunga1/flexjs works
1. What this repo is
LiteFlex is a browser-side, JavaScript-module microframework centered on one idea: a main*.js entrypoint wires together a data model, a view, optional hooks, and a stylesheet, and the core coordinates the lifecycle.
2. Top-level architecture
The repository is organized into clear layers:
- core/ for orchestration
- models/ for data access and normalization
- views/ for DOM rendering
- helper/ for pre/post render hooks
- css/ for page-specific styling
- main*.js for demo-specific composition
- index*.html / movies.html for minimal browser shells
3. Core runtime boundary
core/Flex.js is the main runtime controller. It waits for DOMContentLoaded, can inject a stylesheet, optionally shows a temporary blackout/loading overlay, instantiates the chosen model, and then invokes the view after data is ready. Flex2.js and Flex3.js appear to be alternative/experimental core variants.
4. Data layer boundary
models/ApiModule.js is the common base for fetching and response normalization. It fetches data, then normalizes API shapes by moving a configured dataKey into results. Specific data adapters like TMDB, RickAndMorty, FakeStore, and News sit on top of that pattern and encapsulate source-specific URL and response logic.
5. Data sources and external dependencies
The demos connect to multiple sources with different structures:
- TMDB for movie/streaming-style UIs
- Rick and Morty API
- Fake Store API
- local/news data via data/news.js
This makes the model layer the main integration boundary with external services.
6. Render layer boundary
views/ contains reusable rendering functions such as movieCard, productCard, newsCard, playerView, and card-list helpers. These views are responsible for producing the DOM content, typically by writing markup into a container rather than maintaining their own state.
7. Hook/extensibility layer
helper/ contains pre-render and post-render hooks such as preRenderFn.js and postRenderFn*.js. The lifecycle is intentionally extensible: the core can run code before rendering to prepare the UI, and after rendering to apply behavior or enhancements.
8. Composition happens in entrypoints
The main*.js files are the application assembly points. Each one selects:
- the API URL or data source
- the model class
- the view function
- the CSS file
- the optional pre/post hooks
This is where the framework is “configured” per demo.
9. UI shells and page variants
The HTML files are minimal shells that host the app: index.html, movies.html, indexnews.html, indexplayer.html, and index---.html. They mostly provide the mounting container and let the JS pipeline build the interface dynamically.
10. Styling strategy
Styles are separated by demo or domain in css/ (netflix.css, news.css, player.css, page.css, local.css). The core can inject a stylesheet dynamically, so presentation is part of the framework flow rather than static page setup.
11. Observed end-to-end flow
The typical data/render path is:
main*.js → Flex core → model fetch/normalize → pre-render hook → view render into container → post-render hook → optional loading overlay teardown.
That is the central architecture diagram to capture.
12. Repository character
This is not a generic app repo; it is a framework-like codebase with multiple demos proving the same pipeline across domains. The important architectural boundary is between orchestration (core), data access (models), and presentation (views), with main*.js acting as the composition root.
Main entry points: Flex.js Flex.js · ApiModule.js ApiModule.js · main.js main.js · main2.js main2.js
Components 34
Composition
Demo entrypoints and HTML shells
- main.js · Primary demo composition root
main.js - main2.js · Alternative demo composition
main2.js - main3.js · Alternative demo composition
main3.js - main4.js · Alternative demo composition
main4.js - main5.js · Alternative demo composition
main5.js - main7.js · Alternative demo composition
main7.js - index.html · Browser shell for demos
index.html - movies.html · Movie demo shell
movies.html - indexnews.html · News demo shell
indexnews.html - indexplayer.html · Player demo shell
indexplayer.html
Runtime
Core orchestration layer
Data
API adapters and local data sources
Presentation
Views, hooks, and styling
- movieCard · Movie card renderer
views/movieCard.js - productCard · Product card renderer
views/productCard.js - newsCard · News card renderer
views/newsCard.js - playerView · Player renderer
views/playerView.js - viewCardList · Card list composition helper
views/viewCardList.js - viewCardListAlt · Alternative list composition helper
views/viewCardListAlt.js - preRenderFn · Pre-render lifecycle hook
helper/preRenderFn.js - preRenderFn5 · Alternative pre-render hook
helper/preRenderFn5.js - postRenderFn · Post-render lifecycle hook
helper/postRenderFn.js - postRenderFn2 · Alternative post-render hook
helper/postRenderFn2.js - postRenderFn3 · Alternative post-render hook
helper/postRenderFn3.js - postRenderFn5 · Alternative post-render hook
helper/postRenderFn5.js - netflix.css · Movie/streaming styling
css/netflix.css - news.css · News styling
css/news.css - player.css · Player styling
css/player.css
Connections 40
- main.js → Flex.js: uses · Composition root wires the runtime
- main2.js → Flex.js: uses · Composition root wires the runtime
- main3.js → Flex.js: uses · Composition root wires the runtime
- main4.js → Flex.js: uses · Composition root wires the runtime
- main5.js → Flex.js: uses · Composition root wires the runtime
- main7.js → Flex.js: uses · Composition root wires the runtime
- main.js → TMDB: configures · Selects a model per demo
- main2.js → RickMorty: configures · Selects a model per demo
- main3.js → FakeStore: configures · Selects a model per demo
- main4.js → News: configures · Selects a model per demo
- main5.js → news.js: configures · Selects a local data source
- main.js → movieCard: configures · Selects a view per demo
- main2.js → viewCardList: configures · Selects a view per demo
- main3.js → productCard: configures · Selects a view per demo
- main4.js → newsCard: configures · Selects a view per demo
- main5.js → playerView: configures · Selects a view per demo
- Flex.js → ApiModule.js: instantiates · Core creates the configured model
- ApiModule.js → TMDB: base for · Shared fetch/normalize pattern
- ApiModule.js → RickMorty: base for · Shared fetch/normalize pattern
- ApiModule.js → FakeStore: base for · Shared fetch/normalize pattern
- ApiModule.js → News: base for · Shared fetch/normalize pattern
- News → news.js: reads · Uses local news dataset
- Flex.js → preRenderFn: hooks · Optional lifecycle hook before render
- Flex.js → postRenderFn: hooks · Optional lifecycle hook after render
- Flex.js → postRenderFn2: hooks · Optional lifecycle hook after render
- Flex.js → postRenderFn3: hooks · Optional lifecycle hook after render
- Flex.js → postRenderFn5: hooks · Optional lifecycle hook after render
- Flex.js → movieCard: renders · Invokes selected view after data is ready
- Flex.js → productCard: renders · Invokes selected view after data is ready
- Flex.js → newsCard: renders · Invokes selected view after data is ready
- Flex.js → playerView: renders · Invokes selected view after data is ready
- movieCard → viewCardList: composes · Movie rendering uses list helpers
- productCard → viewCardListAlt: composes · Product rendering uses list helpers
- Flex.js → netflix.css: injects · Runtime can attach demo stylesheet
- Flex.js → news.css: injects · Runtime can attach demo stylesheet
- Flex.js → player.css: injects · Runtime can attach demo stylesheet
- index.html → Flex.js: hosts · Shell mounts the JS pipeline
- movies.html → Flex.js: hosts · Shell mounts the JS pipeline
- indexnews.html → Flex.js: hosts · Shell mounts the JS pipeline
- indexplayer.html → Flex.js: hosts · Shell mounts the JS pipeline