# genericpenguin/scmreplication architecture

> Architecture diagram of the GitHub repository genericpenguin/scmreplication, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/genericpenguin/scmreplication
- Repository: https://github.com/genericpenguin/scmreplication

## Overview

##### Component Layers

a) Interface Layer
- Entry point scripts (P4P4Replicate.py, P4SvnReplicate.py, SvnP4Replicate.py)
- Configuration handling (cfg/ directory contents)

b) Core Services Layer
- SCM Adapters:
- lib/scmp4.py (Perforce adapter)
- lib/scmsvn.py (Subversion adapter)
- Replication Logic:
- lib/PerforceReplicate.py
- lib/PerforceToSubversion.py
- lib/SubversionToPerforce.py

c) Support Services Layer
- lib/buildlogger.py (Logging)
- lib/dockerclient.py (Docker integration)
- lib/buildcommon.py (Common utilities)

##### External Dependencies

External components as separate entities:
- Docker Container Runtime
- Perforce Server
- Subversion Server
- P4Python API
- PySVN API

##### Data Flow Indicators

- Configuration flow from cfg/ files to components
- Change replication paths between servers
- API interactions with external SCM servers

##### Key Technical Elements to Highlight

a) Docker Integration
- Container boundaries
- Volume mounts for workspace and configuration

b) Authentication & Configuration
- How credentials and mapping files flow into the system
- Configuration files in cfg/ directory

##### Testing Infrastructure

A separate section showing:
- Test containers (docker-p4 and docker-svn)
- Test execution environment
- Test categories (p4p4, svnp4, p4svn)

Remember to indicate that the entire system runs within Docker containers, which provides isolation and portability across different Linux distributions.

This design should emphasize the modular nature of the system, showing how the different components can be combined to support various replication scenarios while maintaining a clean separation of concerns between the SCM-specific code and the core replication logic.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Interface Layer"
        P4P4["P4P4Replicate.py"]:::p4
        P4SVN["P4SvnReplicate.py"]:::hybrid
        SVNP4["SvnP4Replicate.py"]:::svn
        click P4P4 "https://github.com/genericpenguin/SCMReplication/blob/master/P4P4Replicate.py"
        click P4SVN "https://github.com/genericpenguin/SCMReplication/blob/master/P4SvnReplicate.py"
        click SVNP4 "https://github.com/genericpenguin/SCMReplication/blob/master/SvnP4Replicate.py"
    end

    subgraph "Core Services Layer"
        SCM2SCM[("SCM2SCM<br/>Core Engine")]:::core
        click SCM2SCM "https://github.com/genericpenguin/SCMReplication/blob/master/lib/scm2scm.py"

        subgraph "SCM Adapters"
            P4ADAPT["P4 Adapter"]:::p4
            SVNADAPT["SVN Adapter"]:::svn
            click P4ADAPT "https://github.com/genericpenguin/SCMReplication/blob/master/lib/scmp4.py"
            click SVNADAPT "https://github.com/genericpenguin/SCMReplication/blob/master/lib/scmsvn.py"
        end

        subgraph "Replication Logic"
            P4REP["Perforce<br/>Replication"]:::p4
            P4SVNREP["P4 to SVN<br/>Replication"]:::hybrid
            SVNP4REP["SVN to P4<br/>Replication"]:::hybrid
            click P4REP "https://github.com/genericpenguin/SCMReplication/blob/master/lib/PerforceReplicate.py"
            click P4SVNREP "https://github.com/genericpenguin/SCMReplication/blob/master/lib/PerforceToSubversion.py"
            click SVNP4REP "https://github.com/genericpenguin/SCMReplication/blob/master/lib/SubversionToPerforce.py"
        end
    end

    subgraph "Support Services Layer"
        LOGGER["Build Logger"]:::support
        DOCKER["Docker Client"]:::support
        COMMON["Common Utilities"]:::support
        click LOGGER "https://github.com/genericpenguin/SCMReplication/blob/master/lib/buildlogger.py"
        click DOCKER "https://github.com/genericpenguin/SCMReplication/blob/master/lib/dockerclient.py"
        click COMMON "https://github.com/genericpenguin/SCMReplication/blob/master/lib/buildcommon.py"
    end

    subgraph "Configuration"
        P4SRC["P4 Source<br/>Mapping"]:::config
        P4DST["P4 Destination<br/>Mapping"]:::config
        SVNSRC["SVN Source<br/>Mapping"]:::config
        SVNDST["SVN Destination<br/>Mapping"]:::config
        click P4SRC "https://github.com/genericpenguin/SCMReplication/blob/master/cfg/p4_src_mapping.cfg"
        click P4DST "https://github.com/genericpenguin/SCMReplication/blob/master/cfg/p4_dst_mapping.cfg"
        click SVNSRC "https://github.com/genericpenguin/SCMReplication/blob/master/cfg/svn_src_mapping.cfg"
        click SVNDST "https://github.com/genericpenguin/SCMReplication/blob/master/cfg/svn_dst_mapping.cfg"
    end

    subgraph "Testing Infrastructure"
        UNITTEST["Test Framework"]:::test
        P4DOCKER["P4 Docker<br/>Environment"]:::test
        SVNDOCKER["SVN Docker<br/>Environment"]:::test
        click UNITTEST "https://github.com/genericpenguin/SCMReplication/blob/master/test/replicationunittest.py"
        click P4DOCKER "https://github.com/genericpenguin/SCMReplication/tree/master/test/dockerfiles/docker-p4"
        click SVNDOCKER "https://github.com/genericpenguin/SCMReplication/tree/master/test/dockerfiles/docker-svn"
    end

    subgraph "External Dependencies"
        P4SERVER["Perforce<br/>Server"]:::external
        SVNSERVER["Subversion<br/>Server"]:::external
        P4API["P4Python API"]:::external
        SVNAPI["PySVN API"]:::external
    end

    %% Connections
    P4P4 --> SCM2SCM
    P4SVN --> SCM2SCM
    SVNP4 --> SCM2SCM

    SCM2SCM --> P4ADAPT
    SCM2SCM --> SVNADAPT
    SCM2SCM --> P4REP
    SCM2SCM --> P4SVNREP
    SCM2SCM --> SVNP4REP

    P4ADAPT --> P4API
    SVNADAPT --> SVNAPI
    P4API --> P4SERVER
    SVNAPI --> SVNSERVER

    P4SRC --> SCM2SCM
    P4DST --> SCM2SCM
    SVNSRC --> SCM2SCM
    SVNDST --> SCM2SCM

    SCM2SCM --> LOGGER
    SCM2SCM --> DOCKER
    SCM2SCM --> COMMON

    UNITTEST --> P4DOCKER
    UNITTEST --> SVNDOCKER

    %% Styles
    classDef p4 fill:#b3d1ff,stroke:#333
    classDef svn fill:#b3ffb3,stroke:#333
    classDef hybrid fill:#e6ccff,stroke:#333
    classDef core fill:#ffdb4d,stroke:#333
    classDef support fill:#cccccc,stroke:#333
    classDef config fill:#ffd9b3,stroke:#333
    classDef test fill:#ffb3b3,stroke:#333
    classDef external fill:#f2f2f2,stroke:#333,stroke-dasharray: 5 5
```
