# trylyhak/final_dart_pos_system architecture

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

- Interactive diagram: https://gitdiagram.com/trylyhak/final_dart_pos_system
- Repository: https://github.com/trylyhak/final_dart_pos_system

## Overview

This repository implements a point-of-sale system: a Flutter client supports sign-in, product and category browsing, cart-based sales, and order handling, backed by a PHP JSON API and MySQL. The main workflow sends client requests through API route dispatch to domain controllers, which validate and perform operations through models. Order creation checks stock, records the order and its items, and deducts inventory in a transaction. The tree and excerpts do not establish the frontend's exact service-to-view calls or all category/auth internals, so those links are omitted where unverified.

Main entry points: [`pos_backend/api/index.php`](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/index.php) (API router), [`pos_backend/api/controllers/OrderController.php`](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/controllers/OrderController.php) (Order processing), [`pos_backend/api/config/database.php`](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/config/database.php) (DB connection), [`pos_backend/api/helpers/response.php`](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/helpers/response.php) (JSON responses)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["POS client"]
  node_flutter_app["Flutter app<br/>[app.dart]"]
  node_admin_views["Admin menu<br/>[admin_menu.dart]"]
  node_sale_views["Sales menu<br/>[sale_menu.dart]"]
  node_client_services["API services<br/>[api_services.dart]"]
  node_auth_service["Auth service<br/>[auth_services.dart]"]
  node_product_service["Product service"]
  node_client_models["POS models"]
end

subgraph group_api["HTTP API"]
  node_http_entry["API router<br/>[index.php]"]
  node_responses["JSON responses<br/>[response.php]"]
end

subgraph group_domain["Domain operations"]
  node_auth["Authentication<br/>[AuthController.php]"]
  node_categories["Category management"]
  node_products["Product management"]
  node_orders["Order processing"]
end

subgraph group_persistence["Persistence"]
  node_database_config["DB connection<br/>[database.php]"]
  node_user_model["User records<br/>[user.php]"]
  node_category_model["Category records<br/>[category.php]"]
  node_product_model["Product and stock<br/>[product.php]"]
  node_order_model["Order records<br/>[order.php]"]
  node_mysql[("MySQL database")]
end

node_operator(("POS operator"))

node_operator -.->|"uses"| node_flutter_app
node_http_entry -->|"routes login"| node_auth
node_http_entry -->|"routes categories"| node_categories
node_http_entry -->|"routes products"| node_products
node_http_entry -->|"routes orders"| node_orders
node_auth -->|"looks up user"| node_user_model
node_categories -->|"manages categories"| node_category_model
node_products -->|"manages products"| node_product_model
node_orders -->|"reads and writes"| node_order_model
node_orders -->|"checks and deducts stock"| node_product_model
node_auth -->|"opens connection"| node_database_config
node_categories -->|"opens connection"| node_database_config
node_products -->|"opens connection"| node_database_config
node_orders -->|"opens connection"| node_database_config
node_database_config -->|"connects"| node_mysql
node_user_model -.->|"queries"| node_mysql
node_category_model -.->|"queries"| node_mysql
node_product_model -.->|"queries"| node_mysql
node_order_model -.->|"queries"| node_mysql
node_http_entry -->|"sends errors"| node_responses
node_auth -->|"returns result"| node_responses
node_categories -->|"returns result"| node_responses
node_products -->|"returns result"| node_responses
node_orders -->|"returns result"| node_responses
node_flutter_app -.->|"shows"| node_admin_views
node_flutter_app -.->|"shows"| node_sale_views
node_admin_views -.->|"uses"| node_product_service
node_sale_views -.->|"uses"| node_product_service
node_sale_views -.->|"uses cart and order data"| node_client_models
node_auth_service -.->|"uses"| node_client_services
node_product_service -.->|"uses"| node_client_services
node_client_services -.->|"calls API"| node_http_entry

click node_flutter_app "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_frontend/lib/app.dart"
click node_admin_views "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_frontend/lib/views/admin_menu.dart"
click node_sale_views "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_frontend/lib/views/sale_menu.dart"
click node_client_services "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_frontend/lib/services/api_services.dart"
click node_auth_service "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_frontend/lib/services/auth_services.dart"
click node_product_service "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_frontend/lib/services/product_service.dart"
click node_client_models "https://github.com/trylyhak/final_dart_pos_system/tree/main/pos_frontend/lib/models"
click node_http_entry "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/index.php"
click node_responses "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/helpers/response.php"
click node_auth "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/controllers/AuthController.php"
click node_categories "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/controllers/CategoryController.php"
click node_products "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/controllers/ProductController.php"
click node_orders "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/controllers/OrderController.php"
click node_database_config "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/config/database.php"
click node_user_model "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/models/user.php"
click node_category_model "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/models/category.php"
click node_product_model "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/models/product.php"
click node_order_model "https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/models/order.php"

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_flutter_app,node_admin_views,node_sale_views,node_client_services,node_auth_service,node_product_service,node_client_models toneBlue
class node_http_entry,node_responses toneAmber
class node_auth,node_categories,node_products,node_orders toneMint
class node_database_config,node_user_model,node_category_model,node_product_model,node_order_model,node_mysql toneRose
class node_operator toneIndigo
```

## Components

### POS client

- [Flutter app](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_frontend/lib/app.dart): `pos_frontend/lib/app.dart`
- [Admin menu](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_frontend/lib/views/admin_menu.dart): `pos_frontend/lib/views/admin_menu.dart`
- [Sales menu](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_frontend/lib/views/sale_menu.dart): `pos_frontend/lib/views/sale_menu.dart`
- [API services](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_frontend/lib/services/api_services.dart): `pos_frontend/lib/services/api_services.dart`
- [Auth service](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_frontend/lib/services/auth_services.dart): `pos_frontend/lib/services/auth_services.dart`
- [Product service](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_frontend/lib/services/product_service.dart): `pos_frontend/lib/services/product_service.dart`
- [POS models](https://github.com/trylyhak/final_dart_pos_system/tree/main/pos_frontend/lib/models): `pos_frontend/lib/models`

### HTTP API

- [API router](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/index.php): `pos_backend/api/index.php`
- [JSON responses](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/helpers/response.php): `pos_backend/api/helpers/response.php`

### Domain operations

- [Authentication](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/controllers/AuthController.php): `pos_backend/api/controllers/AuthController.php`
- [Category management](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/controllers/CategoryController.php): `pos_backend/api/controllers/CategoryController.php`
- [Product management](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/controllers/ProductController.php): `pos_backend/api/controllers/ProductController.php`
- [Order processing](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/controllers/OrderController.php): `pos_backend/api/controllers/OrderController.php`

### Persistence

- [DB connection](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/config/database.php): `pos_backend/api/config/database.php`
- [User records](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/models/user.php): `pos_backend/api/models/user.php`
- [Category records](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/models/category.php): `pos_backend/api/models/category.php`
- [Product and stock](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/models/product.php): `pos_backend/api/models/product.php`
- [Order records](https://github.com/trylyhak/final_dart_pos_system/blob/main/pos_backend/api/models/order.php): `pos_backend/api/models/order.php`
- **MySQL database**

### Other components

- **POS operator**

## Connections

- POS operator → Flutter app: uses
- API router → Authentication: routes login (evidence: `pos_backend/api/index.php`)
- API router → Category management: routes categories (evidence: `pos_backend/api/index.php`)
- API router → Product management: routes products (evidence: `pos_backend/api/index.php`)
- API router → Order processing: routes orders (evidence: `pos_backend/api/index.php`)
- Authentication → User records: looks up user (evidence: `pos_backend/api/controllers/AuthController.php`)
- Category management → Category records: manages categories (evidence: `pos_backend/api/controllers/CategoryController.php`)
- Product management → Product and stock: manages products (evidence: `pos_backend/api/controllers/ProductController.php`)
- Order processing → Order records: reads and writes (evidence: `pos_backend/api/controllers/OrderController.php`)
- Order processing → Product and stock: checks and deducts stock (evidence: `pos_backend/api/controllers/OrderController.php`)
- Authentication → DB connection: opens connection (evidence: `pos_backend/api/controllers/AuthController.php`)
- Category management → DB connection: opens connection (evidence: `pos_backend/api/controllers/CategoryController.php`)
- Product management → DB connection: opens connection (evidence: `pos_backend/api/controllers/ProductController.php`)
- Order processing → DB connection: opens connection (evidence: `pos_backend/api/controllers/OrderController.php`)
- DB connection → MySQL database: connects (evidence: `pos_backend/api/config/database.php`)
- User records → MySQL database: queries
- Category records → MySQL database: queries
- Product and stock → MySQL database: queries
- Order records → MySQL database: queries
- API router → JSON responses: sends errors (evidence: `pos_backend/api/index.php`)
- Authentication → JSON responses: returns result (evidence: `pos_backend/api/controllers/AuthController.php`)
- Category management → JSON responses: returns result (evidence: `pos_backend/api/controllers/CategoryController.php`)
- Product management → JSON responses: returns result (evidence: `pos_backend/api/controllers/ProductController.php`)
- Order processing → JSON responses: returns result (evidence: `pos_backend/api/controllers/OrderController.php`)
- Flutter app → Admin menu: shows
- Flutter app → Sales menu: shows
- Admin menu → Product service: uses
- Sales menu → Product service: uses
- Sales menu → POS models: uses cart and order data
- Auth service → API services: uses
- Product service → API services: uses
- API services → API router: calls API
