Astralis is a Go-based REST API and CLI application that provides information about upcoming astronomical events such as meteor showers, eclipses, and other celestial phenomena.
- REST API for querying astronomical events
- Filter events by date range and type
- CLI application with ASCII art visualization
- Hexagonal architecture for easy extension and maintenance
- Multiple data sources:
- NASA DONKI API for solar events
- Visible Planets API for planetary positions and visibility
- Comprehensive test suite
- Go 1.16 or later
- Environment variables for API configuration:
NASA_API_KEY: API key for NASA APIs (get one at https://api.nasa.gov/)PORT: Port for the REST API server (default: 8080)
-
Clone the repository:
git clone https://github.com/alandavd/astralis.git cd astralis -
Install dependencies:
go mod tidy
The project includes a comprehensive test suite covering domain models, service layer, and API handlers.
Run all tests:
go test ./...Run tests with coverage report:
go test -cover ./...Generate detailed coverage report:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out-
Set the required environment variables:
export NASA_API_KEY="your-nasa-api-key" export PORT="8080"
-
Start the server:
go run cmd/api/main.go
go run cmd/api/main.go -api_port=:8081
The CLI client provides a text-based interface with ASCII art visualization of astronomical events.
go run cmd/cli/main.go --api http://localhost:8080-
GET /events: Get all upcoming events- Query parameters:
start: Start date (RFC3339 format)end: End date (RFC3339 format)
- Query parameters:
-
GET /events/{id}: Get a specific event by ID -
GET /events/type/{type}: Get events by type- Supported types:
- METEOR_SHOWER
- ECLIPSE
- CONJUNCTION
- TRANSIT
- OTHER
- Supported types:
- Provides solar events data (CMEs, solar flares)
- Free API key required (get one at https://api.nasa.gov/)
- Updates daily
- Provides planetary visibility and position data
- No API key required
- Real-time calculations
The application follows hexagonal architecture principles:
internal/core/domain: Domain entities and business logicinternal/core/ports: Interface definitionsinternal/core/service: Business logic implementationinternal/adapters/primary: Input adapters (REST API, CLI)internal/adapters/secondary: Output adapters (NASA API, Visible Planets API)
The test suite follows these principles:
- Domain Tests: Verify the core business logic and domain model behavior
- Service Tests: Ensure the service layer correctly orchestrates repositories
- Handler Tests: Validate HTTP endpoints and request/response handling
- Mock Objects: Use mock implementations for external dependencies
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.