Skip to content

Latest commit

Β 

History

History
150 lines (122 loc) Β· 4.42 KB

File metadata and controls

150 lines (122 loc) Β· 4.42 KB

TradeGuardAI - Trade Disruption Monitoring Platform

A full-stack monorepo for monitoring global trade disruptions and supply chain risks in real-time.

πŸ“ Project Structure

tradeguard-ai/
β”œβ”€β”€ apps/
β”‚   └── web/                 # Next.js frontend application
β”‚       β”œβ”€β”€ app/             # Next.js 13+ app directory (routes)
β”‚       β”œβ”€β”€ public/          # Static assets
β”‚       β”œβ”€β”€ styles/          # Global styles
β”‚       └── package.json     # Web app dependencies
β”‚
β”œβ”€β”€ services/
β”‚   └── api/                 # FastAPI backend service
β”‚       β”œβ”€β”€ routes/          # API route handlers
β”‚       β”œβ”€β”€ main.py          # FastAPI app entry point
β”‚       β”œβ”€β”€ database.py      # Database configuration
β”‚       β”œβ”€β”€ models.py        # SQLAlchemy models
β”‚       β”œβ”€β”€ seed_data.py     # Mock data generator
β”‚       └── requirements.txt # Python dependencies
β”‚
β”œβ”€β”€ packages/                # Shared packages (monorepo)
β”‚   β”œβ”€β”€ ui/                  # React UI components library
β”‚   β”‚   β”œβ”€β”€ ui/              # Base shadcn/ui components
β”‚   β”‚   └── *.tsx            # Custom business components
β”‚   β”œβ”€β”€ hooks/               # Shared React hooks
β”‚   β”‚   β”œβ”€β”€ use-auth.ts
β”‚   β”‚   β”œβ”€β”€ use-websocket.ts
β”‚   β”‚   └── use-toast.ts
β”‚   └── lib/                 # Shared utilities
β”‚       └── utils.ts         # Helper functions (cn, etc.)
β”‚
β”œβ”€β”€ infra/                   # Infrastructure & DevOps
β”‚   β”œβ”€β”€ docker-compose.yml   # Local development setup
β”‚   β”œβ”€β”€ Dockerfile.prod      # Production Docker image
β”‚   └── nginx.conf           # Nginx reverse proxy config
β”‚
β”œβ”€β”€ .github/
β”‚   └── workflows/           # CI/CD pipelines
β”‚
β”œβ”€β”€ pnpm-workspace.yaml      # PNPM workspace configuration
β”œβ”€β”€ .gitattributes           # Git line ending normalization
β”œβ”€β”€ .editorconfig            # Editor consistency settings
└── README.md                # This file

πŸ—οΈ Architecture

Monorepo Structure (managed by PNPM workspaces):

TradeGuardAI/
β”œβ”€β”€ apps/
β”‚   └── web/              # Next.js 16 frontend (React 19, Tailwind CSS 4)
β”œβ”€β”€ services/
β”‚   └── api/              # FastAPI backend (Python 3.11+, SQLite)
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ ui/               # Shared React components (shadcn/ui)
β”‚   β”œβ”€β”€ hooks/            # Shared React hooks
β”‚   └── lib/              # Shared utilities
└── infra/                # Docker & deployment configs

Tech Stack:

  • Frontend: Next.js 16, TypeScript, Tailwind CSS 4, Radix UI, Recharts
  • Backend: FastAPI, SQLAlchemy, Uvicorn
  • Infrastructure: Docker, GitHub Actions

πŸ“‹ Features

Dashboard:

  • 🌍 Real-time event feed with risk map
  • πŸ“Š 30-day risk forecasts for SKUs
  • πŸ”” Event notifications
  • πŸ“ˆ Multi-SKU analytics

Analytics:

  • πŸ“‰ Risk trend analysis
  • 🎯 Sentiment analysis
  • πŸ“‘ Custom report builder
  • πŸ” Advanced filtering

Data:

  • 10 mock trade disruption events
  • 5 SKUs with risk profiles
  • Real-time WebSocket updates

⚑ Quick Start

Prerequisites

  • Node.js 18+ & pnpm 8+
  • Python 3.11+
  • Docker (optional)

πŸš€ Local Development (5 minutes)

# 1. Install frontend dependencies
pnpm install

# 2. Initialize database (Terminal 1)
cd services/api
python seed_data.py

# 3. Start backend (keep Terminal 1 running)
python -m uvicorn main:app --reload
# β†’ http://127.0.0.1:8000

# 4. Start frontend (Terminal 2)
cd ../..
pnpm dev
# β†’ http://localhost:3000

🐳 Docker (Alternative)

cd infra
docker-compose up
# Frontend: http://localhost:3000
# Backend: http://localhost:8000

That's it! Visit http://localhost:3000 to see the dashboard.


πŸ“‘ API Endpoints

Base URL: http://localhost:8000

GET  /api/health                    # Health check
GET  /api/events                    # List events (limit: 10)
GET  /api/events/{id}               # Event details
GET  /api/sku                       # List SKUs (sorted by risk)
GET  /api/sku/{id}                  # SKU details
GET  /api/forecast/{sku_id}         # 30-day risk forecast
GET  /api/analytics/gtri            # Global Trade Risk Index
GET  /docs                          # Interactive API docs

οΏ½ License

MIT License - See LICENSE for details.