A real-time astronaut tracking dashboard showing current crew members aboard spacecraft, built with React, TypeScript, and Vite.
- Real-time Astronaut Data: Track current astronauts in space from multiple sources
- Smart Caching System: Two-tier caching with server-side proxy and browser cache
- Image Optimization: Cached astronaut images with automatic proxy and CDN-style serving
- High Performance: Sub-second load times with intelligent data fetching
- Beautiful UI: Space-themed interface with smooth animations
┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ Client │────▶│ Server │────▶│External APIs│
│ (React) │◀────│ (Fastify) │◀────│(Open Notify)│
└─────────────┘ └──────────────┘ └─────────────┘
│
▼
┌──────────────┐
│Cache Storage │
│- Memory Cache│
│- Disk Images │
└──────────────┘
# Install dependencies for both frontend and server
npm run install:all
# Start both frontend and server in development
npm run dev:all
# Or run separately:
npm run dev # Frontend only (port 5173)
npm run dev:server # Server only (port 4108)- Node.js 18+
- npm 9+
- Clone the repository
- Install dependencies:
npm run install:all - Start development:
npm run dev:all
The application will be available at:
- Frontend: http://localhost:5173
- API Server: http://localhost:4108
- Health Check: http://localhost:4108/api/health
# Development
npm run dev # Start frontend dev server
npm run dev:server # Start backend server
npm run dev:all # Start both concurrently
# Building
npm run build # Build frontend for production
npm run build:server # Build server for production
npm run build:all # Build everything
# Other
npm run lint # Run ESLint
npm run preview # Preview production build
npm run cache:clear # Clear client-side cacheGET /api/astronauts- Get all astronauts (cached)DELETE /api/astronauts/cache- Clear astronaut cacheGET /api/astronauts/cache/stats- Cache statistics
GET /api/images/proxy?url=<url>- Proxy and cache external imageGET /api/images/:hash- Get cached image by hashDELETE /api/images/cache- Clear image cacheGET /api/images/cache/stats- Image cache statistics
GET /api/health- Comprehensive health checkGET /api/health/ready- Readiness probeGET /api/health/live- Liveness probe
-
Server-Side Caching
- Astronaut data: 6-hour TTL with stale-while-revalidate
- Images: 24-hour TTL with permanent disk storage
- Automatic cache warming and background updates
-
Client-Side Caching
- Browser cache headers for optimal performance
- Service worker ready for offline support
- LocalStorage for persistent asset URLs
Create a .env file in the server directory:
# Server Configuration
PORT=4108
HOST=0.0.0.0
# Cache Configuration
CACHE_TTL_ASTRONAUTS=21600000 # 6 hours in ms
CACHE_TTL_IMAGES=86400000 # 24 hours in ms
CACHE_CHECK_PERIOD=600 # 10 minutes in seconds
# External APIs
OPEN_NOTIFY_API=http://api.open-notify.org/astros.json
LAUNCH_LIBRARY_API=https://ll.thespacedevs.com/2.2.0/astronaut/
# Development
NODE_ENV=development
LOG_LEVEL=infonpm run build:allThis creates:
dist/- Frontend production buildserver/dist/- Server production build
- Frontend: Deploy to CDN (Cloudflare Pages, Vercel, Netlify)
- Server: Deploy to Node.js hosting (Railway, Render, Fly.io)
- Database: Consider Redis for distributed caching
- Monitoring: Add application monitoring (Sentry, DataDog)
When ready to scale:
- Replace in-memory cache with Redis
- Use CDN for image serving
- Add horizontal scaling with load balancer
- Implement edge caching with Cloudflare Workers
- React 19 - UI framework
- TypeScript - Type safety
- Vite - Build tool and dev server
- CSS Modules - Scoped styling
- Fastify - High-performance Node.js server
- node-cache - In-memory caching
- got - HTTP client for external APIs
- TypeScript - Type safety