# khalily/oreader architecture

> Architecture diagram of the GitHub repository khalily/oreader, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khalily/oreader
- Repository: https://github.com/khalily/oreader

## Overview

1. **Overall shape**
   - oReader is a two-tier app: a **Flask backend** exposing page routes and JSON APIs, plus an **AngularJS single-page frontend** that runs in the browser.
   - The app is designed as an RSS reader/aggregator: users authenticate, subscribe to feeds, and browse stories fetched from external RSS sources.

2. **Primary entry points**
   - `manage.py` is the local run entry point used by the README (`python manage.py runserver`).
   - `Procfile` and `Procfile.windows` indicate deployment/run conventions for Heroku and Windows.
   - `config.py` centralizes environment/app configuration, likely including Flask, database, and session settings.

3. **Backend application layout**
   - The Flask app lives under `app/` and is split into feature areas:
     - `app/main` for top-level pages and error handling.
     - `app/auth` for login/registration-related server views and forms.
     - `app/api` for the JSON API consumed by the Angular client.
     - `app/feedparser` for RSS ingestion/parsing logic.
   - `app/models.py` contains the persistent domain model and is the main shared data layer.

4. **API boundary**
   - `app/api/resource/*` is the clearest backend interface boundary. It appears to expose resources for:
     - `user`
     - `session`
     - `feed`
     - `story`
   - `app/api/common/schema.py` suggests request/response validation or serialization schemas.
   - `app/api/authentication.py` and `app/api/errors.py` indicate API-level auth and structured error handling separate from page views.

5. **Authentication and session flow**
   - `app/auth/forms.py` and `app/auth/views.py` handle browser-facing authentication pages and form processing.
   - On the API side, `app/api/resource/session.py` likely manages login/logout/session state for the Angular app.
   - This split suggests both traditional Flask form flows and API-backed session control, with the browser UI relying heavily on the JSON layer.

6. **RSS ingestion and content model**
   - `app/feedparser/feedparser.py` is the external-content integration layer. It likely fetches and parses RSS/Atom feeds from third-party URLs.
   - Parsed feed metadata and story items are then persisted through `models.py` and exposed via the API.
   - This is the main data-ingestion boundary: external RSS sources → parser module → database → API/UI.

7. **Frontend architecture**
   - The browser UI is built from AngularJS assets in `app/static/js/`:
     - `app.js` bootstraps the Angular app.
     - `controllers.js`, `services.js`, `directives.js`, and `filters.js` split client behavior by responsibility.
   - Libraries such as Angular, Restangular, angular-route, angular-cookies, lodash, jQuery, Bootstrap, and sortable.js show a classic Angular 1.x SPA stack.

8. **Client views and navigation**
   - Angular templates live in `app/static/partials/` and cover key screens:
     - `login.html`
     - `welcome.html`
     - `feeds.html`
     - `add_subscription.html`
     - `about.html`
   - Server-side templates in `app/templates/` (`base.html`, `index.html`, `404.html`) provide the host page and fallback/error rendering.
   - The likely flow is: Flask serves the shell page, Angular loads partials and calls the API for data.

9. **Static assets and UI presentation**
   - Styling is bundled locally under `app/static/css/` and `app/static/lib/bootstrap/`, with Font Awesome assets for icons.
   - Because the repo vendors frontend libraries instead of pulling them from a CDN, the UI is self-contained and deployment-friendly.
   - `app/static/preview.png` in the README hints the UI is presentation-heavy and modeled after GoRead.

10. **Data persistence and environment**
   - `dev-data.sqlite` indicates a SQLite-backed development database.
   - The architecture likely uses Flask + SQLAlchemy-style persistence through `models.py`, with data stored locally in dev and a different configured database in production.
   - Since Heroku deployment is mentioned, the runtime is expected to be a standard Python web process with environment-based configuration.

11. **Error handling boundaries**
   - There are separate error modules for API and main app routes: `app/api/errors.py` and `app/main/errors.py`.
   - This suggests distinct handling for browser page failures versus JSON API failures, which is important for diagramming the two response types.

12. **What to emphasize in an architecture diagram**
   - Show three main zones:
     - **Browser SPA**: AngularJS app, partials, static assets.
     - **Flask backend**: auth, main pages, REST resources, error handling.
     - **External RSS sources + database**: feed parser ingests remote feeds into persistent models.
   - The core data flow is: **user action in Angular → API call → Flask resource → models/database → response back to UI**, with a separate **RSS fetch/parse pipeline** feeding the same persistence layer.

Main entry points: [`app/__init__.py`](https://github.com/khalily/oreader/blob/master/app/__init__.py) (App init), [`app/static/js/app.js`](https://github.com/khalily/oreader/blob/master/app/static/js/app.js) (Angular app), [`app/api/resource/session.py`](https://github.com/khalily/oreader/blob/master/app/api/resource/session.py) (Session API), [`app/models.py`](https://github.com/khalily/oreader/blob/master/app/models.py) (Models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser SPA"]
  node_angularapp["Angular app<br/>spa bootstrap<br/>[app.js]"]
  node_partials["Views<br/>templates"]
  node_shell["Shell pages<br/>server templates<br/>[base.html]"]
  node_staticlib["UI libs<br/>vendored assets<br/>[angular.js]"]
end

subgraph group_backend["Flask backend"]
  node_manage["Manage<br/>entrypoint<br/>[manage.py]"]
  node_config["Config<br/>settings<br/>[config.py]"]
  node_appcore["App init<br/>flask app<br/>[__init__.py]"]
  node_mainviews["Main views<br/>page routes<br/>[views.py]"]
  node_mainerrors["Page errors<br/>html errors<br/>[errors.py]"]
  node_authviews["Auth views<br/>browser auth<br/>[views.py]"]
  node_authforms["Auth forms<br/>form models<br/>[forms.py]"]
  node_apiauth["API auth<br/>[authentication.py]"]
  node_apischema["Schemas<br/>validation schema<br/>[schema.py]"]
  node_apiuser["User API<br/>resource<br/>[user.py]"]
  node_apisession["Session API<br/>resource<br/>[session.py]"]
  node_apifeed["Feed API<br/>resource<br/>[feed.py]"]
  node_apistory["Story API<br/>resource<br/>[story.py]"]
  node_apierrors["API errors<br/>json errors<br/>[errors.py]"]
end

subgraph group_data["Data layer"]
  node_models[("Models<br/>persistence<br/>[models.py]")]
  node_rssparser["RSS parser<br/>ingestion<br/>[feedparser.py]"]
  node_rssbridge["RSS bridge<br/>integration<br/>[rss.py]"]
end

node_manage -->|"runs"| node_appcore
node_config -->|"configures"| node_appcore
node_appcore -->|"registers"| node_mainviews
node_appcore -->|"registers"| node_authviews
node_appcore -->|"registers"| node_apiauth
node_appcore -->|"registers"| node_apiuser
node_appcore -->|"registers"| node_apisession
node_appcore -->|"registers"| node_apifeed
node_appcore -->|"registers"| node_apistory
node_mainviews -->|"renders"| node_shell
node_mainerrors -->|"renders"| node_shell
node_authviews -->|"uses"| node_authforms
node_authviews -->|"renders"| node_shell
node_apiauth -->|"guards"| node_apisession
node_apiuser -->|"validates"| node_apischema
node_apisession -->|"validates"| node_apischema
node_apifeed -->|"persists"| node_models
node_apistory -->|"persists"| node_models
node_apiuser -->|"persists"| node_models
node_apisession -->|"persists"| node_models
node_rssbridge -->|"delegates"| node_rssparser
node_rssparser -->|"loads"| node_models
node_angularapp -->|"loads"| node_partials
node_angularapp -->|"depends on"| node_staticlib
node_angularapp -->|"calls"| node_apisession
node_angularapp -->|"calls"| node_apifeed
node_angularapp -->|"calls"| node_apistory
node_angularapp -->|"calls"| node_apiuser
node_shell -->|"hosts"| node_angularapp

click node_manage "https://github.com/khalily/oreader/blob/master/manage.py"
click node_config "https://github.com/khalily/oreader/blob/master/config.py"
click node_appcore "https://github.com/khalily/oreader/blob/master/app/__init__.py"
click node_mainviews "https://github.com/khalily/oreader/blob/master/app/main/views.py"
click node_mainerrors "https://github.com/khalily/oreader/blob/master/app/main/errors.py"
click node_authviews "https://github.com/khalily/oreader/blob/master/app/auth/views.py"
click node_authforms "https://github.com/khalily/oreader/blob/master/app/auth/forms.py"
click node_apiauth "https://github.com/khalily/oreader/blob/master/app/api/authentication.py"
click node_apischema "https://github.com/khalily/oreader/blob/master/app/api/common/schema.py"
click node_apiuser "https://github.com/khalily/oreader/blob/master/app/api/resource/user.py"
click node_apisession "https://github.com/khalily/oreader/blob/master/app/api/resource/session.py"
click node_apifeed "https://github.com/khalily/oreader/blob/master/app/api/resource/feed.py"
click node_apistory "https://github.com/khalily/oreader/blob/master/app/api/resource/story.py"
click node_apierrors "https://github.com/khalily/oreader/blob/master/app/api/errors.py"
click node_models "https://github.com/khalily/oreader/blob/master/app/models.py"
click node_rssparser "https://github.com/khalily/oreader/blob/master/app/feedparser/feedparser.py"
click node_rssbridge "https://github.com/khalily/oreader/blob/master/app/api/rss.py"
click node_angularapp "https://github.com/khalily/oreader/blob/master/app/static/js/app.js"
click node_shell "https://github.com/khalily/oreader/blob/master/app/templates/base.html"
click node_staticlib "https://github.com/khalily/oreader/blob/master/app/static/lib/angular.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_angularapp,node_partials,node_shell,node_staticlib toneBlue
class node_manage,node_config,node_appcore,node_mainviews,node_mainerrors,node_authviews,node_authforms,node_apiauth,node_apischema,node_apiuser,node_apisession,node_apifeed,node_apistory,node_apierrors toneAmber
class node_models,node_rssparser,node_rssbridge toneMint
```

## Components

### Browser SPA

AngularJS client, templates, and bundled assets.

- [Angular app](https://github.com/khalily/oreader/blob/master/app/static/js/app.js): spa bootstrap · Client-side application bootstrap and behavior modules. · `app/static/js/app.js`
- **Views**: templates · Angular partials for login, feeds, subscriptions, and welcome screens.
- [Shell pages](https://github.com/khalily/oreader/blob/master/app/templates/base.html): server templates · Flask host page and fallback HTML templates. · `app/templates/base.html`
- [UI libs](https://github.com/khalily/oreader/blob/master/app/static/lib/angular.js): vendored assets · Bundled Angular, jQuery, Bootstrap, and related client libraries. · `app/static/lib/angular.js`

### Flask backend

Server routes, API resources, auth, and error handling.

- [Manage](https://github.com/khalily/oreader/blob/master/manage.py): entrypoint · Local run entry point for the Flask app. · `manage.py`
- [Config](https://github.com/khalily/oreader/blob/master/config.py): settings · Central application and environment configuration. · `config.py`
- [App init](https://github.com/khalily/oreader/blob/master/app/__init__.py): flask app · Flask application bootstrap and wiring. · `app/__init__.py`
- [Main views](https://github.com/khalily/oreader/blob/master/app/main/views.py): page routes · Top-level browser routes and page rendering. · `app/main/views.py`
- [Page errors](https://github.com/khalily/oreader/blob/master/app/main/errors.py): html errors · Browser-facing error handling. · `app/main/errors.py`
- [Auth views](https://github.com/khalily/oreader/blob/master/app/auth/views.py): browser auth · Login and registration page flow. · `app/auth/views.py`
- [Auth forms](https://github.com/khalily/oreader/blob/master/app/auth/forms.py): form models · Server-side authentication forms and validation. · `app/auth/forms.py`
- [API auth](https://github.com/khalily/oreader/blob/master/app/api/authentication.py): api auth · JSON API authentication boundary. · `app/api/authentication.py`
- [Schemas](https://github.com/khalily/oreader/blob/master/app/api/common/schema.py): validation schema · Shared API request and response schema definitions. · `app/api/common/schema.py`
- [User API](https://github.com/khalily/oreader/blob/master/app/api/resource/user.py): resource · User resource exposed through the JSON API. · `app/api/resource/user.py`
- [Session API](https://github.com/khalily/oreader/blob/master/app/api/resource/session.py): resource · Login and logout session state for the SPA. · `app/api/resource/session.py`
- [Feed API](https://github.com/khalily/oreader/blob/master/app/api/resource/feed.py): resource · Feed subscription resource for the client. · `app/api/resource/feed.py`
- [Story API](https://github.com/khalily/oreader/blob/master/app/api/resource/story.py): resource · Story listing and story item resource. · `app/api/resource/story.py`
- [API errors](https://github.com/khalily/oreader/blob/master/app/api/errors.py): json errors · Structured error handling for API responses. · `app/api/errors.py`

### Data layer

RSS ingestion and persistent models.

- [Models](https://github.com/khalily/oreader/blob/master/app/models.py): persistence · Shared domain model and database layer. · `app/models.py`
- [RSS parser](https://github.com/khalily/oreader/blob/master/app/feedparser/feedparser.py): ingestion · Fetches and parses external RSS or Atom feeds. · `app/feedparser/feedparser.py`
- [RSS bridge](https://github.com/khalily/oreader/blob/master/app/api/rss.py): integration · RSS-facing helper or adapter layer. · `app/api/rss.py`

## Connections

- Manage → App init: runs · Local and deployed entry points start the Flask app.
- Config → App init: configures · Application settings are loaded during bootstrap.
- App init → Main views: registers · Flask wires top-level page routes.
- App init → Auth views: registers · Browser authentication routes are part of the app.
- App init → API auth: registers · API authentication boundary is initialized by the app.
- App init → User API: registers · API resources are mounted under the Flask app.
- App init → Session API: registers · Session endpoints are mounted under the Flask app.
- App init → Feed API: registers · Feed endpoints are mounted under the Flask app.
- App init → Story API: registers · Story endpoints are mounted under the Flask app.
- Main views → Shell pages: renders · Page routes serve the host HTML shell.
- Page errors → Shell pages: renders · Browser errors are rendered through server templates.
- Auth views → Auth forms: uses · Auth pages validate requests with server-side forms.
- Auth views → Shell pages: renders · Authentication pages are delivered in the HTML shell.
- API auth → Session API: guards · API auth behavior is centered on session handling.
- User API → Schemas: validates · User payloads use shared schema definitions.
- Session API → Schemas: validates · Session payloads use shared schema definitions.
- Feed API → Models: persists · Feed resources read and write the shared model layer.
- Story API → Models: persists · Story resources read and write the shared model layer.
- User API → Models: persists · User resources are backed by persistent models.
- Session API → Models: persists · Session state is backed by persistent models.
- RSS bridge → RSS parser: delegates · RSS-facing helper code forwards ingestion work to the parser.
- RSS parser → Models: loads · Parsed feeds and stories are stored through the model layer.
- Angular app → Views: loads · Client bootstrap routes the SPA to partial views.
- Angular app → UI libs: depends on · Angular app behavior relies on bundled third-party libraries.
- Angular app → Session API: calls · The SPA uses JSON session endpoints for login state.
- Angular app → Feed API: calls · Feed management is driven through the API.
- Angular app → Story API: calls · Story browsing is driven through the API.
- Angular app → User API: calls · User data and profile actions flow through the API.
- Shell pages → Angular app: hosts · Server templates provide the HTML container for the SPA.
