Skip to content

Commit

Permalink
Implementing a Web API. (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Utar94 authored Dec 31, 2023
1 parent 79b8953 commit 4115808
Show file tree
Hide file tree
Showing 88 changed files with 3,683 additions and 356 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ csharp_space_between_method_call_empty_parameter_list_parentheses = false
# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
[*.{cs,vb}]
dotnet_diagnostic.IDE0290.severity = none
###############################
# VB Coding Conventions #
###############################
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build PokéData Solution
name: Build PokéData Solution

on:
push:
Expand All @@ -8,11 +8,11 @@ on:

jobs:
build:
name: Build PokéData Solution
name: Build PokéData Solution
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Build Docker Image
run: docker build . -t francispion.azurecr.io/pokedata:${{ github.sha }} -f src/PokeData.ETL/Dockerfile
run: docker build . -t francispion.azurecr.io/pokedata:${{ github.sha }} -f src/PokeData/Dockerfile
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,3 @@ MigrationBackup/

# Fody - auto-generated XML schema
FodyWeavers.xsd

# Output files
resources.json
species.csv
species.json
45 changes: 44 additions & 1 deletion PokeData.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitattributes = .gitattributes
.gitignore = .gitignore
CHANGELOG.md = CHANGELOG.md
docker-compose.yml = docker-compose.yml
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokeData.ETL", "src\PokeData.ETL\PokeData.ETL.csproj", "{FC44EF38-D8A6-4A84-84AB-7597501F54BF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PokeData.ETL", "src\PokeData.ETL\PokeData.ETL.csproj", "{FC44EF38-D8A6-4A84-84AB-7597501F54BF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokeData.EntityFrameworkCore.Relational", "src\PokeData.EntityFrameworkCore.Relational\PokeData.EntityFrameworkCore.Relational.csproj", "{2F7CBF71-7E37-4539-A193-348BFC76AB06}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokeData.Domain", "src\PokeData.Domain\PokeData.Domain.csproj", "{ABD45B7D-7392-4829-B18B-20E4472F76F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokeData.Application", "src\PokeData.Application\PokeData.Application.csproj", "{A01D90FC-6A0B-4B81-B37F-8CA9F7C3EDC4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokeData.Infrastructure", "src\PokeData.Infrastructure\PokeData.Infrastructure.csproj", "{F3366415-E934-4B9B-BAA5-9E6327DAD65D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokeData.Infrastructure.PokeApiClient", "src\PokeData.Infrastructure.PokeApiClient\PokeData.Infrastructure.PokeApiClient.csproj", "{9D563A01-E981-47AB-9DC8-64E65BDE8949}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokeData.EntityFrameworkCore.SqlServer", "src\PokeData.EntityFrameworkCore.SqlServer\PokeData.EntityFrameworkCore.SqlServer.csproj", "{A97D552B-387E-4BB9-9D56-B6E1D950DE5B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokeData", "src\PokeData\PokeData.csproj", "{1448F506-73E9-4664-A419-002B79A8C276}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -26,6 +41,34 @@ Global
{FC44EF38-D8A6-4A84-84AB-7597501F54BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC44EF38-D8A6-4A84-84AB-7597501F54BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC44EF38-D8A6-4A84-84AB-7597501F54BF}.Release|Any CPU.Build.0 = Release|Any CPU
{2F7CBF71-7E37-4539-A193-348BFC76AB06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2F7CBF71-7E37-4539-A193-348BFC76AB06}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F7CBF71-7E37-4539-A193-348BFC76AB06}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2F7CBF71-7E37-4539-A193-348BFC76AB06}.Release|Any CPU.Build.0 = Release|Any CPU
{ABD45B7D-7392-4829-B18B-20E4472F76F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ABD45B7D-7392-4829-B18B-20E4472F76F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ABD45B7D-7392-4829-B18B-20E4472F76F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ABD45B7D-7392-4829-B18B-20E4472F76F2}.Release|Any CPU.Build.0 = Release|Any CPU
{A01D90FC-6A0B-4B81-B37F-8CA9F7C3EDC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A01D90FC-6A0B-4B81-B37F-8CA9F7C3EDC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A01D90FC-6A0B-4B81-B37F-8CA9F7C3EDC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A01D90FC-6A0B-4B81-B37F-8CA9F7C3EDC4}.Release|Any CPU.Build.0 = Release|Any CPU
{F3366415-E934-4B9B-BAA5-9E6327DAD65D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3366415-E934-4B9B-BAA5-9E6327DAD65D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3366415-E934-4B9B-BAA5-9E6327DAD65D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3366415-E934-4B9B-BAA5-9E6327DAD65D}.Release|Any CPU.Build.0 = Release|Any CPU
{9D563A01-E981-47AB-9DC8-64E65BDE8949}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D563A01-E981-47AB-9DC8-64E65BDE8949}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D563A01-E981-47AB-9DC8-64E65BDE8949}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D563A01-E981-47AB-9DC8-64E65BDE8949}.Release|Any CPU.Build.0 = Release|Any CPU
{A97D552B-387E-4BB9-9D56-B6E1D950DE5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A97D552B-387E-4BB9-9D56-B6E1D950DE5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A97D552B-387E-4BB9-9D56-B6E1D950DE5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A97D552B-387E-4BB9-9D56-B6E1D950DE5B}.Release|Any CPU.Build.0 = Release|Any CPU
{1448F506-73E9-4664-A419-002B79A8C276}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1448F506-73E9-4664-A419-002B79A8C276}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1448F506-73E9-4664-A419-002B79A8C276}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1448F506-73E9-4664-A419-002B79A8C276}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3.8'
services:
pokedata_mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
container_name: PokeData_mssql
ports:
- 27945:1433
environment:
ACCEPT_EULA: 'Y'
MSSQL_SA_PASSWORD: m7tPnE6dB5TQxYCW

pokedata_api:
build:
context: .
dockerfile: /src/PokeData/Dockerfile
image: pokedata_api
container_name: PokeData_api
depends_on:
- pokedata_mssql
restart: unless-stopped
environment:
ASPNETCORE_Environment: Development
SQLCONNSTR_Master: Server=pokedata_mssql,27945;Database=Pokemon;User Id=SA;Password=m7tPnE6dB5TQxYCW;Persist Security Info=False;Encrypt=False;
ports:
- 43551:8080
9 changes: 9 additions & 0 deletions src/PokeData.Application/Caching/ICacheService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using PokeData.Domain.Resources;

namespace PokeData.Application.Caching;

public interface ICacheService
{
Resource? GetResource(Uri source);
void SetResource(Resource resource);
}
11 changes: 11 additions & 0 deletions src/PokeData.Application/DependencyInjectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Microsoft.Extensions.DependencyInjection;

namespace PokeData.Application;

public static class DependencyInjectionExtensions
{
public static IServiceCollection AddPokeDataApplication(this IServiceCollection services)
{
return services.AddMediatR(config => config.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));
}
}
8 changes: 8 additions & 0 deletions src/PokeData.Application/IResourceService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using PokeData.Domain.Species;

namespace PokeData.Application;

public interface IResourceService
{
Task<PokemonSpecies?> GetSpeciesAsync(string id, CancellationToken cancellationToken = default);
}
23 changes: 23 additions & 0 deletions src/PokeData.Application/PokeData.Application.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\PokeData.Domain\PokeData.Domain.csproj" />
</ItemGroup>

<ItemGroup>
<Using Include="System.Reflection" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using MediatR;

namespace PokeData.Application.Species.Commands;

public record ImportSpeciesCommand(IEnumerable<string> Ids) : INotification;
13 changes: 13 additions & 0 deletions src/PokeData.Domain/Generations/Generation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using PokeData.Domain.Regions;

namespace PokeData.Domain.Generations;

public class Generation
{
public byte Number { get; set; }

public string UniqueName { get; set; } = string.Empty;
public string? DisplayName { get; set; }

public Region? MainRegion { get; set; }
}
14 changes: 14 additions & 0 deletions src/PokeData.Domain/PokeData.Domain.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Logitar.EventSourcing" Version="5.0.0" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions src/PokeData.Domain/PokemonType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace PokeData.Domain;

public class PokemonType
{
public byte Number { get; set; }

public string UniqueName { get; set; } = string.Empty;
public string? DisplayName { get; set; }
}
13 changes: 13 additions & 0 deletions src/PokeData.Domain/Regions/Region.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using PokeData.Domain.Generations;

namespace PokeData.Domain.Regions;

public class Region
{
public byte Number { get; set; }

public string UniqueName { get; set; } = string.Empty;
public string? DisplayName { get; set; }

public Generation? MainGeneration { get; set; }
}
3 changes: 3 additions & 0 deletions src/PokeData.Domain/Resources/Content.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace PokeData.Domain.Resources;

public record Content(string Type, string Text);
8 changes: 8 additions & 0 deletions src/PokeData.Domain/Resources/IResourceRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace PokeData.Domain.Resources;

public interface IResourceRepository
{
Task<IEnumerable<Resource>> GetAsync(CancellationToken cancellationToken = default);
Task<Resource?> GetAsync(Uri source, CancellationToken cancellationToken = default);
Task SaveAsync(Resource resource, CancellationToken cancellationToken = default);
}
3 changes: 3 additions & 0 deletions src/PokeData.Domain/Resources/Resource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace PokeData.Domain.Resources;

public record Resource(Uri Source, Content Content);
29 changes: 29 additions & 0 deletions src/PokeData.Domain/Species/PokemonSpecies.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using PokeData.Domain.Generations;

namespace PokeData.Domain.Species;

public class PokemonSpecies
{
public ushort Number { get; set; }
public ushort Order { get; set; }

public bool IsBaby { get; set; }
public bool IsLegendary { get; set; }
public bool IsMythical { get; set; }
public bool HasGenderDifferences { get; set; }
public bool CanSwitchForm { get; set; }

public string UniqueName { get; set; } = string.Empty;
public string? DisplayName { get; set; }
public string? Category { get; set; }

public double? GenderRatio { get; set; }
public byte CatchRate { get; set; }
public byte HatchTime { get; set; }

public byte BaseFriendship { get; set; }

public Generation? Generation { get; set; }

public List<PokemonVariety> Varieties { get; set; } = [];
}
20 changes: 20 additions & 0 deletions src/PokeData.Domain/Species/PokemonVariety.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace PokeData.Domain.Species;

public class PokemonVariety
{
public ushort Number { get; set; }
public ushort Order { get; set; }

public string UniqueName { get; set; } = string.Empty;

public PokemonType? PrimaryType { get; set; }
public PokemonType? SecondaryType { get; set; }

public double Height { get; set; }
public double Weight { get; set; }

public ushort BaseExperienceYield { get; set; }

public PokemonSpecies? Species { get; set; }
public bool IsDefault { get; set; }
}
23 changes: 0 additions & 23 deletions src/PokeData.ETL/Entities/Generation.cs

This file was deleted.

45 changes: 0 additions & 45 deletions src/PokeData.ETL/Entities/PokemonSpecies.cs

This file was deleted.

16 changes: 0 additions & 16 deletions src/PokeData.ETL/Entities/PokemonType.cs

This file was deleted.

Loading

0 comments on commit 4115808

Please sign in to comment.