https://github.com/shift/psychonautwiki-journal
Harm reduction desktop application with complete PsychonautWiki substance database - built with Kotlin Multiplatform & Compose Desktop
https://github.com/shift/psychonautwiki-journal
compose-desktop desktop-application harm-reduction kotlin-multiplatform nix psychonautwiki substance-database
Last synced: 3 months ago
JSON representation
Harm reduction desktop application with complete PsychonautWiki substance database - built with Kotlin Multiplatform & Compose Desktop
- Host: GitHub
- URL: https://github.com/shift/psychonautwiki-journal
- Owner: shift
- Created: 2025-09-09T09:39:28.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-09-09T09:42:13.000Z (3 months ago)
- Last Synced: 2025-09-09T12:48:59.443Z (3 months ago)
- Topics: compose-desktop, desktop-application, harm-reduction, kotlin-multiplatform, nix, psychonautwiki, substance-database
- Language: Kotlin
- Size: 142 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PsychonautWiki Journal
A comprehensive harm reduction desktop application built with Kotlin Multiplatform and Compose Desktop, featuring the complete PsychonautWiki substance database.
## ๐ฏ Purpose
This application provides evidence-based harm reduction information for psychoactive substances, helping users make informed decisions about substance use through comprehensive data on dosing, duration, interactions, and safety information.
## โจ Features
- **๐ Complete PsychonautWiki Database**: Access to 289 psychoactive substances with comprehensive harm reduction data
- **๐ Detailed Substance Information**:
- Dosing guidelines for different routes of administration
- Duration data (onset, peak, offset, total duration)
- Bioavailability information
- Interaction warnings and contraindications
- Tolerance and addiction potential information
- **๐ Advanced Search & Filtering**: Search by substance name, common names, categories, or effects
- **โก Fast Performance**: Optimized database loading with health monitoring and metrics
- **๐ฅ๏ธ Modern Desktop UI**: Clean, responsive interface built with Compose Desktop
- **๐ก๏ธ Robust Error Handling**: Graceful fallbacks and comprehensive error reporting
## ๐ ๏ธ Technology Stack
- **Kotlin Multiplatform**: Cross-platform development
- **Compose Desktop**: Modern declarative UI framework
- **kotlinx.serialization**: JSON parsing and data serialization
- **SQLDelight**: Database management with coroutines support
- **Koin**: Dependency injection
- **NixOS**: Reproducible development environment
## ๐ Getting Started
### Prerequisites
- **Nix with flakes enabled** (recommended for reproducible builds)
- **Java 17+** (if not using Nix)
- **Gradle 7.6+** (if not using Nix)
### Quick Start with Nix
1. Clone the repository:
```bash
git clone https://github.com/shift/psychonautwiki-journal.git
cd psychonautwiki-journal
```
2. Enter the development environment:
```bash
nix develop
```
3. Build and run the application:
```bash
cd psychonautwiki-journal-desktop
gradle run
```
### Traditional Setup
1. Clone the repository:
```bash
git clone https://github.com/shift/psychonautwiki-journal.git
cd psychonautwiki-journal/psychonautwiki-journal-desktop
```
2. Build and run:
```bash
./gradlew run
```
## ๐ Database Integration
The application successfully loads the complete PsychonautWiki database:
- **289 substances** with comprehensive harm reduction data
- **12 substances** with bioavailability information
- **Multiple routes of administration** per substance
- **Interaction warnings** for dangerous combinations
- **Category-based organization** (psychedelics, stimulants, depressants, etc.)
### Database Loading Features
- **Progress Tracking**: Real-time loading progress with metrics
- **Health Monitoring**: Database integrity checks and load time tracking
- **Graceful Fallbacks**: Fallback to essential substances if full database fails
- **Error Recovery**: Robust handling of malformed JSON entries
Expected console output on successful load:
```
๐ Loading PsychonautWiki substance database...
๐ JSON file loaded: 458192 characters
โ
Successfully loaded PsychonautWiki database in ~500ms
๐ Database metrics:
โข 289 substances
โข 15 categories
โข 180+ substances with dosing/duration data
โข 12 substances with bioavailability data
โข 150+ substances with interaction warnings
โข 400+ total routes of administration
```
## ๐๏ธ Architecture
### Data Layer
- **PsychonautWikiDatabase**: Singleton database manager with JSON parsing
- **SubstanceRepository**: Repository pattern for data access
- **SubstanceLoader**: Service layer for substance loading operations
### Domain Models
- **SubstanceInfo**: Complete substance information
- **RouteOfAdministration**: Dosing and route-specific data
- **BioavailabilityRange**: Bioavailability percentage ranges
- **DurationRange**: Time-based effect duration data
- **InteractionData**: Substance interaction warnings
### UI Layer
- **Compose Desktop**: Modern declarative UI
- **MVVM Pattern**: ViewModels for state management
- **Responsive Design**: Adaptive layouts for different screen sizes
## ๐ง Build Commands
In the NixOS development environment:
```bash
# Build the application
gradle build
# Run the application
gradle run
# Run tests
gradle test
# Run all checks (including BDD tests)
gradle check
# Build distribution package
gradle distZip
```
## ๐งช Testing
The project includes comprehensive testing:
- **Unit Tests**: Core functionality and data models
- **Integration Tests**: Database loading and parsing
- **BDD Tests**: Cucumber-based behavior testing
- **Kotest**: Modern Kotlin testing framework
## ๐ Project Structure
```
psychonautwiki-journal/
โโโ psychonautwiki-journal-desktop/ # Desktop application
โ โโโ src/commonMain/kotlin/ # Shared Kotlin code
โ โ โโโ data/ # Data layer (repositories, models)
โ โ โโโ ui/ # UI layer (screens, viewmodels)
โ โ โโโ navigation/ # Navigation logic
โ โโโ src/commonMain/resources/ # Resources (database JSON)
โ โโโ src/commonTest/kotlin/ # Shared tests
โ โโโ src/desktopMain/kotlin/ # Desktop-specific code
โโโ psychonautwiki-journal-android/ # Android application (legacy)
โโโ flake.nix # NixOS development environment
โโโ README.md # This file
```
## ๐ Recent Improvements
### JSON Parsing Fixes
- **Fixed bioavailability parsing**: Created `BioavailabilityRange` to handle complex JSON structures
- **Fixed duration range parsing**: Made `min` field optional for partial data
- **Enhanced error handling**: Robust parsing with graceful fallbacks
### Database Enhancements
- **Loading metrics**: Comprehensive health monitoring and performance tracking
- **Progress indicators**: Real-time feedback during database loading
- **Error recovery**: Partial loading support for malformed entries
### UI Improvements
- **Bioavailability display**: Shows bioavailability ranges in substance listings
- **Enhanced search**: Full-text search across complete database
- **Performance optimization**: Efficient rendering of large substance lists
## ๐ค Contributing
This project focuses on harm reduction and evidence-based information. Contributions are welcome for:
- **UI/UX improvements**
- **Additional harm reduction features**
- **Database optimization**
- **Testing and documentation**
- **Accessibility enhancements**
## โ๏ธ Legal & Safety
- **Educational Purpose**: This application is for educational and harm reduction purposes only
- **Not Medical Advice**: Information provided is not medical advice; consult healthcare professionals
- **Substance Safety**: Promotes responsible use and harm reduction practices
- **Data Source**: Information sourced from PsychonautWiki, a collaborative harm reduction resource
## ๐ License
[License information to be added]
## ๐ Acknowledgments
- **PsychonautWiki**: For providing the comprehensive substance database
- **Harm Reduction Community**: For evidence-based safety information
- **Kotlin & Compose Teams**: For excellent development tools
- **NixOS Community**: For reproducible development environments
---
**๐ก๏ธ Remember: The safest use is no use. If you choose to use substances, please prioritize harm reduction, start with low doses, test substances when possible, and never use alone.**