An oneironaut is an explorer of dreams. This project is a blockchain-based platform for sharing and connecting dreams.
- Decentralized Blockchain: A fully functional blockchain implementation.
- Proof of Connection: A unique consensus mechanism that forges new blocks by finding common themes (tags) in dreams.
- NLP-powered Dream Analysis: Uses Natural Language Toolkit (NLTK) to extract key tags from dream text.
- Interactive Dream Map: A web interface that visualizes the connections between dreams as an interactive graph.
- Cryptographic Security: Transactions are secured with digital signatures, ensuring user ownership and data integrity.
- Node Network: Supports multiple nodes and can resolve conflicts using the longest-chain rule.
- Persistent Storage: The blockchain state is saved to an SQLite database, ensuring data survives restarts.
- Improved Transaction Handling: Transactions are now managed in an in-memory pool before being committed to a block, improving efficiency and and reliability.
The project is structured as a scalable Flask application:
/
|-- app/
| |-- __init__.py # Application factory
| |-- blockchain.py # Core Blockchain class
| |-- routes.py # Flask routes and API endpoints
| |-- wallet.py # Wallet for key management and signing
| |-- db.py # Database connection and initialization
| |-- schema.sql # Database schema definition
| |-- templates/
| |-- index.html # Main web interface
|-- run.py # Main entry point to run the application
|-- requirements.txt # Project dependencies
|-- .gitignore # Git ignore file
|-- .flake8 # Flake8 configuration
|-- pyproject.toml # Black configuration
|-- blockchain.db # SQLite database file (created on first run)
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS and Linux:
source venv/bin/activate
- On Windows:
-
Install the required packages:
pip install -r requirements.txt
-
Initialize the database and create the genesis block:
- Important: If you have an old
blockchain.dbfile, please delete it before running this command to ensure the correct schema is applied. - On Windows:
del instance\blockchain.db - On macOS and Linux:
rm instance/blockchain.db
- Then, run:
flask --app run init-db
- Important: If you have an old
-
Run the application:
python run.py
You can also specify a port:
python run.py --port 5001
GET /: Renders the main web interface.GET /mine: Mines a new block.POST /transactions/new: Adds a new dream transaction.GET /chain: Returns the full blockchain.POST /nodes/register: Registers new nodes in the network.GET /nodes/resolve: Resolves conflicts between nodes.GET /api/graph_data: Returns the data for the dream map visualization.
- Start the application: Run
python run.py. - Open the web interface: Open your browser and go to
http://localhost:5000. - Submit dreams: Use the form to submit your dreams.
- Mine new blocks: Click the "Mine New Block" button to forge a new block and see the dream map grow.
- Explore the dream map: Interact with the graph to see the connections between dreams.