How mukesh360/psychtrend works
Psychological Trend Analysis System is a local-first behavioral reflection chatbot. A user starts a session in the chat UI, answers adaptive questions, and receives a report after responses are structured, stored, and analyzed for sentiment, trends, behavioral archetypes, and predictions. The report UI presents those results; optional Ollama enhancements normalize input and humanize explanations without replacing statistical analysis. The graph combines sampled source relationships with documented capabilities and workflow; links based only on documentation are cited to the README.
Main entry points: main.py FastAPI routes · llm_service.py LLM enhancements · chat.js Chat UI · chat_logic.py Adaptive questions
Components 21
User experience
- Chat UI
frontend/js/chat.js - Chat page
frontend/index.html - Report UI
frontend/js/report.js - Report page
frontend/report.html
Conversation and API
- FastAPI routes
backend/main.py - Adaptive questions
backend/chat_logic.py - Question bank
data/questions.json - Response structuring
backend/data_processor.py - API data models
backend/models.py
Behavioral analysis
- Sentiment analysis
backend/ml_engine/sentiment.py - Trend analysis
backend/ml_engine/trends.py - Sentiment safeguards
backend/ml_engine/sentiment_context.py - Behavioral clustering
backend/ml_engine/clustering.py - Behavior predictions
backend/ml_engine/predictor.py
Reports and language
- Report generation
backend/main.py - LLM enhancements
backend/llm_service.py - LLM prompts
backend/llm_prompts.py - Ollama client
backend/ollama_client.py
Local persistence
- SQLite database
backend/database.py
Other components
- User
- Ollama service
Connections 25
- User → Chat UI: answers questions
README.md - Chat page → Chat UI: hosts interface
README.md - Chat UI → FastAPI routes: sends messages
README.md - FastAPI routes → Chat UI: returns responses
README.md - FastAPI routes → API data models: validates requests
backend/main.py - FastAPI routes → Adaptive questions: advances conversation
backend/main.py - Adaptive questions → Question bank: selects questions
README.md - FastAPI routes → Response structuring: structures responses
backend/main.py - FastAPI routes → SQLite database: reads and writes sessions
backend/main.py - FastAPI routes → Sentiment analysis: analyzes responses
backend/main.py - FastAPI routes → Trend analysis: computes trends
backend/main.py - FastAPI routes → Behavioral clustering: clusters behavior
backend/main.py - FastAPI routes → Behavior predictions: computes predictions
backend/main.py - Trend analysis → Sentiment safeguards: applies score caps
backend/ml_engine/trends.py - Behavioral clustering → Sentiment safeguards: filters archetypes
backend/ml_engine/clustering.py - FastAPI routes → Report generation: formats report
README.md - Report generation → SQLite database: stores report
backend/database.py - Report generation → Report UI: serves report data
README.md - Report page → Report UI: hosts report view
README.md - Report UI → User: displays insights
README.md - Adaptive questions → LLM enhancements: enhances questions
backend/chat_logic.py - Response structuring → LLM enhancements: normalizes input
backend/data_processor.py - LLM enhancements → LLM prompts: uses templates
backend/llm_service.py - LLM enhancements → Ollama client: requests generation
backend/llm_service.py - Ollama client → Ollama service: calls local model
backend/ollama_client.py