Production-grade full-stack application for real-time Near-Earth Object monitoring and threat analysis
Every day, thousands of asteroids pass near Earth. Most go unnoticed—until one doesn't. Existing solutions were either:
- Basic data feeds with no analysis
- Overly complex scientific tools for researchers
- Missing real-time threat assessment
Asteroid Tracker bridges this gap: a production-ready platform that transforms raw NASA data into actionable insights, with real-time visualization, threat scoring, and community features.
This isn't a tutorial app. It's a production system handling:
- External API Integration — NASA NeoWs API with intelligent caching (1-hour TTL), exponential backoff retry logic, and rate-limit management (50-request daily buffer)
- Real-time Infrastructure — WebSocket connections for live notifications and community chat
- Authentication System — JWT access tokens (15min) + refresh tokens (7 days) with bcrypt password hashing
- Database Design — PostgreSQL with Prisma ORM, proper migrations, and type-safe queries
- State Management — Dual-layer architecture: Zustand for client state, TanStack Query v5 for server state with optimistic updates
Every choice was documented with trade-offs:
| Decision | Why It Matters |
|---|---|
| Bun over Node.js | 22% lower P99 latency on I/O-bound workloads |
| Prisma 7 over Drizzle | Robust migration tooling, type-safe queries |
| TanStack Query over SWR | Advanced cache invalidation, optimistic updates |
| React + Vite | Sub-second HMR, excellent TypeScript DX |
- Live NEO Feed — Browse asteroids approaching Earth in the next 7 days
- Advanced Filtering — Filter by date range, hazardous status, diameter, miss distance
- Search — Find asteroids by name or NASA ID
- Detailed Analysis — Velocity, closest approach distance, diameter, orbital data
- Real-time Statistics — Total count, hazardous percentage, fastest/largest asteroids
- Visual Charts — Hazard distribution pie chart, diameter histogram
- Threat Scoring — Proprietary algorithm calculating risk based on size, speed, proximity
- Authentication — Secure JWT-based auth with refresh token rotation
- Watchlist — Save favorite asteroids with personal notes
- Custom Alerts — Configure notification thresholds
- Interactive UI — Responsive design with TailwindCSS
- Animations — Smooth transitions with Framer Motion
┌─────────────────────────────────────────────────────────────┐
│ Frontend │
│ React 18 + Vite + TypeScript + TailwindCSS │
│ Zustand (client state) + TanStack Query v5 (server) │
└─────────────────────────────────────────────────────────────┘
│
│ REST + WebSocket
▼
┌─────────────────────────────────────────────────────────────┐
│ Backend │
│ Bun + Express 5 + Prisma 7 + PostgreSQL 16 │
│ JWT Auth + Pino Logging + Zod Validation │
└─────────────────────────────────────────────────────────────┘
│
│ Cached (1hr TTL)
▼
┌─────────────────────────────────────────────────────────────┐
│ NASA NeoWs API │
│ Near-Earth Object Web Service │
└─────────────────────────────────────────────────────────────┘
| Layer | Technology |
|---|---|
| Frontend | React 18, Vite 5, TypeScript 5.3 |
| Styling | TailwindCSS 3.4, Framer Motion |
| State | Zustand, TanStack Query v5 |
| Backend | Bun 1.3, Express 5, Prisma 7 |
| Database | PostgreSQL 16 |
| Auth | JWT, bcrypt |
| Validation | Zod |
| Real-time | Socket.IO |
# Backend
cd D:/Astra
bun install
# Frontend
cd D:/Astra-Frontend
npm install# Backend
cp D:/Astra/.env.example D:/Astra/.env
# Edit: DATABASE_URL, JWT_SECRET, JWT_REFRESH_SECRET, NASA_API_KEY
# Frontend
# Already configured to proxy to localhost:3000cd D:/Astra
bun run prisma:generate
bun run prisma:migrate# Terminal 1: Backend (port 3000)
cd D:/Astra
bun run dev
# Terminal 2: Frontend (port 5173)
cd D:/Astra-Frontend
npm run dev| Method | Endpoint | Description |
|---|---|---|
| GET | /api/asteroids/feed |
NEO feed for date range |
| GET | /api/asteroids/search |
Search by name/ID |
| GET | /api/asteroids/stats |
Dashboard statistics |
| GET | /api/asteroids/hazardous |
Hazardous asteroids only |
| GET | /api/asteroids/:nasaId |
Asteroid details |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Create account |
| POST | /api/auth/login |
Get JWT tokens |
| POST | /api/auth/refresh |
Rotate tokens |
| GET | /api/saved-asteroids |
User favorites |
| POST | /api/saved-asteroids |
Save asteroid |
| DELETE | /api/saved-asteroids/:nasaId |
Remove favorite |
| Metric | Value |
|---|---|
| API Response (P50) | < 50ms |
| API Response (P99) | < 200ms |
| Cache TTL | 1 hour |
| Rate Limit Buffer | 50 req/day |
# Full stack with PostgreSQL
cd D:/Astra
docker-compose up -d# Backend
bun run build
NODE_ENV=production bun run src/index.ts
# Frontend
cd D:/Astra-Frontend
npm run build
# Serve dist/ with nginx or VercelD:/Astra (Backend) D:/Astra-Frontend (Frontend)
├── src/ ├── src/
│ ├── controllers/ │ ├── api/
│ ├── services/ │ ├── components/
│ ├── routes/ │ ├── pages/
│ ├── middleware/ │ ├── store/
│ ├── validators/ │ ├── hooks/
│ └── utils/ │ └── types/
├── prisma/ ├── docs/
│ └── migrations/ │ └── adr/
└── docs/ └── ARCHITECTURE.md
└── adr/
Request → Check Cache → Hit? → Return
│
No
▼
Fetch NASA API
│
▼
Store in Cache (1hr TTL)
│
▼
Return to Client
Login → Verify Password → Generate JWT (15min) + Refresh (7 days)
│
┌───────────────────┘
▼
Store Refresh Token (HTTP-only cookie)
│
Access Token Expired?
│
Yes ───────► Refresh Endpoint → New JWT
│
No ────────► Validate & Continue
MIT License - see LICENSE for details.
Ashutosh Dash — GitHub
Built with precision and curiosity.