How anasanzari/bullz-and-bears works
Main Components
• Backend Server (Laravel):
• Controllers and API endpoints are located in app/Http/Controllers (including AdminController, ApiController, FinanceApiController, etc.).
• Console Commands (found in app/Console/Commands) handle scheduled tasks/cron jobs (like DayEndUpdate, DayStartUpdate, StockUpdate, etc.) to update stock prices and game data.
• Models (spread across app/*.php, e.g., Stock.php, BoughtStock.php, Transaction.php, etc.) represent business logic and data entities.
• Configuration for game settings is available in config/bullz.php.
• Frontend Application:
• HTML, JavaScript, and templates exist under resources/src (with separation between “admin” and “app” for different interfaces).
• CSS/SCSS assets for styling are found in resources/assets/sass and are compiled via Grunt tasks (see Gruntfile.js) and Node packages (npm install, bower install).
• The public folder serves as the entry point (public/index.php) for user requests.
• Database:
• The application uses a database with several core tables: stocks, bought stocks, short sell, schedules, and history (as highlighted in the README).
• Migrations and seeders in the database/ folder set up and initialize the data model.
• External Services and Tools:
• Grunt is used for serving and building the frontend.
• PHP Artisan commands manage migrations, seeds, and cron jobs.
• Third-party integrations such as Facebook App configuration (with production and test app IDs) are mentioned for social features.
• CSS frameworks like Materialize (with various SCSS files in both app and sass-cache folders) support the styling.
Relationships and Interactions
• The Frontend and Backend:
• The frontend (running on http://localhost:8080) communicates with the Laravel backend via API endpoints provided by controllers in app/Http.
• Database Interactions:
• Migration and seeding process that initializes database tables and sample data.
• Cron/Console Commands:
• A scheduled or background process component (in app/Console/Commands) that periodically updates the stocks table in the database.
• That these commands use PHP Artisan (e.g., php artisan update:initStocks, php artisan list for 'update' commands) and depend on PHP’s Curl extension for external requests.
• Asset Pipeline:
• Dependency chain where Node (npm, bower) and Grunt manage the asset compilation from SCSS to CSS and bundling JavaScript.
Architectural Patterns and Design Principles
• Use the MVC pattern for the Laravel backend (Models, Views, Controllers).
• Separation of concerns: distinct layers for handling business logic (Models/Console), API services (Controllers), and presentation (Frontend templates and JS controllers).
• Use of scheduled batch processing for live updating stocks (using cron jobs) which is a core design element.
• Use of modular design on the frontend where controllers, directives, filters, and services are separated into their own files, facilitating maintainability and scalability.
Relevant Technologies, Frameworks, and Libraries
• PHP (Laravel framework) for backend.
• JavaScript (likely AngularJS or similar framework, as seen in the structure of controllers/directives) for the frontend.
• Node.js ecosystem (npm, Grunt, Bower) for dependency management and asset compilation.
• Sass for CSS preprocessing with Materialize as a UI framework.
• Database (MySQL or a similar RDBMS) recommended by Laravel and migration files.