I'm looking for feedback on the structure and design of my .NET project (GitHub repo link...

Discussão em 'Angular' iniciado por Koray Erdem, Maio 7, 2025.

  1. Koray Erdem

    Koray Erdem Guest

    I've recently made my GitHub repository public and would appreciate your feedback on the overall structure and design of my .NET project.

    GitHub Repository: https://github.com/ErdemKoray/Beavask

    My questions are:

    Do you think the overall architecture is reasonably aligned with the principles of Clean Architecture?

    Are the API designs mostly in line with RESTful conventions?

    This is my first mid-sized project developed with .NET, so I'm looking to improve both in terms of structure and best practices. I'm not working on the frontend myself, but if you also have suggestions about the frontend structure or design, they are welcome too.

    Architecture overview The solution is structured as follows:

    Application project references the Domain project

    Infrastructure project also references the Domain project

    API project references both the Application and Infrastructure projects

    Note: I think the API project should ideally reference only the Application project, and Infrastructure should be injected through dependency inversion. I'd appreciate your thoughts on that.

    Sample business logic method Here’s one of the business logic methods as an example: public async Task<Response> CreateProjectFromGitHubRepoAsync(CreateProjectFromGitHubRepoDto repo, string repoUrl) { try { bool isCompanyProject = false;

    if (_currentUser.UserId.HasValue && _currentUser.LastName != null)
    {
    isCompanyProject = false;
    }
    else if (_currentCompany.CompanyId.HasValue)
    {
    isCompanyProject = true;
    }

    var repoInfo = await _repoService.GetSingleRepositoryDetailAsync(repoUrl);

    if (repoInfo == null || repoInfo.Data == null)
    {
    return Response<bool>.Fail("Repository not found");
    }

    bool projectExistsForUser = await _unitOfWork.ProjectRepository
    .AskProjectNameExistsForUser(repoInfo.Data.HtmlUrl, _currentUser.UserId.Value);
    if (projectExistsForUser)
    {
    return Response<bool>.Fail("Repository already exists for user");
    }

    bool projectExistsForCompany = await _unitOfWork.ProjectRepository
    .AskProjectNameExistsForCompany(repoInfo.Data.HtmlUrl, _currentCompany.CompanyId.Value);
    if (projectExistsForCompany)
    {
    return Response<bool>.Fail("Repository already exists for company");
    }

    var project = new Project
    {
    Name = repoInfo.Data.Name,
    Description = repoInfo.Data.Description,
    IsCompanyProject = isCompanyProject,
    RepoUrl = repoInfo.Data.HtmlUrl,
    UserId = isCompanyProject ? null : _currentUser.UserId,
    CompanyId = isCompanyProject ? _currentCompany.CompanyId : null
    };

    await _unitOfWork.ProjectRepository.AddAsync(project);
    await _unitOfWork.SaveChangesAsync();

    return Response<bool>.Success(true);
    }
    catch (Exception ex)
    {
    return Response<bool>.Fail($"Error: {ex.Message}");
    }


    }

    I structured my .NET project using a layered architecture inspired by Clean Architecture principles. I followed some common practices, such as separating Domain, Application, Infrastructure, and API layers.

    I expected that this structure would make the project scalable and maintainable. However, since this is my first mid-sized .NET project, I’m not entirely sure if I applied Clean Architecture correctly or followed RESTful API conventions properly.

    That’s why I’m sharing the GitHub repo and asking for your feedback on both the architectural decisions and the API design.

    Continue reading...

Compartilhe esta Página