# micrusa/proyecto-aiss architecture

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

- Interactive diagram: https://gitdiagram.com/micrusa/proyecto-aiss
- Repository: https://github.com/micrusa/proyecto-aiss

## Overview

##### Project type and purpose
- This is a microservices-based Java application (built with Spring Boot and Maven) whose goal is to mine source-control data from Bitbucket and GitHub, normalize (“ETL”) it, and persist it in a central Git data store.
- The root folder contains three independent microservice modules:
- BitbucketMiner – pulls data from the Bitbucket API, transforms it, then pushes it onward
- GithubMiner   – same pattern for the GitHub API
- GitMiner     – exposes CRUD endpoints to receive normalized commits, issues, comments, projects and users, and persists them via JPA

##### File structure
- Top-level directories = microservices. Each is a standalone Spring Boot app with its own pom.xml, src/main/java entry point, application.properties, and unit tests.
- Common layers within each:
- controller – Spring MVC REST endpoints
- service    – business logic, ETL orchestration (and in Bitbucket/Github cases, an injected GitMinerService REST client)
- model      – data transfer objects, mapping external schema to internal schema
- exception  – custom exceptions and handlers
- In GitMiner: an additional repository package under src/main/java for Spring Data JPA interfaces, indicating a persistence layer backed by a relational database.

##### Insights from README
- Confirms that each folder is a microservice.
- Provides Postman collection (pruebas_postman.json) to test each microservice’s endpoints.

##### Main components
a. API clients / users (e.g., Postman or other orchestration tool)
b. BitbucketMiner microservice
c. GithubMiner microservice
d. GitMiner microservice (persistence)
e. External third-party APIs: Bitbucket REST API, GitHub REST API
f. Relational Database (MySQL, Postgres, etc.) used by GitMiner

##### Relationships and data flows
- Users → call BitbucketMiner / GithubMiner REST endpoints
- Miner service controllers → call external REST APIs → receive raw JSON
- Transformer (ETL) components → map external JSON to internal “GitMiner” models
- Service layer → invokes GitMinerService (a REST client) to post normalized data to GitMiner
- GitMiner controllers → accept data → service → repository interfaces → persist to DB
- Optionally, users can also query GitMiner directly for stored data

##### Architectural patterns and design principles
- Microservice separation of concerns (one source per service + one persistence service)
- Layered architecture within each service (Controller → Service → Repository/External API)
- Use of DTOs for external‐to‐internal model transformation
- Centralized persistence via REST between services
- Spring Boot for auto-configuration and embedded server per service
- Maven for build and dependency management

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    APIClient["API Client/Test (Postman)"]:::client

    %% External APIs
    subgraph "External APIs"
        BitbucketAPI["Bitbucket REST API"]:::external
        GitHubAPI["GitHub REST API"]:::external
    end

    %% BitbucketMiner Microservice
    subgraph "BitbucketMiner Microservice"
        BBDir["BitbucketMiner/"]:::service
        BBApp["BitbucketminerApplication"]:::service
        BBController["BitbucketMinerController"]:::service
        BBServiceLayer["service/ (BitbucketMiner Service Layer)"]:::service
        BBTransformer["Transformer (ETL)"]:::service
        BBModelExt["model/bitBucket (External DTOs)"]:::service
        BBModelInt["model/gitMiner (Internal DTOs)"]:::service
        BBException["exception/"]:::service
        BBConfig["application.properties"]:::service

        BBDir --> BBApp
        BBApp --> BBController
        BBController --> BBServiceLayer
        BBServiceLayer --> BBTransformer
        BBTransformer --> BBModelExt
        BBTransformer --> BBModelInt
        BBServiceLayer --> BBException
        BBDir --> BBConfig
    end

    %% GithubMiner Microservice
    subgraph "GithubMiner Microservice"
        GHDir["GithubMiner/"]:::service
        GHApp["GithubminerApplication"]:::service
        GHController["GithubMinerController"]:::service
        GHServiceLayer["service/ (GithubMiner Service Layer)"]:::service
        GHTransformer["Transformer (ETL)"]:::service
        GHModelExt["model/github (External DTOs)"]:::service
        GHModelInt["model/gitminer (Internal DTOs)"]:::service
        GHUtils["utils/GithubUtils.java"]:::service
        GHConfig["application.properties"]:::service

        GHDir --> GHApp
        GHApp --> GHController
        GHController --> GHServiceLayer
        GHServiceLayer --> GHTransformer
        GHTransformer --> GHModelExt
        GHTransformer --> GHModelInt
        GHServiceLayer --> GHUtils
        GHDir --> GHConfig
    end

    %% GitMiner Microservice
    subgraph "GitMiner Microservice"
        GMDIR["GitMiner/"]:::service
        GMApp["GitMinerApplication"]:::service
        GMController["controller/"]:::service
        GMServiceLayer["service/"]:::service
        GMRepository["repository/"]:::service
        GMModel["model/"]:::service
        GMException["exception/"]:::service
        GMConfig["application.properties"]:::service

        GMDIR --> GMApp
        GMApp --> GMController
        GMController --> GMServiceLayer
        GMServiceLayer --> GMRepository
        GMRepository --> GMModel
        GMServiceLayer --> GMException
        GMDIR --> GMConfig
    end

    %% Database
    Database["Relational Database"]:::db

    %% Data Flows
    APIClient -->|"HTTP/REST JSON"| BBController
    APIClient -->|"HTTP/REST JSON"| GHController
    APIClient -->|"HTTP/REST JSON"| GMController

    BBController -->|"REST call"| BitbucketAPI
    BitbucketAPI -->|"JSON response"| BBTransformer
    GHController -->|"REST call"| GitHubAPI
    GitHubAPI -->|"JSON response"| GHTransformer

    BBTransformer -->|"Transform to internal DTO"| BBServiceLayer
    GHTransformer -->|"Transform to internal DTO"| GHServiceLayer

    BBServiceLayer -->|"POST normalized data (JSON over HTTP/REST)"| GMController
    GHServiceLayer -->|"POST normalized data (JSON over HTTP/REST)"| GMController

    GMController -->|"Service layer"| GMServiceLayer
    GMServiceLayer -->|"Repository CRUD"| GMRepository
    GMRepository -->|"JPA persist"| Database

    %% Click Events
    click APIClient "https://github.com/micrusa/proyecto-aiss/blob/main/pruebas_postman.json"
    click BBDir "https://github.com/micrusa/proyecto-aiss/tree/main/BitbucketMiner/"
    click BBApp "https://github.com/micrusa/proyecto-aiss/blob/main/BitbucketMiner/src/main/java/aiss/bitbucketminer/BitbucketminerApplication.java"
    click BBController "https://github.com/micrusa/proyecto-aiss/blob/main/BitbucketMiner/src/main/java/aiss/bitbucketminer/controller/BitbucketMinerController.java"
    click BBServiceLayer "https://github.com/micrusa/proyecto-aiss/tree/main/BitbucketMiner/src/main/java/aiss/bitbucketminer/service/"
    click BBTransformer "https://github.com/micrusa/proyecto-aiss/blob/main/BitbucketMiner/src/main/java/aiss/bitbucketminer/etl/Transformer.java"
    click BBModelExt "https://github.com/micrusa/proyecto-aiss/tree/main/BitbucketMiner/src/main/java/aiss/bitbucketminer/model/bitBucket/"
    click BBModelInt "https://github.com/micrusa/proyecto-aiss/tree/main/BitbucketMiner/src/main/java/aiss/bitbucketminer/model/gitMiner/"
    click BBException "https://github.com/micrusa/proyecto-aiss/tree/main/BitbucketMiner/src/main/java/aiss/bitbucketminer/exception/"
    click BBConfig "https://github.com/micrusa/proyecto-aiss/blob/main/BitbucketMiner/src/main/resources/application.properties"

    click GHDir "https://github.com/micrusa/proyecto-aiss/tree/main/GithubMiner/"
    click GHApp "https://github.com/micrusa/proyecto-aiss/blob/main/GithubMiner/src/main/java/aiss/githubminer/GithubminerApplication.java"
    click GHController "https://github.com/micrusa/proyecto-aiss/blob/main/GithubMiner/src/main/java/aiss/githubminer/controller/GithubMinerController.java"
    click GHServiceLayer "https://github.com/micrusa/proyecto-aiss/tree/main/GithubMiner/src/main/java/aiss/githubminer/service/"
    click GHTransformer "https://github.com/micrusa/proyecto-aiss/blob/main/GithubMiner/src/main/java/aiss/githubminer/etl/Transformer.java"
    click GHModelExt "https://github.com/micrusa/proyecto-aiss/tree/main/GithubMiner/src/main/java/aiss/githubminer/model/github/"
    click GHModelInt "https://github.com/micrusa/proyecto-aiss/tree/main/GithubMiner/src/main/java/aiss/githubminer/model/gitminer/"
    click GHUtils "https://github.com/micrusa/proyecto-aiss/blob/main/GithubMiner/src/main/java/aiss/githubminer/utils/GithubUtils.java"
    click GHConfig "https://github.com/micrusa/proyecto-aiss/blob/main/GithubMiner/src/main/resources/application.properties"

    click GMDIR "https://github.com/micrusa/proyecto-aiss/tree/main/GitMiner/"
    click GMApp "https://github.com/micrusa/proyecto-aiss/blob/main/GitMiner/src/main/java/aiss/gitminer/GitMinerApplication.java"
    click GMController "https://github.com/micrusa/proyecto-aiss/tree/main/GitMiner/src/main/java/aiss/gitminer/controller/"
    click GMServiceLayer "https://github.com/micrusa/proyecto-aiss/tree/main/GitMiner/src/main/java/aiss/gitminer/service/"
    click GMRepository "https://github.com/micrusa/proyecto-aiss/tree/main/GitMiner/src/main/java/aiss/gitminer/repository/"
    click GMModel "https://github.com/micrusa/proyecto-aiss/tree/main/GitMiner/src/main/java/aiss/gitminer/model/"
    click GMException "https://github.com/micrusa/proyecto-aiss/tree/main/GitMiner/src/main/java/aiss/gitminer/exception/"
    click GMConfig "https://github.com/micrusa/proyecto-aiss/blob/main/GitMiner/src/main/resources/application.properties"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef service fill:#B0C4DE,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px,shape:rect
    classDef db fill:#90EE90,stroke:#333,stroke-width:1px,shape:cylinder
```
