Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/danielitoCode/AlejoTaller/llms.txt

Use this file to discover all available pages before exploring further.

The Android client is organised into self-contained feature modules, each following the same data / domain / presentation / di layering. This page documents what each feature does and which use cases drive its business logic. All use-case names below are taken directly from the source tree.

Authentication (feature/auth)

Authentication is the entry point for every customer session. The feature delegates all identity operations to the Appwrite SDK and exposes session state through a StateFlow-backed ViewModel so the rest of the app can react to sign-in and sign-out events.

Capabilities

  • Email and password login
  • Account creation with email/password
  • Custom registration flow
  • Google Sign-In via Android Credential Manager
  • Session persistence across app restarts
  • User profile updates (name, password, phone, photo URL)
  • Account verification status check

Use Cases

Use CaseResponsibility
AuthUserCaseUseAuthenticate an existing user by email and password via Appwrite
CreateAccountUseCaseRegister a new customer account
CustomRegisterCaseUseExtended registration with additional profile data
AuthWithGoogleCaseUseInitiate Google Sign-In using the Android Credential Manager
RegisterWithGoogleUseCaseComplete registration using a Google credential
CloseSessionCaseUseSign out and clear the local session
GetCurrentUserInfoCaseUseRetrieve the authenticated user’s profile from Appwrite
IsUserVerifiedUseCaseCheck whether the account has been email-verified
VerifyUserUseCaseSend or process the email verification request
UpdateUserNameUseCaseUpdate the customer’s display name
UpdateUserPassCaseUseChange the account password
UpdateUserPhoneCaseUseUpdate the customer’s phone number
UpdateUserPhotoUrlCaseUseStore a new profile photo URL
Session state is maintained by the shared-auth module so the operator app and the client app share the same authentication contracts without duplicating logic.

Product Catalog (feature/product)

The product feature gives customers access to the full electronics inventory. Products are cached locally by Room so the catalog remains browsable even without network access.

Capabilities

  • Observe the full product list as a reactive Flow
  • Retrieve a single product by ID for detail screens
  • Sync the remote Appwrite catalog to the local Room database
  • Category-filtered browsing (driven by the category feature)

Use Cases

Use CaseResponsibility
ObserveProductsCaseUseEmit the product list as a Flow from the local Room DAO
GetProductByIdCaseUseFetch a single product entity by its ID from the local cache
SyncProductCaseUsePull the latest product data from Appwrite and write it to Room
Products are the primary offline-first entity. SyncProductCaseUse should be triggered on app start or when connectivity is restored to keep the local cache current with the Appwrite collection.

Categories (feature/category)

The category feature provides the taxonomy used to filter the product catalog. Like products, categories are cached locally for offline availability.

Capabilities

  • Observe the full category list as a reactive Flow
  • Sync the remote Appwrite category collection to Room

Use Cases

Use CaseResponsibility
ObserveCategoriesCaseUseEmit the category list as a Flow from the local Room DAO
SyncCategoriesCaseUsePull categories from Appwrite and persist them locally

Sales & Cart (feature/sale + shared-sale)

The sale feature is the commercial core of the app. It handles cart state, purchase registration, payment initiation, and the offline-first persistence of every order. The foundational domain types and reusable use cases live in the shared-sale module so the web client and Android operator share the same definitions.

Sale Domain Types

// shared-sale
data class Sale(
    val id: String,
    val date: LocalDate,
    val amount: Double,
    val currency: Currency,
    val verified: BuyState,
    val products: List<SaleItem>,
    val userId: String,
    val customerName: String? = null,
    val deliveryType: DeliveryType? = null,
    val deliveryAddress: DeliveryAddress? = null
)

enum class BuyState    { UNVERIFIED, VERIFIED, DELETED }
enum class DeliveryType { PICKUP, DELIVERY }
enum class Currency    { CUP, USD, MLC }

BuyState Lifecycle

UNVERIFIED  ──► VERIFIED   (operator confirms)
            └─► DELETED    (operator rejects)
A sale starts as UNVERIFIED the moment the customer submits it. It transitions to VERIFIED or DELETED only when a real-time event from the operator is received and reconciled locally.

Use Cases in app/ (feature/sale/domain/caseUse)

Use CaseResponsibility
InitiatePaymentCaseUseOrchestrates the full purchase registration flow: assigns a unique ID, notifies the shop via Telegram, persists the sale locally (UNVERIFIED), and requests a checkout URL from the payment gateway. Returns a PaymentInitResult containing the saleId and checkoutUrl.
// InitiatePaymentCaseUse — payment-backed purchase flow
class InitiatePaymentCaseUse(
    private val repository: SaleRepository,
    private val notificationUserProvider: SaleNotificationUserProvider,
    private val telegramNotificator: TelegramNotificator,
    private val paymentGateway: PaymentGateway
) {
    suspend operator fun invoke(
        sale: Sale,
        paymentChannel: PaymentChannel
    ): Result<PaymentInitResult>
}

Use Cases in shared-sale

Use CaseResponsibility
RegisterNewSaleCauseUseRegisters a new sale without online payment: assigns ID, notifies via Telegram, saves to the repository
ObserveAllSalesCaseUseEmits the customer’s sale list as a Flow from the local store
GetSalesByIdCaseUseRetrieves a single sale by ID
SyncSalesCaseUseReconciles local sale records with the remote Appwrite collection
UpdateDeliveryTypeCaseUseUpdates the delivery preference (PICKUP or DELIVERY) on a verified sale
If the payment gateway returns an error, InitiatePaymentCaseUse does not roll back the local save or the Telegram notification. The shop can manage the order manually from the Telegram notification, and the sale remains in local storage as UNVERIFIED.

Real-Time Verification (shared-sale + infrastructure)

Real-time sale verification is the mechanism that closes the loop between the operator’s action and the customer’s in-app feedback. It is implemented as a collaboration between shared-sale use cases and the app’s Pusher infrastructure layer.

Channel Naming

sale-verification-{userId}
Each authenticated customer subscribes to a personal Pusher channel scoped to their user ID. This ensures that verification events are routed only to the correct device.

Events

Event nameMeaning
sale:confirmedThe operator accepted the order; BuyStateVERIFIED
sale:rejectedThe operator rejected the order; BuyStateDELETED

Use Cases

Use CaseResponsibility
SubscribeRealtimeSyncCaseUseSubscribes to the RealtimeSyncGateway for the given userId, forwarding sale events and promotional notifications to caller-provided lambdas
InterpretSaleRealtimeEventCaseUsePure domain function that converts a SaleRealtimeEvent into a list of SaleRealtimeCommand actions (in-app message + push notification)
UpdateSaleVerificationFromRealtimeCaseUseFetches the local sale by ID and writes the new BuyState (VERIFIED or DELETED) only if the state has actually changed
// InterpretSaleRealtimeEventCaseUse — pure, no dependencies
class InterpretSaleRealtimeEventCaseUse {
    operator fun invoke(event: SaleRealtimeEvent): List<SaleRealtimeCommand>
}

// Produces either:
//   SaleRealtimeCommand.InAppMessage  — shown in the UI
//   SaleRealtimeCommand.PushNotification — triggers a local notification
// UpdateSaleVerificationFromRealtimeCaseUse — persists the new state
class UpdateSaleVerificationFromRealtimeCaseUse(
    private val repository: SaleRepository
) {
    suspend operator fun invoke(saleId: String, isSuccess: Boolean): Result<Unit>
}

Processing Pipeline

The app-layer SaleEventProcessor handles raw Pusher payloads before handing them to the domain:
  1. SaleEventProcessor receives the raw RealtimeEventEnvelope from the Pusher connection.
  2. It decodes the JSON payload and dispatches either onSuccess(saleId, userId) or onError(saleId, userId, cause).
  3. The ViewModel calls InterpretSaleRealtimeEventCaseUse to derive UI commands.
  4. UpdateSaleVerificationFromRealtimeCaseUse persists the new BuyState to Room.

Settings (feature/settigns)

The settings feature allows customers to manage their in-app preferences. These are stored locally and influence UI behaviour.

Capabilities

  • Observe and toggle dark mode
  • Toggle haptic feedback
  • Toggle notification preferences

Use Cases

Use CaseResponsibility
ObserveSettingsCaseUseEmits the current settings as a Flow
UpdateDarkModeCaseUsePersists the customer’s dark mode preference
UpdateHapticFeedbackCaseUsePersists the haptic feedback preference
UpdateNotificationsCaseUsePersists the notification opt-in preference

Exchange Rates (feature/exchange)

The exchange rate feature surfaces currency conversion information to help customers understand prices across the three supported currencies (CUP, USD, MLC).

Capabilities

  • Fetch today’s exchange rate from the remote source
  • Read a cached copy when offline

Use Cases

Use CaseResponsibility
GetTodayExchangeCaseUseRetrieves the current exchange rate from the remote data source
GetCachedTodayExchangeCaseUseReturns the last locally cached exchange rate for offline use

Notifications (feature/notifications)

The notifications feature manages promotional messages received through Pusher channels.

Use Cases

Use CaseResponsibility
ObserveActivePromotionsCaseUseEmits the list of active promotions from local storage
SavePromotionCaseUsePersists an incoming promotion received via the real-time gateway

Build docs developers (and LLMs) love