# oneduckyboy/portfolioproject architecture

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

- Interactive diagram: https://gitdiagram.com/oneduckyboy/portfolioproject
- Repository: https://github.com/oneduckyboy/portfolioproject

## Overview

##### Project Type and Purpose
- This is a full-stack, layered ASP.NET Core MVC portfolio application used both as a live portfolio and a graduation thesis project.
- It follows a Clean (Onion) Architecture style, separating presentation, business logic, data access, and domain models into distinct projects.

##### File Structure Analysis
- Top-level “portfolio” folder = Presentation layer (ASP.NET Core MVC): Controllers, Razor Views, Identity UI, Program.cs, wwwroot, Dockerfile, appsettings.
- “Core” = Business layer: service interfaces & implementations, repository interfaces & base repository, email & image-upload service abstractions.
- “DataAccess” = Infrastructure layer: EF Core DbContext, migrations, Docker Compose + Dockerfile for SQL Server.
- “Models” = Domain layer: entity classes (User, Project, Category, Comment, Image, Role, etc.).
- “Utils” = Utility helpers (miscellaneous static helpers).
- “ProjectTests” = Test suite covering Controllers, Services, Repositories, Models, DataAccess migrations.

##### Key Technologies and Patterns
- ASP.NET Core MVC (Controllers + Razor Views)
- ASP.NET Identity (in Areas/Identity)
- Entity Framework Core (Repository pattern + DbContext + Migrations)
- Repository & Service patterns (interfaces in Core.Repositories, Core.Services)
- Docker Compose for local SQL Server
- xUnit (or MSTest) for unit/integration tests
- External services: Cloudinary (image upload), SMTP/email sender

##### Main Components
a. Presentation Layer (Blue)
- MVC Controllers (Home, Category, Project, Comment, Image, User)
- Razor Views & Static Assets (CSS/JS in wwwroot)
- Identity Razor Pages (Areas/Identity)
b. Business Layer (Green)
- Service Interfaces (IService, IImageUploadService, IEmailSender, etc.)
- Service Implementations (Service.cs, ImageUploadService, EmailSender)
c. Data Access Layer (Orange)
- Repository Interfaces (IRepository)
- Repository Implementation (Repository.cs)
- EF Core DbContext (ApplicationDbContext) + Migrations
- Dockerized SQL Server (docker-compose.yml, Dockerfile)
d. Domain Models Layer (Yellow)
- BaseEntity, User, Project, Category, Comment, Image, Role, LikedProjects, LikedComments
e. Utilities & Tests (Gray)
- Utils helper methods
- ProjectTests (unit + integration tests)
f. External Services (Red)
- Cloudinary API (image storage)
- SMTP / Email provider

##### Relationships & Data Flows
- User (Browser) → HTTP Request → MVC Controller
- Controller → calls appropriate Service interface
- Service → calls Repository interface
- Repository → interacts with EF Core DbContext → SQL Server (Docker)
- Service → may call external services:
- ImageUploadService → Cloudinary API
- EmailSender → SMTP/Email API
- ASP.NET Identity flows similarly through its own DbContext into SQL Server
- Test project mimics and validates these flows via mocks/fakes

##### Architectural Patterns & Design Principles
- Clean/Onion Architecture: strict layer independence, Dependency Inversion via interfaces
- Repository Pattern for data access abstraction
- Service Pattern for business rules
- MVC for presentation separation
- Dependency Injection (built into ASP.NET Core)

##### Essential Elements to Capture
- Separation of concerns across Core, DataAccess, Models, Utils, Presentation
- Interaction between ASP.NET Identity and your main DbContext
- Dockerized SQL Server environment
- External image/email services
- Automated tests sitting outside the main runtime flow

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Controllers["Controllers"]:::presentation
        Views["Razor Views & Static Assets"]:::presentation
        Identity["Areas/Identity & IdentityDbContext"]:::presentation
        Program["Program.cs"]:::presentation
        Static["wwwroot"]:::presentation
        Settings["appsettings.json & appsettings.Development.json"]:::presentation
        DockerP["Dockerfile"]:::presentation
    end

    %% Business Layer
    subgraph "Business Layer"
        direction TB
        ServicesIntf["Service Interfaces & Implementations"]:::business
        ReposIntf["Repository Interfaces & Implementations"]:::business
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        DbContext["ApplicationDbContext (EF Core)"]:::dataaccess
        Migrations["Migrations"]:::dataaccess
        DockerSQL["docker-compose.yml & Dockerfile"]:::dataaccess
        DataAccessProj["DataAccess.csproj"]:::dataaccess
    end

    %% Domain Models Layer
    subgraph "Domain Models Layer"
        direction TB
        DomainModels["Entity Models"]:::domain
    end

    %% Utilities & Tests
    subgraph "Utilities & Tests"
        direction TB
        Utils["Utils Helpers"]:::utils
        Tests["ProjectTests"]:::utils
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Cloudinary["Cloudinary API"]:::external
        SMTP["SMTP / Email Provider"]:::external
        SQLServer((SQL Server)):::dataaccess
    end

    %% Data Flows
    Browser["User Browser"]:::external -->|HTTP Request| Controllers
    Controllers -->|calls| ServicesIntf
    ServicesIntf -->|calls| ReposIntf
    ReposIntf -->|uses| DbContext
    DbContext -->|SQL Queries| SQLServer
    Identity -->|auth data| DbContext
    ServicesIntf -->|image upload| Cloudinary
    ServicesIntf -->|email send| SMTP

    %% Tests interactions
    Tests -.-> Controllers
    Tests -.-> ServicesIntf
    Tests -.-> ReposIntf
    Tests -.-> DbContext
    Tests -.-> DomainModels

    %% Click Events
    click Controllers "https://github.com/oneduckyboy/portfolioproject/tree/master/portfolio/Controllers"
    click Views "https://github.com/oneduckyboy/portfolioproject/tree/master/portfolio/Views"
    click Identity "https://github.com/oneduckyboy/portfolioproject/tree/master/portfolio/Areas/Identity"
    click Program "https://github.com/oneduckyboy/portfolioproject/blob/master/portfolio/Program.cs"
    click Static "https://github.com/oneduckyboy/portfolioproject/tree/master/portfolio/wwwroot"
    click Settings "https://github.com/oneduckyboy/portfolioproject/blob/master/portfolio/appsettings.json"
    click DockerP "https://github.com/oneduckyboy/portfolioproject/tree/master/portfolio/Dockerfile"
    click ServicesIntf "https://github.com/oneduckyboy/portfolioproject/tree/master/Core/Services"
    click ReposIntf "https://github.com/oneduckyboy/portfolioproject/tree/master/Core/Repositories"
    click DbContext "https://github.com/oneduckyboy/portfolioproject/blob/master/DataAccess/Data/ApplicationDbContext.cs"
    click Migrations "https://github.com/oneduckyboy/portfolioproject/tree/master/DataAccess/Migrations"
    click DockerSQL "https://github.com/oneduckyboy/portfolioproject/blob/master/DataAccess/docker_sql server/docker-compose.yml"
    click DockerSQL "https://github.com/oneduckyboy/portfolioproject/tree/master/DataAccess/docker_sql server/dockerfile"
    click DataAccessProj "https://github.com/oneduckyboy/portfolioproject/blob/master/DataAccess/DataAccess.csproj"
    click DomainModels "https://github.com/oneduckyboy/portfolioproject/tree/master/Models/Models"
    click Utils "https://github.com/oneduckyboy/portfolioproject/blob/master/Utils/Class1.cs"
    click Tests "https://github.com/oneduckyboy/portfolioproject/blob/master/ProjectTests/ProjectTests.csproj"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#004085,color:#004085;
    classDef business fill:#d4edda,stroke:#155724,color:#155724;
    classDef dataaccess fill:#fff3cd,stroke:#856404,color:#856404;
    classDef domain fill:#fefefe,stroke:#818a91,color:#818a91,fill:#fff3cd;
    classDef utils fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef external fill:#f8d7da,stroke:#721c24,color:#721c24;
```
