# amirulhakiim/platformwelldatasync architecture

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

- Interactive diagram: https://gitdiagram.com/amirulhakiim/platformwelldatasync
- Repository: https://github.com/amirulhakiim/platformwelldatasync

## Overview

The PlatformWellDataSync project is a .NET Core Web API application that serves as an interface for platform, well, and synchronization operations. It integrates with a SQL Server database and is set up to run within Docker containers using Docker Compose. This setup implies a full-stack application architecture where the backend (API) is containerized along with the database.

##### Major Components
- Web API Container: This container (built using the provided Dockerfile) hosts the .NET Core Web API. Inside this container, the application logic is organized with controllers (in the Controllers directory), data access (in the Data directory using Entity Framework’s AppDbContext), and data models (in the Models directory) that reflect the underlying SQL database tables.
- Database (SQL Server) Container: Managed via Docker Compose (docker-compose.yml), it runs the SQL Server instance. This component is critical for storing platform and well data and handling migrations, as seen in the Migrations folder.
- External Clients: Any HTTP client (or swagger UI at the /swagger endpoint) that communicates with the Web API.

##### Understand the Data Flow
- Within the API container, the Controllers handle these requests. For instance, the PlatformWellController and SyncsController define the endpoints.
- The controllers rely on the AppDbContext (Entity Framework) for data access. AppDbContext interacts with the SQL Server database.
- The flow includes pulling and persisting data based on defined models (Platform, Well, SyncRequest, PlatformWell).

##### Architectural Patterns & Design Principles
- Use of MVC-like patterns where Controllers separate API logic from the business/data logic.
- The Data Access pattern via Entity Framework (EF Core) abstracts the database operations.
- Containerization with Docker ensuring consistency of the runtime environment across different stages (development, testing, and production).
- Migrations are handled through Entity Framework, reflecting evolving database schemas.

##### Key Technologies
- .NET Core (C#) for the API server.
- Entity Framework Core for ORM and database migrations.
- SQL Server for persistent storage.
- Docker & Docker Compose for container orchestration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    ExternalClients("External Clients (Swagger, Postman)"):::external
    SQLServer("SQL Server Container"):::database

    %% Web API Container Subgraph
    subgraph "Web API Container (PlatformWellDataSync)"
        direction TB
        DockerFile("Dockerfile"):::api

        subgraph "Controllers"
            direction TB
            PC("PlatformWellController"):::controller
            SC("SyncsController"):::controller
        end

        subgraph "Data Access"
            direction TB
            ADB("AppDbContext"):::dataAccess
            subgraph "Migrations"
                direction TB
                MigDesigner("20240317093231_InitialCreate.Designer.cs"):::dataAccess
                MigCreate("20240317093231_InitialCreate.cs"):::dataAccess
                MigSnapshot("AppDbContextModelSnapshot.cs"):::dataAccess
            end
        end

        subgraph "Models"
            direction TB
            P("Platform"):::model
            W("Well"):::model
            PW("PlatformWell"):::model
            SR("SyncRequest"):::model
        end
    end

    %% Connections
    ExternalClients -->|"HTTPRequest"| PC
    ExternalClients -->|"HTTPRequest"| SC
    PC -->|"callsEF"| ADB
    SC -->|"callsEF"| ADB
    ADB -->|"queries"| SQLServer

    %% Click Events
    click DockerFile "https://github.com/amirulhakiim/platformwelldatasync/tree/main/Dockerfile"
    click PC "https://github.com/amirulhakiim/platformwelldatasync/blob/main/Controllers/PlatformWellController.cs"
    click SC "https://github.com/amirulhakiim/platformwelldatasync/blob/main/Controllers/SyncsController.cs"
    click ADB "https://github.com/amirulhakiim/platformwelldatasync/blob/main/Data/AppDbContext.cs"
    click MigDesigner "https://github.com/amirulhakiim/platformwelldatasync/blob/main/Migrations/20240317093231_InitialCreate.Designer.cs"
    click MigCreate "https://github.com/amirulhakiim/platformwelldatasync/blob/main/Migrations/20240317093231_InitialCreate.cs"
    click MigSnapshot "https://github.com/amirulhakiim/platformwelldatasync/blob/main/Migrations/AppDbContextModelSnapshot.cs"
    click P "https://github.com/amirulhakiim/platformwelldatasync/blob/main/Models/Platform.cs"
    click W "https://github.com/amirulhakiim/platformwelldatasync/blob/main/Models/Well.cs"
    click PW "https://github.com/amirulhakiim/platformwelldatasync/blob/main/Models/PlatformWell.cs"
    click SR "https://github.com/amirulhakiim/platformwelldatasync/blob/main/Models/SyncRequest.cs"
    click SQLServer "https://github.com/amirulhakiim/platformwelldatasync/blob/main/docker-compose.yml"

    %% Styles
    classDef external fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef api fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef controller fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef dataAccess fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef model fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef database fill:#f5c6cb,stroke:#721c24,stroke-width:2px;
```
