An AI-powered dream journal that helps you record, analyze, and explore your dreams with advanced natural language processing and semantic search.
Dream Journal AI combines cutting-edge AI technology with psychological dream analysis to help users record, interpret, and explore their dreams. Using Google's Gemini AI and vector embeddings, it provides personalized dream insights and pattern discovery.
- Smart Dream Analysis: Google Gemini AI generates personalized dream interpretations
- Auto-Title Generation: AI creates meaningful titles for your dreams
- Conversational Interface: Chat with your dream history using natural language
- Semantic Search: Find dreams by meaning, not just keywords (pgvector + sentence transformers)
- Pattern Analysis: Discover recurring themes, symbols, and emotions
- Dream Comparison: Compare two dreams to find connections and insights
- Smart Fallback: 3-level search (semantic β keyword β text) ensures results
- JWT-based authentication
- Google OAuth integration
- Secure password hashing with bcrypt
- Framework: FastAPI (async/await)
- AI Models: Google Gemini (gemini-2.5-flash-lite), LangChain
- Database: PostgreSQL with AsyncSQLAlchemy ORM
- Vector Search: pgvector extension
- Embeddings: Sentence Transformers (all-MiniLM-L6-v2, 384-dim)
- Authentication: JWT + OAuth2 (Google)
- React Native mobile app
- Modern web interface
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Dream Journal AI - RAG Flow β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
User Query βββΊ Embedding Model βββΊ Vector Search βββΊ Context βββΊ LLM
(all-MiniLM-L6) (pgvector) (dreams) (Gemini)
β
βΌ
AI Response
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββ
β User Dreams β β PGVector β β Google β
β (PostgreSQL) βββββββΊβ βββββββΊβ Gemini API β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββ
ββββββββββββββββ βββββββββββββββββββ
β Users β β DreamEntry β
ββββββββββββββββ€ βββββββββββββββββββ€
β id (PK) ββββββ β id (PK) β
β email β β β user_id (FK) βββββββ
β username β βββββΊβ title β β
β password β β description β β
ββββββββββββββββ β interpretation β β
β emotion_tags β β
β timestamp β β
βββββββββββββββββββ β
β β
β β
ββββββββββΌβββββββββ β
β DreamVector β β
βββββββββββββββββββ€ β
β id (PK) β β
β dream_id (FK) βββββββ
β user_id (FK) β
β embedding βββββ pgvector (384-dim)
β created_at β
βββββββββββββββββββ
src/backend/
βββ api/
β βββ endpoints/
β β βββ dreams.py # Dream CRUD operations
β β βββ dream_explorer.py # Conversational search
β β βββ users.py # User management
β βββ routes.py # Router aggregation
βββ services/
β βββ dream_service.py # Dream business logic
β βββ dream_explorer_service.py # Dream history exploration
β βββ dream_retrieval_service.py # Vector search & embeddings
βββ models/
β βββ dreamentry.py # Dream SQLAlchemy model
β βββ dream_vector.py # Embedding storage model
β βββ user.py # User model
β βββ schemas.py # Pydantic validation schemas
βββ ai_interpreters/
β βββ gemini_interpreter.py # Google Gemini integration
βββ utils/
βββ auth.py # JWT authentication
βββ config.py # Settings management
- Python 3.10+
- PostgreSQL 12+ (with pgvector extension)
- Google Gemini API Key
# Clone and setup
git clone https://github.com/Syamgith/ai-dream-journal.git
cd ai-dream-journal
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
# Configure environment (.env file)
PostgreSQL_URL=postgresql+asyncpg://user:password@localhost:5432/dream_journal
GOOGLE_API_KEY=your_gemini_api_key
JWT_SECRET=your_jwt_secret
LLM_MODEL_NAME=gemini-2.5-flash-lite
# Initialize database
alembic upgrade head
# Run server
uvicorn main:app --host 0.0.0.0 --port 8000 --reloaddocker-compose up --buildInteractive Docs:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
POST /dreams/- Create dream with AI interpretationGET /dreams/- List user's dreamsGET /dreams/{id}- Get specific dreamPUT /dreams/{id}- Update dreamDELETE /dreams/{id}- Delete dream
-
POST /dream-explorer/ask- Chat with your dream history{ "question": "What do my flying dreams mean?", "chat_history": [], "top_k": 5 } -
POST /dream-explorer/search- Semantic search across dreams{ "query": "dreams about water and oceans", "top_k": 5, "emotion_tags": ["calm"] } -
GET /dream-explorer/similar/{dream_id}- Find similar dreams -
POST /dream-explorer/patterns- Discover recurring patterns{ "pattern_query": "recurring nightmares", "top_k": 10 } -
POST /dream-explorer/compare- Compare two dreams{ "dream_id_1": 123, "dream_id_2": 456 }
POST /token- Login (JWT)POST /users/register- Register new userPOST /auth/google- Google OAuth
# Run all tests
pytest
# Run specific test suites
pytest tests/test_dream_explorer_endpoints.py
pytest tests/test_dream_service.py- Dream Entry: User creates a dream β AI generates interpretation using Gemini
- Embedding Creation: Dream description β Sentence Transformer β 384-dim vector β Stored in pgvector
- Semantic Search: Query β Embedded β Similarity search in pgvector β Ranked results
- Dream Explorer: Question β Retrieves relevant dreams β LangChain + Gemini β Conversational response
- Fallback Search: Semantic β Keyword matching β Text pattern search (ensures results)
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE for details
Built with: Google Gemini AI β’ FastAPI β’ LangChain β’ pgvector β’ Sentence Transformers
Made with β€οΈ for dreamers everywhere


