# athulcoding07-sudo/gamewear_2 architecture

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

- Interactive diagram: https://gitdiagram.com/athulcoding07-sudo/gamewear_2
- Repository: https://github.com/athulcoding07-sudo/gamewear_2

## Overview

1. **Overall shape**
- This is a single Django monolith organized into feature apps under `apps/`.
- The project is presentation-heavy and server-rendered: Django views render HTML templates from `templates/`, with static assets under `static/`.
- `config/` contains the project-level wiring: URL routing, middleware, ASGI/WSGI entrypoints, and app composition.

2. **Main bounded contexts**
- The repository is split into functional domains rather than a single generic app:
  - `users` for authentication, profiles, addresses, and account security
  - `otp` for OTP generation/verification/expiry
  - `products` for catalog, cart, wishlist, reviews, orders, and addresses
  - `payments` for payment handling and payment result pages
  - `wallet` for stored balance and wallet-based payments
  - `coupons` for discount creation, lookup, and dashboard management
  - `adminpanel` for back-office workflows
  - `home` and `common` for landing/shared concerns

3. **Request/response presentation layer**
- Most user-facing flows are implemented with Django views in each app and HTML templates in `templates/...`.
- The template tree shows distinct UI surfaces for:
  - public landing pages
  - customer auth and dashboard
  - product browsing and product details
  - cart, checkout, orders, wishlist, wallet, and profile management
  - admin-facing dashboards for customers, products, orders, and coupons
- This suggests a server-side rendered architecture with little or no frontend SPA layering.

4. **Authentication and account lifecycle**
- `users` is the core identity boundary: custom user model, manager, forms, validators, and utility functions.
- The README confirms email/password login plus email OTP for signup and password reset.
- Account state is extended with features such as blocked users and profile image handling, indicating the user model is central to authorization and profile presentation.

5. **OTP subsystem**
- `otp` is a reusable support service rather than just a one-off view helper.
- It contains OTP models, service functions, and utility helpers, which implies the flow is:
  - generate OTP
  - persist or associate it with a user/pending identity
  - send it via email
  - validate expiry and correctness
- This subsystem depends on email delivery, likely through Gmail SMTP as described in the README.

6. **Catalog, cart, checkout, and order pipeline**
- `products` is the largest domain and spans multiple commerce stages:
  - catalog entities like products, categories, brands, variants
  - cart and cart items
  - wishlist items
  - reviews and review images
  - orders and order items
  - shipping/order address data
- The migration history shows the schema evolved over time from simple catalog models into a fuller commerce pipeline.
- This app is the main business-domain backbone for customer purchasing behavior.

7. **Service/selector layering**
- Some apps separate read and write logic into `selectors/` and `services/`, especially `coupons` and `wallet`.
- That indicates a deliberate application-service pattern:
  - selectors handle queries and read models
  - services handle business actions and state transitions
- This boundary matters for the architecture diagram because business rules are not concentrated only in views or models.

8. **Coupons and promotions**
- `coupons` is structured as a standalone domain with forms, selectors, services, views, and URLs.
- It includes both customer-facing coupon application and dashboard-facing coupon management.
- The presence of separate `dashboard_coupon_services.py` and dashboard views suggests admin/back-office coupon workflows are distinct from user redemption flows.

9. **Payments and wallet**
- `payments` handles the external payment flow and result pages, likely as the payment gateway integration boundary.
- `wallet` is a separate balance-management subsystem with:
  - wallet models
  - payment services
  - selectors
  - validators
  - signals
  - dedicated wallet and payment views
- The signals file indicates wallet balance changes can be event-driven, not just direct controller updates.
- Architecturally, wallet appears to be a shared financial ledger used alongside standard payments.

10. **Admin/back-office surface**
- `adminpanel` is not just Django admin customization; it is a full custom back-office application.
- Its templates cover customer management, product/category/brand maintenance, coupon lists, and order status updates.
- This creates a second major UI surface for staff, separate from the customer dashboard and public storefront.

11. **Shared and cross-cutting code**
- `common` contains reusable helpers such as decorators and shared views/models.
- `users/utils.py`, `otp/utils.py`, and validators across apps show shared concern handling is localized per domain but reused where needed.
- `config/middleware.py` suggests project-wide request processing concerns exist outside individual apps, likely for auth/session or response shaping.

12. **Data and persistence**
- The app uses Django ORM migrations heavily, which means the architecture is database-centered and schema-driven.
- The README mentions SQLite/PostgreSQL, so the same codebase can run against a local or production relational database.
- Many domain transitions are modeled through migrations rather than external services, indicating state is primarily stored in the application database.

13. **External integrations**
- The most important external dependency is email delivery, used for OTP-based signup and password reset.
- The README references Gmail SMTP and environment variables such as `EMAIL_HOST_USER`, `EMAIL_HOST_PASSWORD`, and `SECRET_KEY`.
- No other major external infrastructure is evident from the tree, so the app is mostly self-contained aside from email and database services.

14. **High-level flow to diagram**
- A good architecture diagram would show:
  - browser requests entering Django routing in `config/urls.py`
  - dispatch into feature apps by URL namespace
  - views calling services/selectors/forms/models
  - persistent state in the relational database
  - email/SMS-like OTP delivery via SMTP email
  - separate customer and admin presentation paths
- The main business flows are authentication/OTP, product browsing, cart/checkout/order placement, payment or wallet settlement, and staff management through the admin panel.

Main entry points: [`config/urls.py`](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/config/urls.py) (URL router), [`apps/products/views.py`](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/products/views.py) (Commerce views), [`apps/users/views.py`](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/users/views.py) (Account views), [`apps/adminpanel/views.py`](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/adminpanel/views.py) (Back office)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_home_views["Landing<br/>Public views<br/>[views.py]"]
  node_users_views["Account views<br/>Customer views<br/>[views.py]"]
  node_adminpanel_views["Back office<br/>Staff views<br/>[views.py]"]
  node_products_views["Commerce views<br/>Storefront views<br/>[views.py]"]
  node_payments_views["Payment views<br/>Gateway views<br/>[views.py]"]
  node_wallet_views["Wallet views<br/>Financial views<br/>[wallet_views.py]"]
  node_coupon_views["Coupon views<br/>Promotion views<br/>[coupon_views.py]"]
  node_dashboard_coupon_views["Coupon admin<br/>Back-office views"]
end

subgraph group_domains["Domain apps"]
  node_users_models[("Users model<br/>Identity model<br/>[models.py]")]
  node_otp_services{{"OTP service<br/>Verification service<br/>[services.py]"}}
  node_products_models[("Catalog core<br/>Commerce models<br/>[models.py]")]
  node_products_service{{"Commerce service<br/>Business rules<br/>[services.py]"}}
  node_coupon_services{{"Coupon engine<br/>Promotion service<br/>[coupon_services.py]"}}
  node_wallet_service{{"Wallet ledger<br/>Financial service<br/>[wallet_service.py]"}}
  node_payments_models[("Payments model<br/>Gateway state<br/>[models.py]")]
end

subgraph group_platform["Platform"]
  node_config_urls["URL router<br/>Django routing<br/>[urls.py]"]
  node_middleware["Middleware<br/>Request hooks<br/>[middleware.py]"]
  node_common_views["Shared views<br/>Shared helpers<br/>[views.py]"]
  node_common_decorators{{"Decorators<br/>Shared guards<br/>[decorators.py]"}}
end

subgraph group_integrations["Integrations"]
  node_email_smtp(("Email SMTP<br/>External mail"))
  node_database[("Relational DB<br/>Persistence")]
end

node_config_urls -->|"routes"| node_home_views
node_config_urls -->|"routes"| node_users_views
node_config_urls -->|"routes"| node_products_views
node_config_urls -->|"routes"| node_payments_views
node_config_urls -->|"routes"| node_wallet_views
node_config_urls -->|"routes"| node_adminpanel_views
node_config_urls -->|"routes"| node_coupon_views
node_config_urls -->|"routes"| node_dashboard_coupon_views
node_config_urls -.->|"wraps"| node_middleware
node_users_views -->|"reads/writes"| node_users_models
node_users_views -->|"uses"| node_otp_services
node_users_views -.->|"guards"| node_common_decorators
node_otp_services -->|"sends"| node_email_smtp
node_otp_services -->|"persists"| node_database
node_products_views -->|"reads/writes"| node_products_models
node_products_views -->|"uses"| node_products_service
node_products_views -->|"applies"| node_coupon_services
node_products_views -->|"settles"| node_wallet_service
node_products_service -->|"stores"| node_database
node_payments_views -->|"reads/writes"| node_payments_models
node_payments_views -->|"stores"| node_database
node_wallet_views -->|"uses"| node_wallet_service
node_wallet_service -->|"stores"| node_database
node_coupon_views -->|"uses"| node_coupon_services
node_dashboard_coupon_views -->|"uses"| node_coupon_services
node_adminpanel_views -->|"manages"| node_products_models
node_adminpanel_views -->|"manages"| node_users_models
node_common_views -.->|"reads/writes"| node_database

click node_config_urls "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/config/urls.py"
click node_middleware "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/config/middleware.py"
click node_home_views "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/home/views.py"
click node_users_views "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/users/views.py"
click node_adminpanel_views "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/adminpanel/views.py"
click node_products_views "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/products/views.py"
click node_payments_views "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/payments/views.py"
click node_wallet_views "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/wallet/views/wallet_views.py"
click node_coupon_views "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/coupons/views/coupon_views.py"
click node_dashboard_coupon_views "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/coupons/views/dashboard_coupon_views.py"
click node_users_models "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/users/models.py"
click node_otp_services "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/otp/services.py"
click node_products_models "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/products/models.py"
click node_products_service "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/products/services.py"
click node_coupon_services "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/coupons/services/coupon_services.py"
click node_wallet_service "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/wallet/services/wallet_service.py"
click node_payments_models "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/payments/models.py"
click node_common_views "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/common/views.py"
click node_common_decorators "https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/common/decorators.py"

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_home_views,node_users_views,node_adminpanel_views,node_products_views,node_payments_views,node_wallet_views,node_coupon_views,node_dashboard_coupon_views toneBlue
class node_users_models,node_otp_services,node_products_models,node_products_service,node_coupon_services,node_wallet_service,node_payments_models toneAmber
class node_config_urls,node_middleware,node_common_views,node_common_decorators toneMint
class node_email_smtp,node_database toneRose
```

## Components

### Presentation

Server-rendered Django templates and request handlers for customer and staff flows.

- [Landing](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/home/views.py): Public views · Public homepage and shared landing pages. · `apps/home/views.py`
- [Account views](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/users/views.py): Customer views · Login, signup, profile, address, dashboard, and cart/checkout-facing request handlers. · `apps/users/views.py`
- [Back office](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/adminpanel/views.py): Staff views · Custom admin dashboard and management flows. · `apps/adminpanel/views.py`
- [Commerce views](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/products/views.py): Storefront views · Catalog, product detail, cart, wishlist, reviews, orders, and addresses. · `apps/products/views.py`
- [Payment views](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/payments/views.py): Gateway views · Payment initiation and result pages. · `apps/payments/views.py`
- [Wallet views](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/wallet/views/wallet_views.py): Financial views · Wallet balance, funding, and wallet payment screens. · `apps/wallet/views/wallet_views.py`
- [Coupon views](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/coupons/views/coupon_views.py): Promotion views · Customer-facing coupon application and lookup. · `apps/coupons/views/coupon_views.py`
- [Coupon admin](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/coupons/views/dashboard_coupon_views.py): Back-office views · Staff coupon management screens and actions. · `apps/coupons/views/dashboard_coupon_views.py`

### Domain apps

Feature apps that hold the core business logic and persistence models.

- [Users model](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/users/models.py): Identity model · Custom user, address, profile state, and account lifecycle data. · `apps/users/models.py`
- [OTP service](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/otp/services.py): Verification service · OTP generation, persistence, expiry, and validation logic. · `apps/otp/services.py`
- [Catalog core](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/products/models.py): Commerce models · Products, categories, brands, carts, wishlist, reviews, orders, and shipping data. · `apps/products/models.py`
- [Commerce service](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/products/services.py): Business rules · Shared commerce operations around catalog and ordering. · `apps/products/services.py`
- [Coupon engine](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/coupons/services/coupon_services.py): Promotion service · Coupon lookup, validation, and dashboard promotion workflows. · `apps/coupons/services/coupon_services.py`
- [Wallet ledger](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/wallet/services/wallet_service.py): Financial service · Wallet balance changes, payment flows, and settlement logic. · `apps/wallet/services/wallet_service.py`
- [Payments model](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/payments/models.py): Gateway state · Payment records and external transaction state. · `apps/payments/models.py`

### Platform

Project wiring, shared utilities, and cross-cutting request handling.

- [URL router](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/config/urls.py): Django routing · Project-level URL dispatch and app composition. · `config/urls.py`
- [Middleware](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/config/middleware.py): Request hooks · Cross-cutting request/response processing. · `config/middleware.py`
- [Shared views](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/common/views.py): Shared helpers · Reusable common presentation helpers and views. · `apps/common/views.py`
- [Decorators](https://github.com/athulcoding07-sudo/gamewear_2/blob/main/apps/common/decorators.py): Shared guards · Reusable access and request decorators. · `apps/common/decorators.py`

### Integrations

External delivery and boundary services used by the application.

- **Email SMTP**: External mail · Email delivery used for OTP and password reset messaging.
- **Relational DB**: Persistence · Primary Django ORM-backed relational datastore.

## Connections

- URL router → Landing: routes · Dispatches public landing requests.
- URL router → Account views: routes · Dispatches customer account and storefront requests.
- URL router → Commerce views: routes · Dispatches commerce requests.
- URL router → Payment views: routes · Dispatches payment requests.
- URL router → Wallet views: routes · Dispatches wallet requests.
- URL router → Back office: routes · Dispatches staff back-office requests.
- URL router → Coupon views: routes · Dispatches coupon-related requests.
- URL router → Coupon admin: routes · Dispatches coupon administration requests.
- URL router → Middleware: wraps · Project request handling is mediated by middleware.
- Account views → Users model: reads/writes · Manages identity, profiles, addresses, and account state.
- Account views → OTP service: uses · Coordinates signup and reset OTP flows.
- Account views → Decorators: guards · Uses shared access control helpers.
- OTP service → Email SMTP: sends · Delivers OTP messages through email.
- OTP service → Relational DB: persists · Stores OTP-related state.
- Commerce views → Catalog core: reads/writes · Drives catalog, cart, wishlist, review, and order workflows.
- Commerce views → Commerce service: uses · Delegates commerce business actions.
- Commerce views → Coupon engine: applies · Supports coupon application during commerce flows.
- Commerce views → Wallet ledger: settles · Can route payment settlement through wallet logic.
- Commerce service → Relational DB: stores · Persists commerce state through the ORM.
- Payment views → Payments model: reads/writes · Records payment attempts and results.
- Payment views → Relational DB: stores · Persists payment state.
- Wallet views → Wallet ledger: uses · Coordinates wallet balance and funding actions.
- Wallet ledger → Relational DB: stores · Maintains wallet ledger state.
- Coupon views → Coupon engine: uses · Validates and applies coupons for customers.
- Coupon admin → Coupon engine: uses · Runs staff coupon management workflows.
- Back office → Catalog core: manages · Maintains products, categories, brands, orders, and customers.
- Back office → Users model: manages · Supports customer administration.
- Shared views → Relational DB: reads/writes · Shared application data access where needed.
