https://github.com/pyrex41/tr_project
https://github.com/pyrex41/tr_project
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pyrex41/tr_project
- Owner: pyrex41
- Created: 2025-11-14T17:02:47.000Z (7 months ago)
- Default Branch: frontend
- Last Pushed: 2025-11-14T18:13:13.000Z (7 months ago)
- Last Synced: 2025-11-14T19:23:17.553Z (7 months ago)
- Language: Python
- Size: 3.78 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Legal Document Analysis - Frontend
A modern, type-safe Elm frontend for analyzing legal documents with AI-powered insights.
## ๐ Features
### **Dashboard**
- Real-time statistics (Total Orders, Experts, Exclusion Rate, Citations, Word Count, Daubert Analysis)
- AI-discovered insights with confidence scores
- Interactive charts (bar and pie charts using elm-charts)
- Quick search with keyword/semantic toggle
### **Search**
- Keyword and semantic search modes
- Real-time results with relevance scoring
- Rich result cards with metadata, expert names, and insights
- Click-through navigation to order details
### **Order Detail**
- **Overview Tab**: Case summary, ruling type, expert field, methodologies, exclusion grounds
- **Analysis Tab**: Key findings, strategic implications, citation context
- **Full Text Tab**: Complete document text with readable formatting
- **Citations Tab**: All citations with type and context
- **Quotes Tab**: Notable quotes with copy functionality
## ๐ ๏ธ Tech Stack
- **Elm 0.19.1** - Type-safe functional language for robust UIs
- **Vite 7.2.2** - Lightning-fast build tool and dev server
- **Tailwind CSS** - Utility-first CSS via CDN
- **elm-charts 5.0.0** - SVG-based charts
- **elm-json-decode-pipeline** - Elegant JSON decoding
## ๐ฆ Project Structure
```
frontend/
โโโ src/
โ โโโ Main.elm # Application entry point, routing
โ โโโ Types.elm # Shared types and JSON decoders
โ โโโ Api.elm # Backend API integration
โ โโโ Components/ # Reusable UI components
โ โ โโโ Layout.elm
โ โ โโโ SearchBar.elm
โ โ โโโ StatCard.elm
โ โ โโโ OrderCard.elm
โ โ โโโ QuoteCard.elm
โ โ โโโ Chart.elm
โ โ โโโ Modal.elm
โ โโโ Pages/ # Feature pages
โ โโโ Dashboard.elm
โ โโโ Search.elm
โ โโโ OrderDetail.elm
โโโ index.html # HTML entry point
โโโ vite.config.js # Vite configuration
โโโ elm.json # Elm dependencies
โโโ package.json # Node dependencies
```
## ๐ Getting Started
### Prerequisites
- Node.js 18+ and npm
- Elm 0.19.1 (`npm install -g elm`)
### Installation
```bash
# Install dependencies
npm install
# Start development server
npm run dev
```
The app will be available at `http://localhost:5173`
### Building for Production
```bash
# Create optimized production build
npm run build
# Preview production build
npm run preview
```
## ๐ Backend Integration
The frontend expects a backend API at `http://localhost:8000` with the following endpoints:
- `GET /api/stats` - Dashboard statistics
- `GET /api/insights` - AI-discovered insights
- `POST /api/search/keyword` - Keyword search
- `POST /api/search/semantic` - Semantic search
- `GET /api/orders` - Paginated order list
- `GET /api/orders/:id` - Order details
API configuration can be set via the `VITE_API_BASE_URL` environment variable.
## ๐ Build Stats
- **Bundle Size**: 116.08 KB (37.17 KB gzipped)
- **Build Time**: ~500ms
- **Zero console errors**
- **100% type-safe** - All data validated through Elm's type system
## ๐จ Styling
The application uses Tailwind CSS via CDN for rapid development with a professional Westlaw-inspired color scheme:
- **Primary**: Blue-900 (#1e3a8a)
- **Secondary**: Blue-800 (#1e40af)
- **Accent**: Blue-500 (#3b82f6)
Responsive breakpoints:
- Mobile: < 768px
- Desktop: >= 768px
## ๐งช Type Safety
All API responses are decoded through Elm's type system:
- JSON decoders ensure runtime safety
- Compiler catches type mismatches at build time
- RemoteData pattern for loading states
- Exhaustive pattern matching prevents bugs
## ๐ฆ Routing
- `/` - Dashboard
- `/search` - Search page
- `/order/:id` - Order detail page
## ๐ Development Notes
- **Hot Module Replacement**: Full HMR support via Vite
- **Type Errors**: Elm compiler provides helpful error messages
- **No Runtime Exceptions**: Elm guarantees no runtime errors
- **Immutable State**: All state updates are pure functions
## ๐ฎ Future Enhancements
- Pagination for search results
- Advanced filters (date range, expert field, ruling type)
- Export functionality (PDF, CSV)
- Saved searches and bookmarks
- Real-time clipboard support for quotes
- Accessibility improvements (ARIA labels, keyboard navigation)
- Unit tests with elm-test
- E2E tests with Cypress
## ๐ License
Part of the TR Project legal document analysis system.