# carlosdevelopp/crud_movies_store architecture

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

- Interactive diagram: https://gitdiagram.com/carlosdevelopp/crud_movies_store
- Repository: https://github.com/carlosdevelopp/crud_movies_store

## Overview

##### Project Type and Purpose
- This is a server-side Web API project built in C# using ASP.NET Core 8.0. It implements a classic three-layer architecture:
- Presentation layer: an ASP.NET Core Web API (“MoviesStore” project)
- Business/infrastructure layer: service interfaces, DTOs and business logic (“Infrastructure” project)
- Data access layer: Entity Framework Core context, repository implementations and database models (“DataAccess” project)
- Its purpose is to expose CRUD operations on movie-related entities (Movies, Actors, Genres, Awards) backed by a SQL Server 2019 database.

##### Directory Structure and Architectural Patterns
- Top-level solution file (MoviesStore.sln) orchestrates three projects:
- MoviesStore (the Web API host)
- Infrastructure (service contracts, DTOs, service implementations)
- DataAccess (EF Core DbContext, repository pattern)
- Patterns in use:
- Layered (Presentation → Infrastructure → DataAccess → Database)
- Repository/Unit-of-Work (MoviesDataAccess.cs over ApplicationDbContext)
- DTOs for data transfer between layers
- Dependency Injection (built-in ASP.NET Core DI container)

##### Key Components
a. Presentation Layer (ASP.NET Core Web API)
- MoviesController (handles HTTP requests)
- Program/Startup (application host, middleware pipeline, DI registration)
- Configuration files (appsettings.json)
b. Infrastructure Layer
- IMoviesInfrastructure (service contract)
- MoviesInfrastructure (business logic, data mapping between DTOs and entities)
- DTO types (MoviesDTO, ActorsDTO, etc.)
c. Data Access Layer
- IMoviesDataAccess (repository contract)
- MoviesDataAccess (EF Core repository)
- ApplicationDbContext (DbContext with DbSet<Tables>)
- EF Core entity models (Movies, Actors, Genres, Awards, MoviesActors join table)
d. External Systems
- SQL Server 2019 database instance
- (Optional) Swagger/OpenAPI if used
- (Optional) Logging/Monitoring sinks

##### Relationships and Data Flow
- HTTP client → ASP.NET Core Web API (MoviesController)
- Controller calls MoviesInfrastructure via IMoviesInfrastructure
- MoviesInfrastructure calls MoviesDataAccess via IMoviesDataAccess
- MoviesDataAccess uses ApplicationDbContext to query/update SQL Server
- Results flow back up: EF entity → Infrastructure DTO → HTTP response

##### Architectural Patterns and Technologies
- Layered architecture with clear separation of concerns
- Repository pattern for data operations, hiding ORM details
- DTO mapping in Infrastructure layer to decouple API from EF entities
- EF Core for ORM, SQL Server 2019 as the persistent store
- ASP.NET Core 8.0 for hosting Web API, dependency injection, configuration, middleware

##### Final Checklist
- Four layers: Client / Presentation / Infrastructure / Data Access / Database
- Key components in each layer, clearly labeled
- Callouts for major technologies: ASP.NET Core 8.0, EF Core, SQL Server 2019

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Client
    Client["HTTP Client"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Controller["MoviesController"]:::presentation
        Program["Program / Startup"]:::presentation
        Config["appsettings.json\n(appsettings.Development.json)"]:::presentation
    end

    %% Infrastructure Layer
    subgraph "Business/Infrastructure Layer"
        direction TB
        IMoviesInfra["IMoviesInfrastructure"]:::interface
        MoviesInfra["MoviesInfrastructure"]:::infrastructure
        DTOs["DTO Types"]:::note
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        IMoviesData["IMoviesDataAccess"]:::interface
        MoviesData["MoviesDataAccess"]:::dataaccess
        DbContext["ApplicationDbContext"]:::dataaccess
        Entities["EF Core Entities"]:::note
    end

    %% Database
    Database[(SQL Server 2019)]:::database

    %% Connections
    Client -->|"HTTP Request/Response"| Controller
    Controller -->|"calls IMoviesInfrastructure"| IMoviesInfra
    IMoviesInfra -->|"implemented by MoviesInfrastructure"| MoviesInfra
    MoviesInfra -->|"invokes IMoviesDataAccess"| IMoviesData
    IMoviesData -->|"implemented by MoviesDataAccess"| MoviesData
    MoviesData -->|"uses DbContext"| DbContext
    DbContext -->|"executes SQL Queries"| Database

    %% Click Events
    click Controller "https://github.com/carlosdevelopp/crud_movies_store/blob/main/MoviesStore/MoviesStore/Controllers/MoviesController.cs"
    click Program "https://github.com/carlosdevelopp/crud_movies_store/blob/main/MoviesStore/MoviesStore/Program.cs"
    click Config "https://github.com/carlosdevelopp/crud_movies_store/blob/main/MoviesStore/MoviesStore/appsettings.json"
    click IMoviesInfra "https://github.com/carlosdevelopp/crud_movies_store/blob/main/MoviesStore/Infrastructure/Contract/IMoviesInfrastructure.cs"
    click MoviesInfra "https://github.com/carlosdevelopp/crud_movies_store/blob/main/MoviesStore/Infrastructure/Implementation/MoviesInfrastructure.cs"
    click DTOs "https://github.com/carlosdevelopp/crud_movies_store/tree/main/MoviesStore/Infrastructure/DTO"
    click IMoviesData "https://github.com/carlosdevelopp/crud_movies_store/blob/main/MoviesStore/DataAccess/Contract/IMoviesDataAccess.cs"
    click MoviesData "https://github.com/carlosdevelopp/crud_movies_store/blob/main/MoviesStore/DataAccess/Implementation/MoviesDataAccess.cs"
    click DbContext "https://github.com/carlosdevelopp/crud_movies_store/blob/main/MoviesStore/DataAccess/Implementation/Base/ApplicationDbContext.cs"
    click Entities "https://github.com/carlosdevelopp/crud_movies_store/tree/main/MoviesStore/DataAccess/Models/Tables"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef presentation fill:#ccf,stroke:#333,stroke-width:1px
    classDef infrastructure fill:#cfc,stroke:#333,stroke-width:1px
    classDef dataaccess fill:#fcf,stroke:#333,stroke-width:1px
    classDef interface stroke-dasharray: 5 5,fill:#fff,stroke:#333,stroke-width:1px
    classDef database fill:#afa,stroke:#333,stroke-width:1px,shape:cylinder
    classDef note fill:#ffe,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
```
