# jamf/jamfpro architecture

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

- Interactive diagram: https://gitdiagram.com/jamf/jamfpro
- Repository: https://github.com/jamf/jamfpro

## Overview

##### Main Components
- Docker Build Environment – This includes the Dockerfile which is the center of the build process. It references the upstream Tomcat image and integrates custom configurations.
- Application Container – Represents the running container, with internal components such as:
- Apache Tomcat server running as a non-root user ("tomcat").
- The JamfPro ROOT.war application that is either mounted or pre-unpacked in the specified directory.
- Configuration Files – This includes server.template (for overriding server.xml), DataBase.xml (if mounted) and any log configuration files (the various log4j and log4j2 replacement files).
- External Dependencies – These are resources that interact with the container:
- Remote Database – The container expects a remote database (parameters like DATABASE_HOST, DATABASE_NAME, etc.) with which it interacts.
- Logging and Monitoring – Logs are streamed to stdout, and JMX settings allow external monitoring.
- Kubernetes Environment – When clustering is enabled, via environment variables (POD_NAME, POD_IP, PRIMARY_NODE_NAME), indicating that container orchestration (likely via a Kubernetes pod deployment) is a consideration.

##### Relationships and Interactions
- During Build Time:
- The Dockerfile along with optional overrides (using arguments like TOMCAT_VERSION) builds the image.
- Files such as the server.template are used to modify the Tomcat configuration (server.xml) right before starting.
- During Runtime:
- The container mounts a bind directory for ROOT.war or uses an existing webapps directory.
- Environment variables drive substitutions in configuration files (e.g., database credentials, log settings, JMX configurations, and server.xml overrides).
- If DataBase.xml is provided via a volume mount to /config, it overrides any defaults based on the environmental parameters.
- Logs are handled by replacement files (log4j and log4j2 configuration) that direct logging output to stdout alongside traditional Tomcat logging (catalina logs).
- When deploying in Kubernetes, downward API fields (POD_NAME, POD_IP) are used to configure clustering within Tomcat.

##### Architectural Patterns and Design Principles
- Containerization – The entire system is encapsulated in a Docker container which promotes a consistent, reproducible runtime environment.
- Configuration via Environment – Configuration is abstracted to environment variables, promoting flexibility between development, staging, and production environments.
- Volume Bind-Mounting – For data persistence (i.e., ROOT.war and/or webapps) and configuration override (DataBase.xml).
- Security Considerations – Running Tomcat as a non-root user enhances security.

##### Relevant Technologies, Frameworks, and Libraries
- Docker – For containerizing and distributing the application.
- Apache Tomcat – The servlet container that runs the JamfPro application.
- JamfPro – The core application that is deployed within Tomcat.
- Log4j / Log4j2 – For advanced logging configuration.
- Kubernetes (optional) – For clustering and orchestration via environment variables and downward API information.

##### Essential Elements
- Use clear labels: Each component (Docker Build, Container, Tomcat, External Database, etc.) should be clearly named.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Build Process
    subgraph "Build Process"
        DBE["Docker Build Environment"]:::build
        IMG["Docker Image"]:::build
    end

    %% Runtime Container
    subgraph "Runtime Container"
        CON["Container"]:::container
        subgraph "Container Components"
            TOMCAT["Apache Tomcat (non-root)"]:::subcomp
            CONFIG["Custom Configuration Files"]:::subcomp
            LOGGING["Logging Setup"]:::subcomp
            APP["JamfPro Application Deployment (ROOT.war)"]:::subcomp
        end
    end

    %% External Systems
    subgraph "External Systems"
        DB["Remote Database"]:::external
        JMX["Monitoring (JMX)"]:::external
        KUBE["Kubernetes Environment"]:::external
    end

    %% Connections - Build to Runtime
    DBE -->|"builds"| IMG
    IMG -->|"deploys"| CON
    CON -->|"runs"| TOMCAT
    CON -->|"includes"| CONFIG
    CON -->|"includes"| LOGGING
    CON -->|"includes"| APP

    %% Internal Configuration Connections
    CONFIG -->|"overrides"| TOMCAT
    LOGGING -->|"routesLogs"| CON

    %% External Interactions
    TOMCAT -->|"connectsTo"| DB
    TOMCAT -->|"monitoredBy"| JMX
    TOMCAT -->|"clusteredIn"| KUBE

    %% Environment Variables Influence (Annotation)
    DBE -.->|"envVarsApplied"| CON

    %% Click Events for Build Components
    click DBE "https://github.com/jamf/jamfpro/tree/master/Dockerfile"
    click DBE "https://github.com/jamf/jamfpro/blob/master/.dockerignore"
    click DBE "https://github.com/jamf/jamfpro/tree/master/Makefile"

    %% Click Events for Tomcat Component
    click TOMCAT "https://github.com/jamf/jamfpro/blob/master/startup.sh"

    %% Click Events for Custom Configuration Files
    click CONFIG "https://github.com/jamf/jamfpro/blob/master/server.template"
    click CONFIG "https://github.com/jamf/jamfpro/blob/master/configuration.sh"

    %% Click Events for Logging Setup
    click LOGGING "https://github.com/jamf/jamfpro/blob/master/log4j.stdout.replace"
    click LOGGING "https://github.com/jamf/jamfpro/blob/master/log4j2.stdout.appenders.replace"
    click LOGGING "https://github.com/jamf/jamfpro/blob/master/log4j2.stdout.loggers.analytics.replace"
    click LOGGING "https://github.com/jamf/jamfpro/blob/master/log4j2.stdout.loggers.root.replace"
    click LOGGING "https://github.com/jamf/jamfpro/blob/master/log4j2.stdout.loggers.vpp.replace"

    %% Styles
    classDef build fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef container fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef subcomp fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:2px;
```
