# cybrarist/discount-bandit architecture

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

- Interactive diagram: https://gitdiagram.com/cybrarist/discount-bandit
- Repository: https://github.com/cybrarist/discount-bandit

## Overview

##### Project Type & Purpose
- This is a full-stack web application built with PHP (using Composer and Artisan) designed as a price tracker across multiple online shopping platforms. It notifies users when items drop to their desired price. It includes both a web interface for end-users and an administration section (through Filament) for managers.
- The README emphasizes deployment requirements (PHP, MySQL/SQLite, Apache/Nginx) as well as optional Docker deployment, which indicates flexibility in installation and environment configuration.

##### File Structure
- The “app” directory contains the core application’s logic following an MVC-like pattern: models (app/Models), controllers (app/Http/Controllers), requests, jobs, notifications, and helpers.
- The “app/Filament” subdirectories show resources, pages, and relation managers that suggest use of the Filament admin panel for backend management (CRUD operations for categories, groups, products, users, etc.).
- The “routes” folder splits the endpoints into web, API, and console routes.
- The “database” directory contains migrations, factories, and seeders that indicate relational database setup.
- The “public” directory contains assets and the entry point (index.php) that handles web client requests.
- The presence of Docker configuration files (Dockerfile, docker-compose.yaml) in the root and the “docker” folder shows that containerized deployment is supported.
- Additional directories targeting testing (tests/Unit and tests/Feature) are also present, ensuring the system is well tested.

##### Key Components & Their Interactions
a. Web Server and Frontend:
- The “public” folder represents the web entry point, with static assets (CSS, JavaScript) and HTML views (rendered by Laravel’s Blade templates in “resources/views”).
- Routes (routes/web.php) serve user-facing pages, while routes/api.php expose endpoints for integration.
b. Backend Application Layer:
- Controllers (in app/Http/Controllers) handle HTTP requests.
- Business logic is further separated into helpers (app/Helpers) and models (app/Models).
- Modules like Filament (app/Filament/) power the admin panel, and the commands in app/Console/Commands are used for maintenance and background tasks.
c. Database & Persistence:
- Database migrations and seeders set up the schema for entities such as products, stores, categories, users, and price histories.
- The configuration files in “config/database.php” and related settings configure how Laravel connects with MySQL or SQLite.
d. Background Processes & Notifications:
- Jobs (e.g., CrawlProductJob) handle asynchronous processing for crawling product prices.
- Notification channels (e.g., Apprise, Ntfy, and potential Telegram integration noted in the README) manage push notifications when discounts occur.
e. External Integrations:
- The helpers under “app/Helpers/StoresAvailable” indicate integrations with multiple shopping platforms (e.g., Amazon, Ajio, Flipkart) using tailored classes.

##### Architectural Patterns and Technologies
- MVC Pattern: Controllers, Models, and Views are clearly separated.
- Service Layer and Helpers: Business logic – especially for price tracking and integration with external stores – is modularized in helper classes.
- Admin Panel: The use of Filament indicates a dedicated panel for managing resources.
- Containerization: Docker files along with CI/CD GitHub workflows show modern deployment practices.
- API Design: With dedicated API controllers and resource classes (under “app/Http/Resources/Api”), the system supports external API access.

## Diagram (Mermaid)

```mermaid
flowchart TD
    UI("User Interface (Frontend)"):::frontend
    WS("Web Server & API Routing"):::webserver
    BE("Laravel Backend"):::backend
    AD("Admin Panel (Filament)"):::admin
    DB("Database & Persistence"):::database
    JN("Background Jobs & Notifications"):::jobs
    EX("External Integrations (Stores)"):::external
    CT("Containerization & Deployment"):::container

    UI -->|"HTTPRequest"| WS
    WS -->|"RoutesRequest"| BE
    BE -->|"AdminAccess"| AD
    BE -->|"CRUD"| DB
    DB -->|"DataSync"| BE
    BE -->|"TriggersJobs"| JN
    JN -->|"Notifies"| EX
    CT -->|"Deploys"| WS
    CT -->|"Deploys"| BE

    click UI "https://github.com/cybrarist/discount-bandit/blob/master/public/index.php"
    click UI "https://github.com/cybrarist/discount-bandit/tree/master/resources/views"
    click UI "https://github.com/cybrarist/discount-bandit/blob/master/routes/web.php"

    click WS "https://github.com/cybrarist/discount-bandit/blob/master/routes/web.php"
    click WS "https://github.com/cybrarist/discount-bandit/blob/master/routes/api.php"

    click BE "https://github.com/cybrarist/discount-bandit/tree/master/app/Http/Controllers"
    click BE "https://github.com/cybrarist/discount-bandit/tree/master/app/Models"
    click BE "https://github.com/cybrarist/discount-bandit/tree/master/app/Helpers"

    click AD "https://github.com/cybrarist/discount-bandit/tree/master/app/Filament"
    click AD "https://github.com/cybrarist/discount-bandit/blob/master/app/Providers/Filament/AdminPanelProvider.php"

    click DB "https://github.com/cybrarist/discount-bandit/tree/master/database/migrations"
    click DB "https://github.com/cybrarist/discount-bandit/tree/master/database/seeders"
    click DB "https://github.com/cybrarist/discount-bandit/blob/master/config/database.php"

    click JN "https://github.com/cybrarist/discount-bandit/tree/master/app/Jobs"
    click JN "https://github.com/cybrarist/discount-bandit/tree/master/app/Notifications"
    click JN "https://github.com/cybrarist/discount-bandit/tree/master/app/NotificationsChannels"

    click EX "https://github.com/cybrarist/discount-bandit/tree/master/app/Helpers/StoresAvailable"

    click CT "https://github.com/cybrarist/discount-bandit/tree/master/Dockerfile"
    click CT "https://github.com/cybrarist/discount-bandit/blob/master/docker-compose.yaml"
    click CT "https://github.com/cybrarist/discount-bandit/tree/master/docker/"

    classDef frontend fill:#a6cee3,stroke:#000,stroke-width:2px;
    classDef webserver fill:#1f78b4,stroke:#000,stroke-width:2px;
    classDef backend fill:#b2df8a,stroke:#000,stroke-width:2px;
    classDef admin fill:#fb9a99,stroke:#000,stroke-width:2px;
    classDef database fill:#fdbf6f,stroke:#000,stroke-width:2px;
    classDef jobs fill:#cab2d6,stroke:#000,stroke-width:2px;
    classDef external fill:#ffff99,stroke:#000,stroke-width:2px;
    classDef container fill:#fdd0a2,stroke:#000,stroke-width:2px;
```
