# yeury-dcm/medsync architecture

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

- Interactive diagram: https://gitdiagram.com/yeury-dcm/medsync
- Repository: https://github.com/yeury-dcm/medsync

## Overview

##### Project Type and Purpose
- This is a monolithic full‑stack ASP.NET Core MVC web application.
- It follows an Onion Architecture to manage patient data, appointments, doctors, lab tests/results, and user authentication/authorization in a medical center context.

##### File Structure
- Top‑level layers:
- MedSync.Core.Domain – pure business entities and enums.
- MedSync.Core.Application – use‑case services, interfaces (repositories, services), ViewModels, AutoMapper profiles.
- MedSync.Infrastructure.Persistence – EF Core DbContext, migrations, repository implementations.
- MedSync.Presentation.Web – MVC layer: Controllers, Razor Views, static assets, middleware, session management.
- Look for cross‑cutting concerns (e.g., password encryption helper, session helper, DI ServiceExtension classes).
- Configuration files: appsettings.json, launchSettings.json, .csproj files, migrations.

##### README for Additional Insights
- Confirms the four‑layer onion structure with responsibilities for each layer.
- Lists main features and user roles (Administrator, Assistant).
- Technologies: ASP.NET Core MVC, EF Core, SQL Server, Bootstrap/Razor UI.

##### Detail Without Overthinking
- 4 layers of the Onion Architecture explicitly.
- Core services (Account, Appointment, Patient, LabTest, LabResult).
- Session validation middleware and static file serving.
- Full request‑response cycle end to end.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Client Browser<br/>(HTML/CSS/JS)"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Program["Program Startup"]:::presentation
        Middleware["ValidateUserSession Middleware"]:::presentation
        Controllers["MVC Controllers"]:::presentation
        Views["Razor Views"]:::presentation
        ErrorVM["ErrorViewModel"]:::presentation
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        ServiceIF["Service Interfaces"]:::application
        RepoIF["Repository Interfaces"]:::application
        Helpers["Helpers<br/>(Session, Password)"]:::application
        Mapping["AutoMapper Profiles"]:::application
        AppExt["DI Service Extension"]:::application
        Services["Service Implementations"]:::application
        ViewModels["ViewModels (DTOs)"]:::application
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        Entities["Entities"]:::domain
        Common["Common Base Types"]:::domain
        Enums["Enums"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        DbContext["ApplicationDbContext"]:::infrastructure
        RepoImpl["Repository Implementations"]:::infrastructure
        Migrations["EF Core Migrations"]:::infrastructure
        InfraExt["DI Service Extension"]:::infrastructure
    end

    %% Database
    Database["SQL Server"]:::database

    %% Data Flow
    Browser -->|"HTTP Request"| Program
    Program -->|"Invoke Middleware"| Middleware
    Middleware -->|"Validate Session"| Controllers
    Controllers -->|"Call Interfaces"| ServiceIF
    ServiceIF -->|"Implemented by"| Services
    Services -->|"Use Repo Interfaces"| RepoIF
    RepoIF -->|"Implemented by"| RepoImpl
    Services -->|"Map Entities/DTOs"| Mapping
    Services -->|"Use Helpers"| Helpers
    Services -->|"Use ViewModels"| ViewModels
    Services -->|"Use Domain Types"| Entities
    Services -->|"Use Domain Types"| Common
    Services -->|"Use Domain Types"| Enums
    RepoImpl -->|"Use DbContext"| DbContext
    DbContext -->|"Query/Update"| Database
    Migrations -->|"Schema Changes"| Database
    InfraExt -->|"Registers Repos"| RepoImpl
    AppExt -->|"Registers Services"| Services

    %% Click Events
    click Browser "https://github.com/yeury-dcm/medsync/tree/master/MedSync.Presentation.Web/wwwroot"
    click Program "https://github.com/yeury-dcm/medsync/blob/master/MedSync.Presentation.Web/Program.cs"
    click Controllers "https://github.com/yeury-dcm/medsync/tree/master/MedSync.Presentation.Web/Controllers"
    click Middleware "https://github.com/yeury-dcm/medsync/blob/master/MedSync.Presentation.Web/Middelware/ValidateUserSession.cs"
    click Views "https://github.com/yeury-dcm/medsync/tree/master/MedSync.Presentation.Web/Views"
    click ErrorVM "https://github.com/yeury-dcm/medsync/blob/master/MedSync.Presentation.Web/Models/ErrorViewModel.cs"
    click ServiceIF "https://github.com/yeury-dcm/medsync/tree/master/MedSync.Core.Application/Interfaces/Services"
    click RepoIF "https://github.com/yeury-dcm/medsync/tree/master/MedSync.Core.Application/Interfaces/Repositories"
    click Helpers "https://github.com/yeury-dcm/medsync/blob/master/MedSync.Core.Application/Helpers/SessionHelper.cs"
    click Helpers "https://github.com/yeury-dcm/medsync/blob/master/MedSync.Core.Application/Helpers/PasswordEncryption.cs"
    click Mapping "https://github.com/yeury-dcm/medsync/blob/master/MedSync.Core.Application/Mappings/GeneralProfile.cs"
    click AppExt "https://github.com/yeury-dcm/medsync/blob/master/MedSync.Core.Application/ServiceExtention.cs"
    click Services "https://github.com/yeury-dcm/medsync/tree/master/MedSync.Core.Application/Services"
    click ViewModels "https://github.com/yeury-dcm/medsync/tree/master/MedSync.Core.Application/ViewModels"
    click Entities "https://github.com/yeury-dcm/medsync/tree/master/MedSync.Core.Domain/Entities"
    click Common "https://github.com/yeury-dcm/medsync/tree/master/MedSync.Core.Domain/Common"
    click Enums "https://github.com/yeury-dcm/medsync/tree/master/MedSync.Core.Domain/Enums"
    click DbContext "https://github.com/yeury-dcm/medsync/blob/master/MedSync.Infraestructure.Persistence/Contexts/ApplicationDbContext.cs"
    click RepoImpl "https://github.com/yeury-dcm/medsync/tree/master/MedSync.Infraestructure.Persistence/Repositories"
    click Migrations "https://github.com/yeury-dcm/medsync/tree/master/MedSync.Infraestructure.Persistence/Migrations"
    click InfraExt "https://github.com/yeury-dcm/medsync/blob/master/MedSync.Infraestructure.Persistence/ServiceExtension.cs"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef application fill:#90EE90,stroke:#333,stroke-width:1px
    classDef domain fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef infrastructure fill:#FFA500,stroke:#333,stroke-width:1px
    classDef database fill:#FF9999,stroke:#333,stroke-width:1px
    classDef external fill:#DDDDDD,stroke:#333,stroke-width:1px
```
