Skip to content

calin-tesu/AstroCalc-Libra

Repository files navigation

AstroCalc-Libra: Offline Ephemeris Calculator

A modern Android application built with Kotlin and Jetpack Compose for performing high-precision astrological calculations offline using the Swiss Ephemeris library.

🌟 Key Features

Offline Calculations: Uses the included Swiss Ephemeris data files (.se1) and the .jar library for all astronomical calculations, ensuring no network connectivity is required for core functionality.

Data Persistence: Utilizes a local Room database for saving user-defined birth profiles (ChartProfileEntity).

Modern UI: Built entirely using Jetpack Compose for a reactive and declarative user interface.

Dependency Injection: Implements Hilt for dependency management across all architectural layers.

🛠️ Project Setup & Environment

Prerequisites

Android Studio Giraffe or newer

Gradle 8.0+

Kotlin (Check build.gradle.kts for version)

Critical Setup Steps (Non-Standard)

This project requires two manual steps to handle the Swiss Ephemeris library and data files:

1. Swiss Ephemeris Library (.jar):

  • Acquire the Swiss Ephemeris Java library file (e.g., sweph.jar).

  • Place this file into the app/libs/ directory.

  • Ensure the dependency is correctly declared in app/build.gradle.kts.

** 2. Ephemeris Data Files (.se1):

  • The application requires the main ephemeris data files (e.g., sepl_18.se1, etc.) to run its calculations.

  • These files must be present in the app/src/main/assets/ephe/ folder.

  • The AssetCopier.kt utility handles copying these files from the assets folder to the app's internal storage on first run, allowing the Swiss Ephemeris library to access them.

🧠 Architecture Overview (MVVM & Clean)

The project follows a modular, layer-based architecture to separate concerns, making it testable and maintainable.

|

Layer Directories Key Components Purpose
Presentation (UI) ui/, viewmodel/ MainScreen.kt, MainViewModel.kt Handles user interaction, manages UI state, and triggers business logic.
Domain (Data Logic) repository/ EphemerisRepository.kt Centralizes data operations (abstraction layer). Determines whether to fetch data from local calculation or persistence.
Data (Local) local/, database/ SwissEphemerisService.kt, AppDatabase.kt, ChartProfileDao.kt Local Service: Direct wrapper around the external Swiss Ephemeris library. Database: Handles saving and retrieving user chart profiles (Room).
Models model/ BirthData.kt, PlanetData.kt Pure data structures used to transfer information between layers.

🚀 Core Workflow: Calculating a Chart

This is the central process of the application:

1. User Input: User enters BirthData (Date, Time, Location) in MainScreen.kt.

2. Event: The UI triggers a calculation event in MainViewModel.kt.

3. ViewModel Action: MainViewModel calls a function on EphemerisRepository.kt.

4. Repository Logic: The repository validates the input and calls SwissEphemerisService.calculatePlanets() (or similar).

5. Local Service: SwissEphemerisService initiates the Swiss Ephemeris library, ensuring the data files are accessible (via AssetCopier.kt if necessary), and performs the complex astronomical calculation.

6. Data Return: The library's results are mapped into clean PlanetData models and flow back up through the repository to the ViewModel.

7. UI Update: The ViewModel updates its StateFlow/LiveData, causing MainScreen.kt (Composable) to automatically recompose and display the final chart results.

💡 Code Walkthrough Pointers

For a quick deep dive:

File Why it's Important
AstroApplication.kt Contains the crucial logic to initialize the app, including the first-run file copying logic from assets.
SwissEphemerisService.kt The Core: This is where all native Swiss Ephemeris calls are handled. Look here to see how date, time, and location parameters are transformed for the library.
EphemerisRepository.kt Controls the app's business logic, managing both calculation (SE) and storage (Room) paths.
MainViewModel.kt Manages the UI state (StateFlow) and accepts all user events.

Screenshots

(Add screenshots of the application here)

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.

About

Astrology App

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages