How astrolin/ephemeris-api works
Main Components
a. Clients
• Web or mobile applications (HTTP consumers)
• Command-line tools or curl (for testing/demo)
b. API Service Container
• Pedestal HTTP server (Jetty or Immutant adapter)
• Static asset handler (serves resources/public)
c. Application Core
• Routing and endpoints (src/ephemeris_api/server.clj, views.clj)
• Service layer (src/ephemeris_api/service.clj)
• Core logic (src/ephemeris_api/core.clj)
• Configuration loader (nomad via src/ephemeris_api/config.clj + resources/config.edn + env vars)
d. Ephemeris Library
• Third-party ephemeris code (astrolet/ephemeris)
e. Logging & Monitoring
• logback.xml (structured logs to console or file)
f. Build & Deployment Pipeline
• Leiningen (project.clj, dev/dev.clj)
• Dockerfiles & Heroku Procfile (containerization & PaaS)
• CI configs (Travis CI: .travis.yml, CircleCI: circle.yml)
Relationships & Data Flow
• Clients → HTTP(S) request → Pedestal routing layer
• Pedestal → invokes service functions → passes request data
• Service layer → calls core logic → core logic → ephemeris library
• Ephemeris library → computes positions → returns data to core
• Core → service layer → converts result to JSON via views → response
• Static file requests → Pedestal’s resource interceptor → serves index.html/css
• Throughout: configuration parameters injected from nomad/environ → influence port, host, API base path
• Logs emitted at each request/response boundary, written by logback
Architectural Patterns & Principles
• Microservice: self-contained HTTP API for a single responsibility (functional transformation)
• Stateless, single-purpose service; no database dependency
• Functional core (pure logic) separated from I/O layer (Pedestal)
• Configuration as code via nomad + environment overrides
• Containerizable: environment-agnostic, deployable to Docker, Heroku, OpenShift, etc.
Technologies & Frameworks
• Clojure (runtime, REPL-driven dev)
• Pedestal (HTTP framework) with Jetty/Immutant adapters
• Leiningen (build + REPL + uberjar)
• Nomad/environ (configuration management)
• Docker/Heroku/OpenShift manifests for deployment
• logback for logging
• CI: Travis, CircleCI
Essential Elements
– Component names and roles (Server, Router, Service Layer, Core Logic, Ephemeris Library)
– Environment variables pointing into config loader
– Deployment targets (Docker container pushed to Heroku, etc.)
– CI triggers and build artifacts (uberjar, Docker image)