# openmf/community-app architecture

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

- Interactive diagram: https://gitdiagram.com/openmf/community-app
- Repository: https://github.com/openmf/community-app

## Overview

##### Project Type and Purpose
- This is a frontend UI application (“community-app”) that exposes the functionalities of the Mifos X platform to end-users.
- Its purpose is to provide a rich SPA interface that interacts with a separate backend Fineract provider (via REST APIs). It uses AngularJS along with auxiliary libraries such as Bootstrap and Font Awesome.

##### File Structure to Architectural Components
- The “app” folder holds all the client-side logic:
- The “angular” folder (and many “controllers”, “directives”, “filters”, “services”, “models”, “modules”, “routes”) shows that the application adheres to an MVC or MVVM-like pattern.
- “views” contains HTML templates that are rendered by Angular based on routing.
- “styles”, “styles-dev”, and fonts indicate the presentation layer that uses Bootstrap and custom SCSS.
- Configuration files like “UIconfig.json”, “Gruntfile.js”, “bower.json”, etc. indicate build and dependency management.
- External assets (images, fonts) and internationalization support (i18n and global-translations) are also present.
- The Dockerfile, Travis config, and CI/CD files point to automated builds, testing, and deployment pipelines.

##### Key Components
a. Client (Browser):
- That the application is loaded via ‘index.html’ and relies on AngularJS.
b. AngularJS Application Shell:
- “Main Controller”, “Routing”, “Modules”, and “Services” that manage the UI state.
- Denote the “controllers” (grouped by features like client, loans, deposits, accounting, etc.), “directives”, “filters”, and “views” as sub-components.
c. Communication Layer:
- REST API client modules (AuthenticationService, ResourceFactoryProvider, HttpServiceProvider, SessionManager, etc.) which facilitate communication with the Fineract backend.
- Use of query parameters such as baseApiUrl and tenantIdentifier for API endpoint configurations.
d. External Services and Build Tools:
- That the Docker image builds the app and deploys it on Nginx within a container (as defined by the Dockerfile).
- Integration with OAuth2 settings as a configurable module (via configurations.js).
e. Integration with Mifos X / Fineract Backend:
- That the angular app interacts with a remote Fineract backend (even though it’s not in the same repository, the integration is essential for the overall system).

##### Architectural Patterns and Design Principles
- SPA design pattern where a single HTML page is used alongside AngularJS to dynamically update content.
- Pattern separation such as MVC/MVVM: Controllers and directives encapsulate UI behavior, while services manage API integration.
- Modularity – various functional areas (clients, loans, products, accounting, organization, etc.) are separated into individual subfolders in controllers and views.
- The build system (Grunt, Bower) and automated tests (unit and functional tests under the “test” folder) should be indicated as supporting components.

- Start from a high-level view:
- Within the “UI” layer:
- “Modules” that are set up to manage features like accounting, client management, loan products, savings, and system configurations.
- External interactions:
- A note on the API endpoint configuration and how the app is configurable to target different backend URLs.
- On the periphery, include components representing the build and deployment environment (e.g., Grunt tasks, Docker container deployment to Nginx).

##### Final Touches
- Clear labels (for example, “Authentication Service”, “Session Manager”) to demonstrate which modules facilitate communication with the backend.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "MifosX Community App (SPA)"
        BROWSER["Browser/Client"]:::client
        subgraph "UI (AngularJS)"
            ANGULAR["AngularJS App Shell"]:::angular
            MIFOSX_JS["Main Angular Core"]:::angular
            ROUTES["Routing"]:::angular
            subgraph "Controllers"
                MAIN_CTRL["Main Controller"]:::ui
            end
            subgraph "Directives"
                DIALOG_DIR["Dialog Directive"]:::ui
            end
            subgraph "Filters"
                DATE_FILTER["Date Format Filter"]:::ui
            end
            subgraph "Views"
                HOME_VIEW["Home View"]:::ui
                TOPNAV_VIEW["Topnavbar View"]:::ui
            end
            subgraph "API Services"
                AUTH["Authentication Service"]:::apiservice
                HTTP["Http Service Provider"]:::apiservice
                RESOURCE["Resource Factory Provider"]:::apiservice
                SESSION["Session Manager"]:::apiservice
            end
            CONFIG["Configurations"]:::config
            EXTERNAL_ASSETS["External Assets"]:::config
        end
        BACKEND["Fineract Backend (Mifos X Platform)"]:::backend
        BUILD["Build & Deployment Environment"]:::build
    end

    %% Connections
    BROWSER -->|"loads"| ANGULAR
    ANGULAR --> MIFOSX_JS
    ANGULAR --> ROUTES
    ANGULAR -->|"controls"| MAIN_CTRL
    ANGULAR -->|"controls"| DIALOG_DIR
    ANGULAR -->|"formats"| DATE_FILTER
    ANGULAR -->|"renders"| HOME_VIEW
    ANGULAR -->|"renders"| TOPNAV_VIEW
    ANGULAR -->|"calls"| AUTH
    ANGULAR -->|"calls"| HTTP
    ANGULAR -->|"calls"| RESOURCE
    ANGULAR -->|"calls"| SESSION
    ANGULAR -->|"configures"| CONFIG
    ANGULAR -->|"loads"| EXTERNAL_ASSETS
    AUTH -->|"REST"| BACKEND
    HTTP -->|"REST"| BACKEND
    RESOURCE -->|"REST"| BACKEND
    SESSION -->|"REST"| BACKEND
    BUILD -->|"builds"| ANGULAR
    BUILD -->|"deploys"| BACKEND

    %% Click Events
    click BROWSER "https://github.com/openmf/community-app/blob/develop/app/index.html"
    click MIFOSX_JS "https://github.com/openmf/community-app/blob/develop/app/scripts/mifosX.js"
    click ROUTES "https://github.com/openmf/community-app/blob/develop/app/scripts/routes.js"
    click MAIN_CTRL "https://github.com/openmf/community-app/blob/develop/app/scripts/controllers/main/MainController.js"
    click DIALOG_DIR "https://github.com/openmf/community-app/blob/develop/app/scripts/directives/DialogDirective.js"
    click DATE_FILTER "https://github.com/openmf/community-app/blob/develop/app/scripts/filters/DateFormat.js"
    click HOME_VIEW "https://github.com/openmf/community-app/blob/develop/app/views/home.html"
    click TOPNAV_VIEW "https://github.com/openmf/community-app/blob/develop/app/views/_topnavbar.html"
    click AUTH "https://github.com/openmf/community-app/blob/develop/app/scripts/services/AuthenticationService.js"
    click HTTP "https://github.com/openmf/community-app/blob/develop/app/scripts/services/HttpServiceProvider.js"
    click RESOURCE "https://github.com/openmf/community-app/blob/develop/app/scripts/services/ResourceFactoryProvider.js"
    click SESSION "https://github.com/openmf/community-app/blob/develop/app/scripts/services/SessionManager.js"
    click CONFIG "https://github.com/openmf/community-app/tree/develop/app/scripts/config"
    click EXTERNAL_ASSETS "https://github.com/openmf/community-app/tree/develop/app/fonts"
    click BUILD "https://github.com/openmf/community-app/blob/develop/Gruntfile.js"

    %% Styles
    classDef client fill:#ffebcd,stroke:#333,stroke-width:2px;
    classDef angular fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef ui fill:#e0ffff,stroke:#333,stroke-width:2px;
    classDef apiservice fill:#dda0dd,stroke:#333,stroke-width:2px;
    classDef config fill:#ffffe0,stroke:#333,stroke-width:2px;
    classDef backend fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef build fill:#ffcccb,stroke:#333,stroke-width:2px;
```
