# arthur-sena/teste-novibet architecture

> Architecture diagram of the GitHub repository arthur-sena/teste-novibet, 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/arthur-sena/teste-novibet
- Repository: https://github.com/arthur-sena/teste-novibet

## Overview

##### Project type and purpose
- This is a .NET 8.0 Web API microservice (“Novibet”) with a complementary test project (“Novibet.Test”).
- Purpose: provide IP-lookup and country information via HTTP endpoints, backed by Entity Framework Core, in-memory caching, and a scheduled job to refresh IP data.

##### File structure
- Top-level Novibet folder contains:
- Controllers: Http API entry points (IpController).
- Services: business logic interfaces and implementations (IpService, UpdateIpJobService).
- Application: higher‐level use‐case orchestrators (IpApplication, UpdateIpJobApplication).
- Repositories: data‐access interfaces and EF Core implementations (IpRepository, CountryRepository).
- Models: domain and DTO classes (IPAddressDomain, CountryDomain, IPAddressResponse, IpReportResponse, CacheConfiguration).
- AppDbContext: EF Core DbContext, configured via appsettings.json.
- Program.cs / launchSettings.json: application startup, dependency injection, Quartz scheduler registration.
- Novibet.Test folder:
- Unit tests for Repository classes using xUnit, Moq, EF Core In-Memory provider.

##### README for additional insights
- Uses EF Core for persistence.
- In-memory caching for repeated IP lookups.
- Quartz to schedule a recurring job that updates IP data.
- xUnit/Moq for testing.

##### Elements
- Blue rectangles for API/Controllers
- Green rectangles for Application/Service layer
- Orange rectangles for Repository/DbContext

##### Summary of steps
- Step C: Annotate with technologies (.NET 8, EF Core, MemoryCache, Quartz).
- Step E: Optionally, add a small inset showing the test project layering over repositories with EF InMemory.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        IpController["IpController"]:::controller
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        IIpApplication["IIpApplication"]:::application
        IpApplication["IpApplication"]:::application
        UpdateIpJobApplication["UpdateIpJobApplication"]:::application
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        IIpService["IIpService"]:::service
        IpService["IpService"]:::service
        IUpdateIpJobService["IUpdateIpJobService"]:::service
        UpdateIpJobService["UpdateIpJobService"]:::service
    end

    %% Repository Layer
    subgraph "Repository Layer"
        direction TB
        IIpRepository["IIpRepository"]:::repository
        IpRepository["IpRepository"]:::repository
        ICountryRepository["ICountryRepository"]:::repository
        CountryRepository["CountryRepository"]:::repository
        AppDbContext["AppDbContext"]:::db
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        direction TB
        MemoryCache["MemoryCache"]:::cache
        SQLDatabase["SQL Database"]:::db
        QuartzScheduler["Quartz Scheduler"]:::scheduler
        ExternalIPSource["External IP Source"]:::external
    end

    %% Test Suite
    subgraph "Test Suite (Novibet.Test)"
        direction TB
        IpRepositoryTests["IpRepositoryTests"]:::test
        CountryRepositoryTests["CountryRepositoryTests"]:::test
    end

    %% Request Flow
    IpController -->|"calls"| IIpApplication
    IIpApplication -->|"uses"| IpApplication
    IpApplication -->|"calls"| IIpService
    IIpService -->|"implements"| IpService
    IpService -->|"checks cache"| MemoryCache
    IpService -->|"on miss calls"| IIpRepository
    IIpRepository -->|"implements"| IpRepository
    IpRepository -->|"EF Core uses"| AppDbContext
    AppDbContext -->|"persists to"| SQLDatabase

    %% Scheduler Flow
    QuartzScheduler -.->|"triggers"| UpdateIpJobApplication
    UpdateIpJobApplication -->|"uses"| IUpdateIpJobService
    IUpdateIpJobService -->|"implements"| UpdateIpJobService
    UpdateIpJobService -->|"reads/writes"| IIpRepository
    UpdateIpJobService -->|"reads/writes"| ICountryRepository
    ICountryRepository -->|"implements"| CountryRepository
    CountryRepository -->|"EF Core uses"| AppDbContext
    UpdateIpJobService -.->|"optionally ingests"| ExternalIPSource

    %% Test Flow
    IpRepositoryTests -->|"tests"| IpRepository
    IpRepositoryTests -->|"uses InMemory"| AppDbContext
    CountryRepositoryTests -->|"tests"| CountryRepository
    CountryRepositoryTests -->|"uses InMemory"| AppDbContext

    %% Click Events
    click IpController "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Controllers/IpController.cs"
    click IpApplication "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Application/Application/IpApplication.cs"
    click UpdateIpJobApplication "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Application/Application/UpdateIpJobApplication.cs"
    click IIpApplication "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Application/Interfaces/IIpApplication.cs"
    click IpService "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Services/Services/IpService.cs"
    click UpdateIpJobService "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Services/Services/UpdateIpJobService.cs"
    click IIpService "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Services/Interfaces/IIpService.cs"
    click IUpdateIpJobService "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Services/Interfaces/IUpdateIpJobService.cs"
    click IpRepository "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Repositories/Repositories/IpRepository.cs"
    click CountryRepository "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Repositories/Repositories/CountryRepository.cs"
    click IIpRepository "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Repositories/Interface/IIpRepository.cs"
    click ICountryRepository "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Repositories/Interface/ICountryRepository.cs"
    click AppDbContext "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/AppDbContext.cs"
    click Program "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Program.cs"
    click launchSettings "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/Properties/launchSettings.json"
    click appsettings "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/appsettings.json"
    click appsettingsDev "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet/appsettings.Development.json"
    click CountryRepositoryTests "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet.Test/Repositories/CountryRepositoryTests.cs"
    click IpRepositoryTests "https://github.com/arthur-sena/teste-novibet/blob/main/Novibet.Test/Repositories/IpRepositoryTests.cs"

    %% Styles
    classDef controller fill:#D0E8FF,stroke:#0284C7,stroke-width:1px;
    classDef application fill:#D4FDD6,stroke:#059669,stroke-width:1px;
    classDef service fill:#E6F0FF,stroke:#2563EB,stroke-width:1px;
    classDef repository fill:#FFEDD5,stroke:#F97316,stroke-width:1px;
    classDef db fill:#FCE7F3,stroke:#DB2777,stroke-width:1px,stroke-dasharray: 5 5;
    classDef cache fill:#FEF3C7,stroke:#EAB308,stroke-width:1px;
    classDef scheduler fill:#E0E7FF,stroke:#4338CA,stroke-width:1px,stroke-dasharray: 2 2;
    classDef external fill:#F3F4F6,stroke:#6B7280,stroke-width:1px,stroke-dasharray: 2 2;
    classDef test fill:#F5F5F5,stroke:#9CA3AF,stroke-width:1px,stroke-dasharray: 2 2;
```
