How jeremyhenrickson/token-app-js works
Project Type and Purpose
• This is a Node.js/Java “Token app” chatbot service.
• Purpose: run user-facing bot logic (src/bot.js) that interacts with the Token network (end-to-end encrypted chat and payments) via a Java headless client, stores state in Postgres, and uses Redis for inter-process messaging.
File Structure Analysis
• Root-level: Dockerfile, Procfile, docker-compose.yml.sample → containerization & deployment.
• dependencies/: prebuilt Docker images for headless-client (Java) and redis.
• config/: environment-specific YAML configs (dev/staging/prod).
• src/: Node.js bot logic + library modules (Bot, Client, Config, Logger, Session, Thread).
• build.gradle + system.properties → Java headless client build config.
• examples/, docs/: usage samples and architecture image.
README Insights
• Lists four runtime processes: token-headless-client, redis pub/sub, bot.js, postgres.
• Describes how messages flow (client ↔ redis ↔ bot ↔ redis ↔ client) and session data stored in Postgres.
Main Components
b. Token Headless Client (Java process)
c. Redis Pub/Sub (message bus)
d. Bot Service (Node.js process with src/lib modules)
e. PostgreSQL Database
Relationships & Data Flows
• Headless Client ←→ Token Backend (HTTPS / Signal protocol)
• Headless Client ↔ Redis Pub/Sub (publish incoming messages, subscribe outgoing messages)
• Bot Service ↔ Redis Pub/Sub (listen for new messages, publish responses)
• Bot Service ↔ PostgreSQL (CRUD session/state data)
Architectural Patterns & Technologies
• Micro-process design: separate Java “client proxy” from Node.js “business logic.”
• Pub/Sub messaging for decoupling (Redis).
• Persistent session store (Postgres) for stateful conversations.
• Containerized deployment (Docker + docker-compose, Heroku).