# fmoraes87/cadre architecture

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

- Interactive diagram: https://gitdiagram.com/fmoraes87/cadre
- Repository: https://github.com/fmoraes87/cadre

## Overview

##### Main Components
- Front-End Application (Cadre Front-End): An Angular 11 project using the PrimeNG Diamond template. This part is responsible for the user interface and client-side logic (routing, components, services, UI controls, theming, etc.).
- Backend Application (Cadre Server): A Maven-based Java application meant to run on Tomcat, handling business logic, data persistence, OAuth support, identity management, and metadata-driven configuration. It is divided into multiple layers:
- Core Services and Business Logic (processes, authentication, notification, etc.)
- Data Persistence & ORM layers (DAO, JDBC, query packages)
- Security and OAuth integration components (OAuth2, Facebook and Google providers)
- Additional utility modules (caching, validation, converters, and cron jobs)
- Database: A PostgreSQL instance (with a connection string evident in the environment variable setup) used for persisting application data and metadata.
- External Services/Providers:
- OAuth, Facebook Login, Google Support (to handle user identity and integration with external identity management systems)
- (Possibly) external configuration and integration endpoints offered through REST.
- Infrastructure & Deployment:
- Docker Compose configuration to launch the backend in a development setting.
- Tomcat for production deployments, managed via generated WAR files.

##### Relationships and Interactions
- For authentication and integration, represent connections from both the client and server layers to external identity providers (OAuth, Facebook, Google).
- Within the Java backend, internally denote how layers interact (e.g., request flow from a REST controller to service layer, then to persistence layer).
- Optionally, highlight integrations such as the data engine APIs or metadata-driven modules that allow for dynamic customization without regenerating Java code.

##### Architectural Patterns and Design Principles
- Clear separation of concerns: The front-end is a distinct Angular application, and the backend leverages the layered architecture (presentation, service, and data persistence layers).
- Metadata-Driven Customization: Emphasize that the backend utilizes extensive annotations, metadata, and dynamic configuration to enable flexible process and UI definitions.
- Security and Enterprise Integration: Include components for authentication, identity management, and service access policies.
- Reusability/Extensibility: Both the front-end (with UI components and services) and the backend (with converters, builders, and validators) are modular, suggesting the advantage of reusing components and an extensible architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User Browser"]:::user

    subgraph "Cadre Front-End"
        FE["Cadre Front-End (Angular)"]:::fe
    end

    subgraph "Cadre Server"
        REST["REST API Endpoints"]:::backend
        CORE["Core Services & Business Logic"]:::core
        PERSIST["Data Persistence & ORM"]:::persistence
        SECURITY["Security & OAuth Integration"]:::security
        REST -->|"process"| CORE
        CORE -->|"CRUD"| PERSIST
        CORE -->|"secure"| SECURITY
    end

    subgraph "External Identity Providers"
        OAUTH["OAuth"]:::external
        FB["Facebook Login"]:::external
        GGL["Google Support"]:::external
    end

    subgraph "Deployment Infrastructure"
        DOCKER["Docker Compose (Dev)"]:::deploy
        TOMCAT["Tomcat (Prod)"]:::deploy
    end

    DB["PostgreSQL Database"]:::database

    %% Data Flow Connections
    User -->|"UIRequests"| FE
    FE -->|"APIRequests"| REST
    CORE -->|"queries"| DB
    SECURITY -->|"authFlow"| OAUTH
    SECURITY -->|"authFlow"| FB
    SECURITY -->|"authFlow"| GGL

    %% Deployment Connections (dotted arrows)
    REST -.->|"deployedOn"| TOMCAT
    REST -.->|"deployedOn"| DOCKER

    %% Click Events for Cadre Front-End
    click FE "https://github.com/fmoraes87/cadre/tree/main/cadre-front-end"
    click FE "https://github.com/fmoraes87/cadre/blob/main/cadre-front-end/angular.json"
    click FE "https://github.com/fmoraes87/cadre/blob/main/cadre-front-end/src/app/app.module.ts"

    %% Click Events for Cadre Server REST Endpoint
    click REST "https://github.com/fmoraes87/cadre/tree/main/cadre-server"
    click REST "https://github.com/fmoraes87/cadre/blob/main/cadre-server/pom.xml"

    %% Click Events for Core Services & Business Logic
    click CORE "https://github.com/fmoraes87/cadre/tree/main/cadre-server/src/main/java/com/cadre/server/core"
    click CORE "https://github.com/fmoraes87/cadre/blob/main/cadre-server/src/main/java/com/cadre/server/core/CadreSvrBootstrap.java"

    %% Click Events for Data Persistence & ORM Layers
    click PERSIST "https://github.com/fmoraes87/cadre/tree/main/cadre-server/src/main/java/com/cadre/server/core/persistence"
    click PERSIST "https://github.com/fmoraes87/cadre/tree/main/cadre-server/src/main/java/com/cadre/server/core/persistence/jdbc"

    %% Click Events for Security and OAuth Integration Components
    click SECURITY "https://github.com/fmoraes87/cadre/tree/main/cadre-server/src/main/java/com/cadre/server/core/security"
    click SECURITY "https://github.com/fmoraes87/cadre/tree/main/cadre-server/src/main/java/com/cadre/server/core/security/oauth2"

    %% Click Events for External Services/Providers
    click FB "https://github.com/fmoraes87/cadre/tree/main/cadre-server/src/main/java/com/cadre/server/ext/facebook"
    click GGL "https://github.com/fmoraes87/cadre/tree/main/cadre-server/src/main/java/com/cadre/server/ext/google"

    %% Click Events for Deployment Infrastructure
    click DOCKER "https://github.com/fmoraes87/cadre/blob/main/cadre-server/docker-compose-dev.yml"
    click TOMCAT "https://github.com/fmoraes87/cadre/blob/main/cadre-server/src/main/webapp/WEB-INF/web.xml"
    click TOMCAT "https://github.com/fmoraes87/cadre/blob/main/cadre-server/src/main/webapp/index.html"

    %% Styles
    classDef fe fill:#ADD8E6,stroke:#000,stroke-width:2px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px
    classDef core fill:#FFB6C1,stroke:#000,stroke-width:2px
    classDef persistence fill:#FFD700,stroke:#000,stroke-width:2px
    classDef security fill:#FFA07A,stroke:#000,stroke-width:2px
    classDef external fill:#DDA0DD,stroke:#000,stroke-width:2px
    classDef deploy fill:#87CEFA,stroke:#000,stroke-width:2px
    classDef database fill:#F08080,stroke:#000,stroke-width:2px
    classDef user fill:#F5DEB3,stroke:#000,stroke-width:2px
```
