# aviirajsharma/elitemart architecture

> Architecture diagram of the GitHub repository aviirajsharma/elitemart, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aviirajsharma/elitemart
- Repository: https://github.com/aviirajsharma/elitemart

## Overview

1. **Overall shape**
   - This is a **multi-module Android shopping app** organized around **Clean Architecture + MVVM**.
   - The codebase is split into three main layers: **presentation**, **domain**, and **data**. The root Gradle setup wires them together.

2. **Presentation module = app entry + UI**
   - `presentation/` contains the **Compose UI**, **ViewModels**, navigation, theming, and Android entry points.
   - Key app entry classes are `MainActivity`, `ShopperApp`, and `ShopperSession`.
   - Screens are grouped by feature: **login/register**, **home**, **all products**, **product details**, **cart**, **cart summary**, **orders**, **profile**, and **user address**.

3. **Presentation state and navigation**
   - Each feature screen has a matching `ViewModel`, which is the state-holder and orchestrator for that screen.
   - Navigation is handled with **Compose Navigation**, with route definitions in `navigation/`.
   - There are custom nav types/wrappers for passing complex objects like **product data** and **user address** between screens.

4. **Domain module = business rules**
   - `domain/` is the core business layer and is intentionally free of Android/UI concerns.
   - It defines:
     - **repository interfaces** for cart, categories, orders, products, and users
     - **use cases** for each business action
     - **domain models** for products, cart, categories, orders, user, and address
     - a **network service interface** used as a boundary to remote data access

5. **Use case layer**
   - The use cases are the primary entry points from ViewModels into business logic.
   - They cover the app’s main actions: **login**, **register**, **fetch products/categories**, **add to cart**, **update quantity**, **get cart**, **cart summary**, **place order**, **list orders**, and **delete product**.
   - This makes the dependency direction clear: UI never talks to repositories directly.

6. **Data module = remote data access**
   - `data/` contains the concrete implementations of the repository interfaces.
   - `NetworkServiceImpl` is the implementation that talks to the backend API.
   - Repository implementations transform remote DTOs into domain-friendly models and expose them to the domain layer.

7. **Data contracts and model boundaries**
   - The repo distinguishes three model layers:
     - **data models / DTOs** in `data/model`
     - **domain models** in `domain/model`
     - **UI models** in `presentation/model`
   - This indicates explicit mapping boundaries between API payloads, business objects, and screen-specific state.

8. **Feature flow through the app**
   - Typical flow is: **Compose screen → ViewModel → Use Case → Repository interface → Repository implementation → Network service → REST API**.
   - Responses then flow back through mapping layers into domain objects and finally into UI state.
   - The app is heavily **network-driven**; there is no obvious local database layer in the tree.

9. **Backend/API boundary**
   - The architecture expects a **remote HTTP/REST backend** and internet access.
   - The README calls out **Ktor client**, though the tree only shows the abstraction/implementation split, not the transport details.
   - The main external dependency boundary is therefore the shopping API for products, auth, cart, orders, and addresses.

10. **Dependency injection**
   - DI is organized per layer:
     - `data/di`
     - `domain/di`
     - `presentation/di`
   - These modules likely bind repository implementations, use cases, and ViewModels into the app graph.
   - The README mentions Koin, and the module structure matches that style of layered injection.

11. **User/session concerns**
   - `ShopperSession` suggests a lightweight session/auth state holder in the presentation layer.
   - Login and registration are first-class flows, so user identity/auth state is a core cross-screen concern.

12. **Main architectural boundaries to show in a diagram**
   - Strong boundary between **UI/state** and **business logic**.
   - Strong boundary between **domain interfaces** and **data implementations**.
   - Strong boundary between **app models** and **API DTOs**.
   - External boundary is the **remote shopping backend** accessed through the network service layer.

13. **Testing footprint**
   - The repo includes unit and instrumented tests in each module, plus a specific `CartViewModelTest`.
   - That suggests the cart flow is an important stateful path and the architecture is designed to be testable at layer boundaries.

Main entry points: [`presentation/src/main/java/com/cscorner/elitemart/ui/feature`](https://github.com/aviirajsharma/elitemart/tree/main/presentation/src/main/java/com/cscorner/elitemart/ui/feature) (ViewModels), [`data/src/main/java/com/cscorner/data/repository`](https://github.com/aviirajsharma/elitemart/tree/main/data/src/main/java/com/cscorner/data/repository) (Repository Impl), [`domain/src/main/java/com/cscorner/domain/usecase`](https://github.com/aviirajsharma/elitemart/tree/main/domain/src/main/java/com/cscorner/domain/usecase) (Use Cases), [`data/src/main/java/com/cscorner/data/network/NetworkServiceImpl.kt`](https://github.com/aviirajsharma/elitemart/blob/main/data/src/main/java/com/cscorner/data/network/NetworkServiceImpl.kt) (NetworkServiceImpl)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_main_activity["MainActivity<br/>android entry<br/>[MainActivity.kt]"]
  node_shopper_app["ShopperApp<br/>app shell<br/>[ShopperApp.kt]"]
  node_shopper_session(("ShopperSession<br/>session state<br/>[ShopperSession.kt]"))
  node_nav_routes["Nav Routes<br/>navigation<br/>[NavRoutes.kt]"]
  node_ui_features["Feature UI<br/>compose screens"]
  node_viewmodels["ViewModels<br/>state holders"]
  node_ui_models["UI Models<br/>ui mapping"]
  node_presentation_di{{"Presentation DI<br/>koin module"}}
end

subgraph group_domain["Domain"]
  node_domain_models["Domain Models<br/>entities"]
  node_repo_interfaces["Repo Contracts<br/>interfaces"]
  node_network_boundary{{"Network Boundary<br/>service interface<br/>[NetworkService.kt]"}}
  node_use_cases["Use Cases<br/>business actions"]
  node_domain_di{{"Domain DI<br/>koin module<br/>[DomainModule.kt]"}}
end

subgraph group_data["Data"]
  node_data_models["DTO Models<br/>api payloads"]
  node_network_impl{{"NetworkServiceImpl<br/>http client"}}
  node_repository_impls["Repository Impl<br/>adapters"]
  node_data_di{{"Data DI<br/>koin module<br/>[DataModule.kt]"}}
end

subgraph group_external["External"]
  node_backend_api[("Shopping API<br/>remote backend")]
end

node_main_activity -->|"launches"| node_shopper_app
node_shopper_app -->|"hosts"| node_nav_routes
node_nav_routes -->|"navigates"| node_ui_features
node_ui_features -->|"reads state"| node_viewmodels
node_viewmodels -->|"invokes"| node_use_cases
node_viewmodels -->|"maps to"| node_ui_models
node_shopper_session -->|"shares auth"| node_viewmodels
node_presentation_di -->|"wires"| node_viewmodels
node_presentation_di -->|"configures"| node_shopper_app
node_use_cases -->|"depends on"| node_repo_interfaces
node_use_cases -->|"returns"| node_domain_models
node_domain_di -->|"wires"| node_use_cases
node_repo_interfaces -->|"abstracts"| node_network_boundary
node_repository_impls -->|"implements"| node_repo_interfaces
node_repository_impls -->|"maps"| node_data_models
node_network_impl -->|"calls"| node_backend_api
node_repository_impls -->|"uses"| node_network_impl
node_data_di -->|"wires"| node_repository_impls
node_data_di -->|"wires"| node_network_impl
node_network_impl -->|"conforms to"| node_network_boundary
node_data_models -.->|"maps into"| node_domain_models
node_ui_models -.->|"derived from"| node_domain_models

click node_main_activity "https://github.com/aviirajsharma/elitemart/blob/main/presentation/src/main/java/com/cscorner/elitemart/MainActivity.kt"
click node_shopper_app "https://github.com/aviirajsharma/elitemart/blob/main/presentation/src/main/java/com/cscorner/elitemart/ShopperApp.kt"
click node_shopper_session "https://github.com/aviirajsharma/elitemart/blob/main/presentation/src/main/java/com/cscorner/elitemart/ShopperSession.kt"
click node_nav_routes "https://github.com/aviirajsharma/elitemart/blob/main/presentation/src/main/java/com/cscorner/elitemart/navigation/NavRoutes.kt"
click node_ui_features "https://github.com/aviirajsharma/elitemart/tree/main/presentation/src/main/java/com/cscorner/elitemart/ui/feature"
click node_viewmodels "https://github.com/aviirajsharma/elitemart/tree/main/presentation/src/main/java/com/cscorner/elitemart/ui/feature"
click node_ui_models "https://github.com/aviirajsharma/elitemart/tree/main/presentation/src/main/java/com/cscorner/elitemart/model"
click node_presentation_di "https://github.com/aviirajsharma/elitemart/blob/main/presentation/src/main/java/com/cscorner/elitemart/di/PresentationModule.kt"
click node_domain_models "https://github.com/aviirajsharma/elitemart/tree/main/domain/src/main/java/com/cscorner/domain/model"
click node_repo_interfaces "https://github.com/aviirajsharma/elitemart/tree/main/domain/src/main/java/com/cscorner/domain/repository"
click node_network_boundary "https://github.com/aviirajsharma/elitemart/blob/main/domain/src/main/java/com/cscorner/domain/network/NetworkService.kt"
click node_use_cases "https://github.com/aviirajsharma/elitemart/tree/main/domain/src/main/java/com/cscorner/domain/usecase"
click node_domain_di "https://github.com/aviirajsharma/elitemart/blob/main/domain/src/main/java/com/cscorner/domain/di/DomainModule.kt"
click node_data_models "https://github.com/aviirajsharma/elitemart/tree/main/data/src/main/java/com/cscorner/data/model"
click node_network_impl "https://github.com/aviirajsharma/elitemart/blob/main/data/src/main/java/com/cscorner/data/network/NetworkServiceImpl.kt"
click node_repository_impls "https://github.com/aviirajsharma/elitemart/tree/main/data/src/main/java/com/cscorner/data/repository"
click node_data_di "https://github.com/aviirajsharma/elitemart/blob/main/data/src/main/java/com/cscorner/data/di/DataModule.kt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main_activity,node_shopper_app,node_shopper_session,node_nav_routes,node_ui_features,node_viewmodels,node_ui_models,node_presentation_di toneBlue
class node_domain_models,node_repo_interfaces,node_network_boundary,node_use_cases,node_domain_di toneAmber
class node_data_models,node_network_impl,node_repository_impls,node_data_di toneMint
class node_backend_api toneRose
```

## Components

### Presentation

Compose UI, navigation, session, and feature ViewModels

- [MainActivity](https://github.com/aviirajsharma/elitemart/blob/main/presentation/src/main/java/com/cscorner/elitemart/MainActivity.kt): android entry · Android app entry point · `presentation/src/main/java/com/cscorner/elitemart/MainActivity.kt`
- [ShopperApp](https://github.com/aviirajsharma/elitemart/blob/main/presentation/src/main/java/com/cscorner/elitemart/ShopperApp.kt): app shell · Top-level Compose host and app wiring · `presentation/src/main/java/com/cscorner/elitemart/ShopperApp.kt`
- [ShopperSession](https://github.com/aviirajsharma/elitemart/blob/main/presentation/src/main/java/com/cscorner/elitemart/ShopperSession.kt): session state · Lightweight session/auth state holder · `presentation/src/main/java/com/cscorner/elitemart/ShopperSession.kt`
- [Nav Routes](https://github.com/aviirajsharma/elitemart/blob/main/presentation/src/main/java/com/cscorner/elitemart/navigation/NavRoutes.kt): navigation · Screen routes and navigation graph definitions · `presentation/src/main/java/com/cscorner/elitemart/navigation/NavRoutes.kt`
- [Feature UI](https://github.com/aviirajsharma/elitemart/tree/main/presentation/src/main/java/com/cscorner/elitemart/ui/feature): compose screens · Login, home, products, cart, orders, profile, and address screens · `presentation/src/main/java/com/cscorner/elitemart/ui/feature`
- [ViewModels](https://github.com/aviirajsharma/elitemart/tree/main/presentation/src/main/java/com/cscorner/elitemart/ui/feature): state holders · Screen-level state and orchestration for each feature · `presentation/src/main/java/com/cscorner/elitemart/ui/feature`
- [UI Models](https://github.com/aviirajsharma/elitemart/tree/main/presentation/src/main/java/com/cscorner/elitemart/model): ui mapping · Screen-specific models such as product and user address · `presentation/src/main/java/com/cscorner/elitemart/model`
- [Presentation DI](https://github.com/aviirajsharma/elitemart/blob/main/presentation/src/main/java/com/cscorner/elitemart/di/PresentationModule.kt): koin module · Presentation-layer dependency bindings · `presentation/src/main/java/com/cscorner/elitemart/di/PresentationModule.kt`

### Domain

Business rules, repository contracts, models, and use cases

- [Domain Models](https://github.com/aviirajsharma/elitemart/tree/main/domain/src/main/java/com/cscorner/domain/model): entities · Core business models for products, cart, orders, users, and address · `domain/src/main/java/com/cscorner/domain/model`
- [Repo Contracts](https://github.com/aviirajsharma/elitemart/tree/main/domain/src/main/java/com/cscorner/domain/repository): interfaces · Repository boundaries for cart, categories, orders, products, and users · `domain/src/main/java/com/cscorner/domain/repository`
- [Network Boundary](https://github.com/aviirajsharma/elitemart/blob/main/domain/src/main/java/com/cscorner/domain/network/NetworkService.kt): service interface · Domain-facing network service abstraction · `domain/src/main/java/com/cscorner/domain/network/NetworkService.kt`
- [Use Cases](https://github.com/aviirajsharma/elitemart/tree/main/domain/src/main/java/com/cscorner/domain/usecase): business actions · Login, register, fetch, cart, order, and delete flows · `domain/src/main/java/com/cscorner/domain/usecase`
- [Domain DI](https://github.com/aviirajsharma/elitemart/blob/main/domain/src/main/java/com/cscorner/domain/di/DomainModule.kt): koin module · Domain-layer dependency bindings for use cases and contracts · `domain/src/main/java/com/cscorner/domain/di/DomainModule.kt`

### Data

Repository implementations, DTOs, and network access

- [DTO Models](https://github.com/aviirajsharma/elitemart/tree/main/data/src/main/java/com/cscorner/data/model): api payloads · Remote request and response models · `data/src/main/java/com/cscorner/data/model`
- [NetworkServiceImpl](https://github.com/aviirajsharma/elitemart/blob/main/data/src/main/java/com/cscorner/data/network/NetworkServiceImpl.kt): http client · Concrete remote API access implementation · `data/src/main/java/com/cscorner/data/network/NetworkServiceImpl.kt`
- [Repository Impl](https://github.com/aviirajsharma/elitemart/tree/main/data/src/main/java/com/cscorner/data/repository): adapters · Transforms DTOs into domain-friendly data and fulfills repository contracts · `data/src/main/java/com/cscorner/data/repository`
- [Data DI](https://github.com/aviirajsharma/elitemart/blob/main/data/src/main/java/com/cscorner/data/di/DataModule.kt): koin module · Data-layer dependency bindings for network and repositories · `data/src/main/java/com/cscorner/data/di/DataModule.kt`

### External

Remote shopping backend

- **Shopping API**: remote backend · External REST backend for auth, catalog, cart, orders, and address

## Connections

- MainActivity → ShopperApp: launches · Activity starts the Compose app shell
- ShopperApp → Nav Routes: hosts · App shell owns navigation and screen routing
- Nav Routes → Feature UI: navigates · Routes connect to feature screens
- Feature UI → ViewModels: reads state · Screens observe and send events to ViewModels
- ViewModels → Use Cases: invokes · ViewModels call business actions through use cases
- ViewModels → UI Models: maps to · Presentation converts domain data into screen models
- ShopperSession → ViewModels: shares auth · Session state is consumed by feature state holders
- Presentation DI → ViewModels: wires · Presentation DI provides ViewModels
- Presentation DI → ShopperApp: configures · Presentation DI supports app setup
- Use Cases → Repo Contracts: depends on · Business logic depends on repository contracts only
- Use Cases → Domain Models: returns · Use cases operate on domain models
- Domain DI → Use Cases: wires · Domain DI assembles use case graph
- Repo Contracts → Network Boundary: abstracts · Repository contracts sit above the service boundary
- Repository Impl → Repo Contracts: implements · Concrete repositories fulfill domain contracts
- Repository Impl → DTO Models: maps · Repository implementations transform DTOs
- NetworkServiceImpl → Shopping API: calls · HTTP client talks to remote shopping backend
- Repository Impl → NetworkServiceImpl: uses · Repositories fetch data through the network service implementation
- Data DI → Repository Impl: wires · Data DI binds repository implementations
- Data DI → NetworkServiceImpl: wires · Data DI binds network implementation
- NetworkServiceImpl → Network Boundary: conforms to · Concrete network service satisfies the domain boundary
- DTO Models → Domain Models: maps into · Remote payloads are converted into domain objects
- UI Models → Domain Models: derived from · Screen models are projected from domain data
