Skip to content

Gophermart - #1

Merged
iPatrushevSergey merged 254 commits into
masterfrom
gophermart
Feb 24, 2026
Merged

iPatrushevSergey merged 254 commits into
masterfrom
gophermart

Conversation

@iPatrushevSergey

Copy link
Copy Markdown
Owner

Summary

Реализована часть системы лояльности GopherMart на Go по принципам Clean Architecture.

Функциональность

  • Регистрация и аутентификация пользователей (JWT)
  • Загрузка номеров заказов с валидацией по алгоритму Луна
  • Получение списка заказов и их статусов
  • Начисление баллов через интеграцию с внешним сервисом accrual (фоновый воркер)
  • Просмотр баланса, списание баллов, история списаний

Архитектура (Clean Architecture)

  • domain/ — сущности, value objects, доменные сервисы
  • application/ — use cases, порты (интерфейсы), DTO
  • presentation/ — HTTP-хендлеры, middleware, воркеры
  • adapters/ — PostgreSQL, JWT, bcrypt, accrual-клиент
  • cmd/bootstrap/ — composition root, DI

Тестирование

  • Unit-тесты доменного слоя, use cases и HTTP-хендлеров (gomock, testify)
  • Интеграционные тесты репозиториев (testcontainers-go + PostgreSQL)
  • E2E API-тесты полного пользовательского флоу

Added Withdrawal struct (immutable event: UserID, OrderNumber, Amount, ProcessedAt).
Added Luhn algorithm implementation for order number validation.
Added UserID value object.
Added Points value object.
Added OrderNumber value object with Luhn validation.
Added domain value object errors.
Changed comments in entity package from Russian to English.
Added domain service for loyalty balance operations (ApplyAccrual, Withdraw).
Added domain service to create withdrawal records.
Added concise comment describing the type.
Added concise comments for type and methods; removed implementation note from Version.
Added concise comments; removed API/DB mapping details.
Added concise comment describing the type.
Added concise comment describing the service role.
Added concise comment describing the service role.
Added concise comments for type and Create method.
Added concise comment; removed storage details.
Added concise comments for type and methods.
Added concise error description.
Added RegisterInput and LoginInput for use case input.
Added ErrNotFound, ErrAlreadyExists, ErrConflict, ErrInvalidCredentials.
Added port for password hashing and verification.
Added port for auth token issue and validation.
Added UseCase[In,Out] interface for interactors.
Added port for user persistence (Create, FindByID, FindByLogin).
Added LoginUser interactor.
Added RegisterUser interactor.
Added in-memory UserRepository for dev and tests.
Added BCrypt implementation of PasswordHasher.
Added JWT implementation of TokenProvider.
Moved user creation logic from UserService into entity constructor
Moved order creation logic from OrderService into entity constructor
Moved withdrawal creation logic from WithdrawalService into entity constructor
Replaced UserService and BalanceService deps with entity.NewUser
Removed service dependencies from constructor calls
Replaced OrderService dep with entity.NewOrder
Removed service dependencies from constructor calls
Replaced WithdrawalService dep with entity.NewWithdrawal
Removed service dependencies from constructor calls
Added streaming method returning iter.Seq2 for lazy order fetching
Added StreamByStatuses mock method
Added iter.Seq2-based streaming query with cursor iteration
Added configurable worker pool size for accrual processing
Replaced sequential loop with streaming iter.Seq2 and errgroup workers
Replaced ListByStatuses mocks with StreamByStatuses and ordersIter helper
Required for errgroup in accrual processing
Replaced positional params with WithXxx options and validation
Switched NewUseCaseFactory call to WithXxx option functions
Switched NewUseCaseFactory call to WithXxx option functions
Replaced by entity constructors NewUser, NewOrder, NewWithdrawal
Replaced RetryConfig struct with RetryOption functions and pluggable BackoffFunc/RetriableFunc
Added DoWithRetry convenience method for repositories
Replaced package-level DoWithRetry calls with transactor method
Replaced package-level DoWithRetry calls with transactor method
Replaced package-level DoWithRetry calls with transactor method
Replaced package-level DoWithRetry calls with transactor method
Switched to WithMaxRetries and WithExponentialBackoff
Replaced RetryConfig with WithMaxRetries option
Switched NewTransactor to WithMaxRetries and WithExponentialBackoff
@iPatrushevSergey
iPatrushevSergey merged commit 72500a0 into master Feb 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants