Skip to content

antstackio/Stocksuggestor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ˆ Premarket Stock Suggester

A modern, AI-powered web application that displays premarket stock suggestions based on news sentiment analysis. Built with Next.js, TypeScript, and shadcn/ui.

โœจ Features

  • Real-time Stock Analysis: Displays bullish and bearish stock signals based on news sentiment
  • High Priority Watchlist: Sortable table showing stocks with highest priority and bias scores
  • Market Overview Dashboard: Key statistics about news coverage and stock signals
  • Responsive Design: Fully responsive UI that works on all devices
  • Dark Mode Ready: Built-in dark mode support with smooth transitions
  • Auto-refresh: Automatically fetches new data every 5 minutes
  • Clean UI: Trading-dashboard aesthetic with intuitive color coding

๐Ÿš€ Tech Stack

  • Framework: Next.js 15 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • UI Components: shadcn/ui
  • Data Fetching: TanStack React Query
  • HTTP Client: Axios
  • Date Formatting: date-fns
  • Icons: Lucide React

๐Ÿ“ฆ Installation

  1. Clone the repository:
git clone <your-repo-url>
cd StockSuggestor
  1. Install dependencies:
npm install
  1. Configure environment variables:

The API endpoint is already configured in .env.local:

NEXT_PUBLIC_API_URL=https://hwkhkt7ao8.execute-api.us-east-1.amazonaws.com/dev

You can update this to point to a different API endpoint if needed.

๐Ÿƒ Running the Application

Development Mode

npm run dev

Open http://localhost:3000 in your browser.

Production Build

npm run build
npm start

Linting

npm run lint

๐Ÿ“Š API Integration

The application fetches data from the /watchlist endpoint. The API returns data in the following format:

{
  "statusCode": 200,
  "headers": {
    "Content-Type": "application/json",
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Allow-Headers": "Content-Type",
    "Access-Control-Allow-Methods": "GET, POST, OPTIONS"
  },
  "body": {
    "success": true,
    "data": {
      "watchlist": [
        {
          "stock_symbol": "RELIANCE",
          "direction": "BULLISH" | "BEARISH",
          "priority": "HIGH" | "MEDIUM",
          "bias_score": 3.5,
          "reason": "Strong earnings report and positive market sentiment",
          "news_count": 15,
          "sector": "Finance",
          "latest_news_datetime": "2024-01-18T09:30:00",
          "date": "2024-01-18"
        }
      ],
      "bullish_stocks": [...],
      "bearish_stocks": [...]
    },
    "metadata": {
      "generated_at": "2024-01-18T09:30:00",
      "total_news_fetched": 150,
      "total_analyzed": 145,
      "bullish_count": 25,
      "bearish_count": 18,
      "watchlist_size": 10
    }
  }
}

The application automatically normalizes the API response data to a UI-friendly format.

๐ŸŽจ Components

Core Components

  • StatsCard: Displays key metrics with icons and trends
  • StockTable: Sortable table for watchlist stocks
  • StockCard: Individual stock card with expandable analysis
  • PriorityBadge: Visual indicator for stock priority
  • DirectionBadge: Bullish/Bearish indicator with icons
  • BiasScoreIndicator: Color-coded bias score display
  • LoadingSkeleton: Loading state UI
  • ErrorState: Error handling with retry functionality
  • EmptyState: Empty data state messaging

Component Features

  • Auto-sorting: Watchlist sorted by priority (HIGH โ†’ MEDIUM) then bias score
  • Truncation: Long reasons truncated with "Read more" accordion
  • Time Formatting: Automatic date/time formatting to IST
  • Visual Signals: Green for bullish, red for bearish
  • High Conviction Badge: Shown when bullish bias_score > 3
  • High Risk Badge: Shown for HIGH priority bearish stocks

๐ŸŽฏ Project Structure

StockSuggestor/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ layout.tsx          # Root layout with providers
โ”‚   โ”œโ”€โ”€ page.tsx            # Main dashboard page
โ”‚   โ””โ”€โ”€ globals.css         # Global styles and themes
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ providers/
โ”‚   โ”‚   โ””โ”€โ”€ query-provider.tsx
โ”‚   โ””โ”€โ”€ ui/
โ”‚       โ”œโ”€โ”€ badge.tsx
โ”‚       โ”œโ”€โ”€ bias-score-indicator.tsx
โ”‚       โ”œโ”€โ”€ button.tsx
โ”‚       โ”œโ”€โ”€ card.tsx
โ”‚       โ”œโ”€โ”€ direction-badge.tsx
โ”‚       โ”œโ”€โ”€ empty-state.tsx
โ”‚       โ”œโ”€โ”€ error-state.tsx
โ”‚       โ”œโ”€โ”€ loading-skeleton.tsx
โ”‚       โ”œโ”€โ”€ priority-badge.tsx
โ”‚       โ”œโ”€โ”€ stats-card.tsx
โ”‚       โ”œโ”€โ”€ stock-card.tsx
โ”‚       โ””โ”€โ”€ stock-table.tsx
โ”œโ”€โ”€ hooks/
โ”‚   โ””โ”€โ”€ usePremarketData.ts  # React Query hook
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ api.ts               # API client
โ”‚   โ””โ”€โ”€ utils.ts             # Utility functions
โ”œโ”€โ”€ types/
โ”‚   โ””โ”€โ”€ api.ts               # TypeScript types
โ””โ”€โ”€ .env.local               # Environment variables

๐Ÿ”ง Configuration

React Query Settings

The application uses the following React Query configuration:

  • Refetch Interval: 5 minutes
  • Retry Attempts: 1
  • Stale Time: 5 minutes
  • GC Time: 10 minutes

Modify these settings in hooks/usePremarketData.ts.

API Endpoint

Update the API base URL in .env.local:

NEXT_PUBLIC_API_URL=https://your-api-domain.com

๐ŸŒ™ Dark Mode

The application supports dark mode out of the box. Users can toggle dark mode using their system preferences. All components are styled with dark mode variants.

๐Ÿ“ฑ Responsive Design

The application is fully responsive with breakpoints:

  • Mobile: Single column layout
  • Tablet (md): 2-column grid for cards
  • Desktop (lg): 3-4 column grid for cards

โšก Performance

  • Lighthouse Score: Target > 90
  • First Contentful Paint: < 2s
  • Bundle Optimization: Tree-shaking and code splitting
  • Image Optimization: Next.js automatic image optimization

๐Ÿ”ฎ Future Enhancements

  • Sector filtering
  • Auto-refresh toggle control
  • Historical date selector
  • TradingView chart embeds
  • Saved watchlists
  • Telegram/WhatsApp alerts
  • User authentication
  • Custom notifications

๐Ÿ“„ License

This project is licensed under the MIT License.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ› Issues

If you encounter any issues, please create an issue on GitHub.


Built with โค๏ธ using Next.js and shadcn/ui

Releases

No releases published

Packages

No packages published