Loading...
Loading...
Avg 12.6 stars per repo.
24 day streak.
Coding for 17 years.
A comprehensive two-part system for tracking shipments to your home, built with Go and SQLite using minimal dependencies and test-driven development.
Part 1: Core Tracking System β COMPLETE
Part 2: AI Email Processor π§ PLANNED
# Clone the repository
git clone git@github.com:jhjaggars/package-tracking.git
cd package-tracking
# Run the server (creates database.db automatically)
go run cmd/server/main.go
# Server starts on http://localhost:8080
# Health check
curl http://localhost:8080/api/health
# List carriers
curl http://localhost:8080/api/carriers
# Create a shipment (works immediately - no API keys required for any carrier!)
curl -X POST http://localhost:8080/api/shipments \
-H "Content-Type: application/json" \
-d '{"tracking_number":"1Z999AA1234567890","carrier":"ups","description":"Test Package"}'
# Create a USPS shipment (also works without setup)
curl -X POST http://localhost:8080/api/shipments \
-H "Content-Type: application/json" \
-d '{"tracking_number":"9400111899562347123456","carrier":"usps","description":"Priority Mail"}'
# Create a FedEx shipment (zero configuration required)
curl -X POST http://localhost:8080/api/shipments \
-H "Content-Type: application/json" \
-d '{"tracking_number":"123456789012","carrier":"fedex","description":"FedEx Express"}'
# Create a DHL shipment (zero configuration required)
curl -X POST http://localhost:8080/api/shipments \
-H "Content-Type: application/json" \
-d '{"tracking_number":"1234567890","carrier":"dhl","description":"DHL Express"}'
# List shipments
curl http://localhost:8080/api/shipments
Here's a step-by-step example showing how to add a tracking number and retrieve its details:
# 1. Add a UPS package to the system (works immediately - no setup required!)
curl -X POST http://localhost:8080/api/shipments \
-H "Content-Type: application/json" \
-d '{"tracking_number":"1Z999AA1234567890","carrier":"ups","description":"Test Package"}'
# Response will include the shipment ID, e.g.:
# {"id":1,"tracking_number":"1Z999AA1234567890","carrier":"ups","description":"Test Package",...}
# 2. Get shipment details by ID (replace '1' with the actual ID from step 1)
curl http://localhost:8080/api/shipments/1
# 3. Get tracking events for the shipment (shows real tracking data from carrier)
curl http://localhost:8080/api/shipments/1/events
# 4. Update the shipment description if needed
curl -X PUT http://localhost:8080/api/shipments/1 \
-H "Content-Type: application/json" \
-d '{"description":"Updated Package Description"}'
# 5. List all shipments to see your packages
curl http://localhost:8080/api/shipments
# 6. Delete a shipment when no longer needed
curl -X DELETE http://localhost:8080/api/shipments/1
Note: The system will automatically attempt to fetch real tracking data from the carrier when you create a shipment or request tracking events. This works immediately without any API configuration thanks to the web scraping fallback system.
package-tracking/
βββ cmd/server/main.go # Application entry point
βββ internal/
β βββ config/ # Configuration management
β βββ database/ # Database models and operations
β βββ handlers/ # HTTP request handlers
β βββ carriers/ # Carrier API clients (USPS, UPS, FedEx, DHL)
β βββ server/ # Router, middleware, and server logic
βββ go.mod # Go module definition
βββ database.db # SQLite database (auto-created)
type Shipment struct {
ID int `json:"id"`
TrackingNumber string `json:"tracking_number"`
Carrier string `json:"carrier"`
Description string `json:"description"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ExpectedDelivery *time.Time `json:"expected_delivery,omitempty"`
IsDelivered bool `json:"is_delivered"`
}
type TrackingEvent struct {
ID int `json:"id"`
ShipmentID int `json:"shipment_id"`
Timestamp time.Time `json:"timestamp"`
Location string `json:"location"`
Status string `json:"status"`
Description string `json:"description"`
CreatedAt time.Time `json:"created_at"`
}
GET /api/shipments - List all shipmentsPOST /api/shipments - Create new shipmentGET /api/shipments/{id} - Get shipment by IDPUT /api/shipments/{id} - Update shipmentDELETE /api/shipments/{id} - Delete shipmentGET /api/shipments/{id}/events - Get tracking events for shipmentGET /api/health - Health check with database connectivityGET /api/carriers - List supported carriersGET /api/carriers?active=true - List only active carriersEnvironment variables with sensible defaults:
# Server configuration
SERVER_HOST=localhost # Server host
SERVER_PORT=8080 # Server port
DB_PATH=./database.db # SQLite database path
# Feature configuration
UPDATE_INTERVAL=1h # Background update interval
LOG_LEVEL=info # Logging level (debug, info, warn, error)
# Carrier API keys (optional - system works without them!)
USPS_API_KEY=your_key # Falls back to web scraping if not provided
UPS_API_KEY=your_key # Falls back to web scraping if not provided
FEDEX_API_KEY=your_key # Falls back to web scraping if not provided
DHL_API_KEY=your_key # Falls back to web scraping if not provided
Note: All carriers (USPS, UPS, FedEx, DHL) work immediately without any configuration! The system automatically falls back to web scraping when API keys are not configured, providing 100% zero-configuration tracking coverage.
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run integration tests only
go test ./internal/server -run TestIntegration
# Test script with full API workflow
./test_server.sh
# Signal handling demonstration
./test_signal_comprehensive.sh
The server handles shutdown signals gracefully:
# Graceful shutdown
kill -TERM <pid>
# Force shutdown (not recommended)
kill -9 <pid>
Database Layer
HTTP Layer
/api/shipments/{id})Server Infrastructure
Testing & Quality
Deployment
Carrier API Integration β COMPLETE
Web Scraping Integration β COMPLETE (4/4 carriers)
Phase 2: Complete Alternative Tracking Methods β COMPLETE
Phase 3: Background Services
Phase 4: Web Interface
html/templatePhase 5: AI Email Processing (Part 2)
This project follows test-driven development (TDD) principles:
# Run tests continuously during development
go test ./... -watch
# Check test coverage
go test -cover ./...
# Build and test the server
go build -o bin/server cmd/server/main.go
./bin/server
Built with Test-Driven Development using Go 1.21+ and SQLite
π€ This project was developed with Claude Code assistance
Contribution Graph
Activity Timeline
Commits and contributions grouped by day, week, or month.
Pushed to master at matburt/research-vault
February 3rd, 2026 1:18 AM
Pushed to master at matburt/research-vault
February 1st, 2026 4:29 AM