refactor: standardize project names to Musify.* and flatten layout

- Flatten nested per-repo folders into flat Musify.* projects at root
- Rename assemblies/csproj: Domain->Musify.Domain, Application->Musify.Application,
  Infrastructure->Musify.Infrastructure, WebApi->Musify.Api, Worker->Musify.Worker,
  StreamingGateway->Musify.StreamingGateway
- Rename WebApi.* namespaces to Musify.Api.*
- Update all ProjectReference paths and the solution file
- Consolidate stray per-repo dotfiles; add root .gitattributes
- Move flutter client out to _archive

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-05 03:32:48 +02:00
co-authored by Claude Opus 4.8
parent 8ab4d27287
commit f6d668d201
259 changed files with 82 additions and 1711 deletions
@@ -0,0 +1,26 @@
using Ardalis.Result;
using Mediator;
using Musify.Application.Users.Responses;
using Musify.Domain.Entities;
namespace Musify.Application.Users.Commands
{
public record CreateUserCommand(long Id,
string Name,
string? FirstName,
string? SecondName)
: ICommand<Result<UserApplicationResponse>>
{
public static User ToEntity(CreateUserCommand command)
{
return new User
{
Id = command.Id,
Name = command.Name,
NormalizedName = command.Name.ToUpperInvariant(),
FirstName = command.FirstName,
SecondName = command.SecondName
};
}
}
}
@@ -0,0 +1,13 @@
using Ardalis.Result;
using Mediator;
namespace Musify.Application.Users.Commands
{
public record SyncUserCommand(
long Id,
string Name,
string? FirstName,
string? SecondName,
string? ProfilePictureUrl)
: ICommand<Result>;
}
@@ -0,0 +1,40 @@
using Ardalis.Result;
using Mediator;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Musify.Application.Contracts;
using Musify.Application.Users.Commands;
using Musify.Application.Users.Responses;
namespace Musify.Application.Users.Handlers
{
public class CreateUserCommandHandler(IDatabase database, ILogger<CreateUserCommandHandler> logger)
: ICommandHandler<CreateUserCommand, Result<UserApplicationResponse> >
{
public async ValueTask<Result<UserApplicationResponse>> Handle(CreateUserCommand request, CancellationToken cancellationToken)
{
var userExists = await database.Users.AnyAsync(u => u.Id == request.Id, cancellationToken);
if (userExists)
{
logger.LogInformation("User {UserId} already exists", request.Id);
return Result<UserApplicationResponse>.Conflict($"User {request.Id} already exists");
}
var newUser = CreateUserCommand.ToEntity(request);
try
{
await database.Users.AddAsync(newUser, cancellationToken);
await database.SaveChangesAsync(cancellationToken);
}
catch (Exception exception)
{
logger.LogError(exception, "Failed to create user {UserId}", request.Id);
return Result.Error($"Failed to create user {request.Id}");
}
logger.LogInformation("Created user {UserId}", newUser.Id);
return Result.Created(UserApplicationResponse.FromEntity(newUser));
}
}
}
@@ -0,0 +1,26 @@
using Ardalis.Result;
using Mediator;
using Microsoft.EntityFrameworkCore;
using Musify.Application.Contracts;
using Musify.Application.Users.Queries;
using Musify.Application.Users.Responses;
namespace Musify.Application.Users.Handlers
{
public class GetUserByIdQueryHandler(IDatabase database)
: IQueryHandler<GetUserByIdQuery, Result<UserApplicationResponse> >
{
public async ValueTask<Result<UserApplicationResponse>> Handle(GetUserByIdQuery request, CancellationToken cancellationToken)
{
var user = await database.Users
.AsNoTracking()
.Where(u => u.Id == request.Id)
.Select(u => UserApplicationResponse.FromEntity(u))
.SingleOrDefaultAsync(cancellationToken);
return user is null
? Result<UserApplicationResponse>.NotFound()
: Result.Success(user);
}
}
}
@@ -0,0 +1,35 @@
using Ardalis.Result;
using Mediator;
using Microsoft.EntityFrameworkCore;
using Musify.Application.Pagination;
using Musify.Application.Users.Queries;
using Musify.Application.Users.Responses;
using X.PagedList.EF;
using Musify.Application.Contracts;
namespace Musify.Application.Users.Handlers
{
public class GetUsersQueryHandler(IDatabase database)
: IQueryHandler<GetUsersQuery, Result<PaginatedResponse<UserApplicationResponse> > >
{
public async ValueTask<Result<PaginatedResponse<UserApplicationResponse> >> Handle(GetUsersQuery request, CancellationToken cancellationToken)
{
var user = database.Users
.AsNoTracking()
.AsQueryable();
if (request.UsernameSearch is not null)
{
var normalizedUsername = request.UsernameSearch.Trim().ToUpperInvariant();
user = user.Where(u => u.NormalizedName.Contains(normalizedUsername));
}
var totalCount = await user.CountAsync(cancellationToken);
var pagedUser = await user
.Select(u => UserApplicationResponse.FromEntity(u))
.ToPagedListAsync(request.PageNumber, request.PageSize, totalCount, cancellationToken);
return Result.Success(PaginatedResponse<UserApplicationResponse>.FromPagedList(pagedUser));
}
}
}
@@ -0,0 +1,50 @@
using Ardalis.Result;
using Mediator;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Musify.Application.Contracts;
using Musify.Application.Users.Commands;
using Musify.Domain.Entities;
namespace Musify.Application.Users.Handlers
{
public class SyncUserCommandHandler(IDatabase database, ILogger<SyncUserCommandHandler> logger)
: ICommandHandler<SyncUserCommand, Result>
{
public async ValueTask<Result> Handle(SyncUserCommand request, CancellationToken cancellationToken)
{
var user = await database.Users
.SingleOrDefaultAsync(u => u.Id == request.Id, cancellationToken);
if (user is null)
{
await database.Users.AddAsync(new User
{
Id = request.Id,
Name = request.Name,
NormalizedName = request.Name.ToUpperInvariant(),
FirstName = request.FirstName,
SecondName = request.SecondName,
ProfilePictureUrl = request.ProfilePictureUrl
}, cancellationToken);
await database.SaveChangesAsync(cancellationToken);
logger.LogInformation("Provisioned user {UserId}", request.Id);
return Result.Success();
}
user.Name = request.Name;
user.NormalizedName = request.Name.ToUpperInvariant();
user.FirstName = request.FirstName;
user.SecondName = request.SecondName;
user.ProfilePictureUrl = request.ProfilePictureUrl;
var written = await database.SaveChangesAsync(cancellationToken);
if (written > 0)
logger.LogInformation("Synced profile for user {UserId}", request.Id);
return Result.Success();
}
}
}
@@ -0,0 +1,9 @@
using Ardalis.Result;
using Mediator;
using Musify.Application.Users.Responses;
namespace Musify.Application.Users.Queries
{
public record GetUserByIdQuery(long Id)
: IQuery<Result<UserApplicationResponse> >;
}
@@ -0,0 +1,10 @@
using Ardalis.Result;
using Mediator;
using Musify.Application.Pagination;
using Musify.Application.Users.Responses;
namespace Musify.Application.Users.Queries
{
public record GetUsersQuery(int PageNumber, int PageSize, string? UsernameSearch = null)
: IQuery<Result<PaginatedResponse<UserApplicationResponse> >>;
}
@@ -0,0 +1,26 @@
using Musify.Domain.Entities;
namespace Musify.Application.Users.Responses
{
public record UserApplicationResponse(
long Id,
string Name,
string? FirstName,
string? SecondName,
string? ProfilePictureUrl,
DateTime CreatedAt,
DateTime UpdatedAt)
{
public static UserApplicationResponse FromEntity(User user)
{
return new UserApplicationResponse(
user.Id,
user.Name,
user.FirstName,
user.SecondName,
user.ProfilePictureUrl,
user.CreatedAt,
user.UpdatedAt);
}
}
}