How gatiskevans/stock-trader works
Stock Trader is a Laravel application for browsing company market data and buying or selling stocks. The main workflow is a user request handled by stock controllers, which delegate trade rules and updates to services and repositories; repositories retrieve Finnhub data and persist portfolio and transaction state. README documents viewing, buying, and selling, and the source excerpts confirm the trade path. Event-driven mail and some route/view wiring are visible in the tree but not sampled, so those links are omitted or marked unverified.
Main entry points: FinnhubStocksRepository.php Stock repository · StocksController.php Stock controller · BuyStocksService.php Purchase service · SellStocksService.php Sale service
Components 20
Web and accounts
- Route registration
app/Providers/RouteServiceProvider.php - Stock controller
app/Http/Controllers/Stocks/StocksController.php - Funds controller
app/Http/Controllers/Funds/FundsController.php - Transactions controller
app/Http/Controllers/Transactions/TransactionsController.php - Session authentication
app/Http/Controllers/Auth/AuthenticatedSessionController.php - Stock and company views
resources/views/stocks/stock.blade.php - Funds view
resources/views/funds/show-funds.blade.php
Trading workflow
- Purchase service
app/Services/BuyStocksService.php - Sale service
app/Services/SellStocksService.php - Market hours
app/Services/MarketOpenService.php
Market data
- Stock repository
app/Repositories/StocksRepositories/FinnhubStocksRepository.php - Company profile data
app/Models/Companies/CompanyProfile.php - Quote data
app/Models/QuoteData.php
Persistence and notifications
- Transaction repository
app/Repositories/TransactionsRepositories/MySQLTransactionsRepository.php - Application database
app/Models/Transaction.php - Portfolio stock model
app/Models/Stock.php - Trade events
app/Events/StockPurchasedEvent.php - Trade email jobs
app/Jobs/PurchaseStock.php
Other components
- Trader
- Finnhub API
Connections 23
- Trader → Stock controller: requests trading
- Route registration → Stock controller: routes requests
- Stock controller → Purchase service: invokes purchase
app/Http/Controllers/Stocks/StocksController.php - Stock controller → Sale service: invokes sale
app/Http/Controllers/Stocks/StocksController.php - Stock controller → Stock repository: fetches market and holdings
app/Http/Controllers/Stocks/StocksController.php - Stock controller → Stock and company views: renders stock pages
app/Http/Controllers/Stocks/StocksController.php - Purchase service → Market hours: checks trading hours
app/Services/BuyStocksService.php - Sale service → Market hours: checks trading hours
app/Services/SellStocksService.php - Purchase service → Stock repository: reads and updates holdings
app/Services/BuyStocksService.php - Sale service → Stock repository: reads and updates holdings
app/Services/SellStocksService.php - Purchase service → Transaction repository: records purchase
app/Services/BuyStocksService.php - Sale service → Transaction repository: records sale
app/Services/SellStocksService.php - Stock repository → Finnhub API: requests company and quote data
app/Repositories/StocksRepositories/FinnhubStocksRepository.php - Stock repository → Company profile data: constructs profile
app/Repositories/StocksRepositories/FinnhubStocksRepository.php - Stock repository → Quote data: constructs quote
app/Repositories/StocksRepositories/FinnhubStocksRepository.php - Stock repository → Application database: queries portfolio records
app/Repositories/StocksRepositories/FinnhubStocksRepository.php - Transaction repository → Application database: persists transactions
app/Repositories/TransactionsRepositories/MySQLTransactionsRepository.php - Purchase service → Trade events: dispatches purchase event
app/Services/BuyStocksService.php - Sale service → Trade events: dispatches sale event
app/Services/SellStocksService.php - Trade events → Trade email jobs: queues trade email
- Trader → Session authentication: authenticates
app/Http/Controllers/Auth/AuthenticatedSessionController.php - Funds controller → Funds view: renders funds page
- Transactions controller → Transaction repository: loads transaction history