Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

App Architecture

Yu-Jen Lin edited this page Apr 23, 2017 · 21 revisions

It is electron based

Electron + Bulma.io + SASS + jQuery

Dependencies (Production)

CSS Frameworks

Bulma.io

Font Awesome

Javascripts Library

jQuery

TongWen (customized to fit node.js)

Electron/node.js modules

electron-settings

Writing electron settings file in json format to ~/Library/Application\ Support/Setting (Mac) and "Not sure where" (Win and Linux). This plugin right now only supports writing to one single file. We might need to replace this one with another (for example, electron-config) later if we need to separate each comic's information to different files.

requests

Make http request

Async utilities for node and the browser

Schedule tasks that needs to be executed repeatedly

node-notifier

node-schedule

DevDependencies

livereloadx

Watches the file changes under the project folder, and trigger the app to refresh automatically.

node-sass

Compiles SASS files to CSS.

nodemon

Watches the SASS files, and execute node-sass if any of the SASS file changes.

concurrently

Allows us to run all of the command above in parallel.

Folder Structure

I use the folder structure follows this one on electron/electron-api-demos. The main.js is replaced with app.js (we can change it back later) in the root folder. Other system-related .js should be placed under main-process folder. Currently there is no main-process folder.

(According to the guidelines, main/app.js needs to be in the root folder, other system-realted .js that is reuired by main/app.js should be placed under main-process folder. Although, technically we can place main.js to any place we want).

Folder Structure

assets

This directory includes assets files for the app itself, including css, fonts, images, javascripts, and more.

css folder

Contains css files from other libraries, and the main.css which is compiled from the scss folder Developers who wants to contributed to this project should avoid from writing .css directly, and use scss/sass instead

js

Contains 3rd party javascripts library, such as jQuery

icons

Contains app icons. (It is not being used right now. The current setup in app.js is incorrect)

renderer-process

The idea is to have Model View ViewModel (MVVM) separated. (Although it is not done perfectly, yet. Right now some of my view-controller accessing the model directly, which should be fixed later) (Naming should be change either, I got this idea before I actually know MVVM.)

This is the diagram from www.objc.op :
img

Our current implementations looks like the following diagram: img Where views are defined under the sections using .html files

Model

The database is right now store together with the general application settings at ~/Library/Application\ Support/Settings in JSON format.

Application Settings:

Key: "system"
Values: {
    "windowsize": {
        "width": 800, 
        "height": 600
    }
}

Comic Settings/Database

Basic structure:

// value inside <> needs to be replace with actual data
// {} represent the data type of the value
Key: "comic"
Value: {
     "<host_name>" : {
         "<comic_key>" : {
             "title": "{String}", // comic's name
             "link" : "{String}", //URL to the comic page
             "thumbnail": "{String}", // URL to the cover photo
             "subscribed": "{bool}", //Whether the user subscribes the comic or not
             "lastread" : "{String}", // Chapter name the user read last time
             "chapters": {
                 "<chapter_name>" : {
                     "read": "{bool}" // <Whether the user has read this chapter or not>
                 } 
             },
             "newestchapter": "{String}" // Chapter name of the newest chapter
        }
    }
}

values.js

A javascript object contains two Key-Value pairs

{
    hosts: {
        "<host_path>": {
            "name": "{String} <host_name>",
            "parsers": "{Object} <host_parser>"
        }
    },
    hostsname: {
         "<host_name>" : {
             "parsers": "{Object} <host_parser>"
         }
    }
}

ViewModel

search-controller.js

Handle the search mechanism and notify the search-view to update its UI elements once the search results is returned by the server.

subscriber.js

Handle everything for the subscription. It owns view-controllers and models. It will notify the view-controllers to update UI elements.

comic-parser.js

Parsing information of a comic. Including chapters/episodes of a selected comic, and loading every single page for a selected chapter/episode.

util.js

Contains general utility codes

load-after.js

!!!Important!!! - this file should be load last Things todo after every single element is loaded. Right now it is used to switch the active panel to favorite view after everything is loaded, includes other scripts.

View-Controller

content-loader.js

Load the three different main views to index.html

search-view.js, favorite-view.js, read-view.js

controllers for the three different views

view-switcher.js

Associate with sidebar-view and the middle-panel (chapter-selector) under read view

sections

Contains html templates. These files is loaded to the index.html(or the app) by using the .js file under renderer-process

Sidebar

sidebar.html

Favorite View

--

favorite-entry.html

A HTML template for one single entry that is used in favorite-view Imgur

favorite-view.html

The HTML template for the whole favorite view

Read View

--

chapter-entry.html

A HTML template for one single entry that is used in chapter-selector under read-view Imgur

page.html

A HTML template for one single image under the read-view Imgur

read-view.html

The HTML template for the whole read view

Search View

--

search-result-entry.html

A HTML template for one single search result Imgur

search-view.html

The HTML template for the whole search view

Clone this wiki locally