How hanzvibes/instajs works
1. Repository type and runtime
- This is a Node.js command-line automation tool for Instagram, not a web app.
- The main entrypoint is index.js, which likely presents the CLI flow and dispatches to feature modules under src/.
2. Primary boundary: Instagram as the external system
- The only major external dependency is Instagram itself.
- All bot behavior revolves around interacting with Instagram users, posts, stories, hashtags, locations, and follower graphs.
3. Core integration layer
- src/api.js is the central integration module.
- It likely wraps the low-level Instagram session/authentication and exposes reusable operations consumed by the feature-specific modules.
4. Configuration and authentication
- Credentials come from .env via dotenv, as documented in the README.
- This means account identity is configured outside the codebase, while runtime behavior is driven by the CLI and environment variables.
5. Feature subsystems by content source
- The code is organized by where targets come from:
- src/feeds/: actions on the user’s feed and stories.
- src/hashtags/: actions against hashtag-generated content.
- src/targetFollowers/: actions against followers of a chosen account.
- src/targetFollowings/: actions against accounts followed by a chosen target.
- src/targetLocation/: actions against posts/accounts discovered by location.
- src/targets/: custom target-profile actions.
- This structure is the clearest architectural boundary in the repo.
6. Feature subsystems by action type
- The automation actions are split into small purpose-built modules:
- follow
- like
- comment
- followLike
- followLikeComment
- DM variants under src/dm/
- story_views
- This suggests the architecture is composed of reusable action pipelines rather than one monolithic bot loop.
7. Account maintenance and cleanup
- src/accounts/ handles ongoing hygiene tasks:
- unfollowing inactive users,
- unfollowing users with no posts,
- unfollowing non-follow-backs,
- cleaning media/posts.
- These are distinct from growth/engagement actions and represent a separate maintenance subsystem.
8. State persistence and idempotency
- The logs/ tree is a major architectural piece.
- Separate log folders exist for accounts, feeds, hashtags, targets, target followers, target followings, and target locations.
- The README says the bot remembers previously interacted users, so these logs are used as persistent state to avoid reprocessing after restart.
9. Typical data flow
- A CLI command selects a feature.
- The relevant module discovers candidate users/posts from Instagram.
- The module applies interaction rules and delays to simulate human behavior.
- Successful actions are recorded in the corresponding log path.
- Later runs consult those logs to skip already-processed accounts/content.
10. Operational concerns
- The README emphasizes auto-set delays and human-like pacing, which indicates timing/throttling is an architectural concern, not just a utility detail.
- This affects all action modules and likely sits in shared logic inside the API layer or the CLI dispatcher.
11. UI/assets and packaging
- assets/ is only for branding/screenshots/banner images, not runtime logic.
- package.json defines the Node package/runtime dependencies, while .gitignore and LICENSE are repo scaffolding rather than architectural components.
12. How to diagram it
- A good architecture diagram would show:
- CLI entrypoint (index.js)
- shared Instagram API layer (src/api.js)
- feature modules grouped by source and action
- filesystem logs as persistent state
- Instagram as the external service boundary
- The repo is essentially a modular automation engine with feature-specific pipelines feeding a shared Instagram interaction layer.
Main entry points: index.js CLI entry · logs Logs · feeds Feed actions · hashtags Hashtag actions
Components 19
CLI
Command entrypoint and package runtime
Core
Shared Instagram integration and account info
- API layer · Shared integration layer wrapping Instagram session and actions
src/api.js - Account info · Helper for retrieving or presenting account information
src/info.js
Target sources
Feature pipelines organized by where candidates come from
- Feed actions · Interactions driven by the user feed and stories
src/feeds - Hashtag actions · Interactions driven by hashtag-discovered content
src/hashtags - Followers target · Actions against followers of a chosen account
src/targetFollowers - Followings target · Actions against accounts followed by a chosen target
src/targetFollowings - Location target · Actions against posts or users found by location
src/targetLocation - Custom target · Actions against explicitly chosen target profiles
src/targets - DM actions · Follow-like-comment variants that include messaging
src/dm - Story views · Story viewing automation for feed stories
src/feeds/story_views.js
Maintenance
Account cleanup and hygiene tasks
- Account cleanup · Hygiene tasks such as unfollowing and media cleanup
src/accounts
State
Persistent logs used to avoid reprocessing
- Logs · Filesystem records that track processed accounts and content
logs
External
Outside system boundary
- Instagram · Target platform and network boundary
Other components
- Follow · Core follow operation used by multiple source pipelines
src/hashtags/follow.js - Like · Core like operation reused across source pipelines
src/feeds/like.js - Comment · Commenting operation used in combined engagement flows
src/hashtags/comment.js - Combined flow · Follow-like and follow-like-comment variants
src/hashtags/followLikeComment.js
Connections 29
- CLI entry → API layer: dispatches · CLI routes commands into the shared integration layer
- CLI entry → Feed actions: runs · CLI can start feed-based automation flows
- CLI entry → Hashtag actions: runs · CLI can start hashtag-based automation flows
- CLI entry → Followers target: runs · CLI can start follower-targeted flows
- CLI entry → Followings target: runs · CLI can start followings-targeted flows
- CLI entry → Location target: runs · CLI can start location-targeted flows
- CLI entry → Custom target: runs · CLI can start custom target flows
- CLI entry → Account cleanup: runs · CLI can trigger maintenance tasks
- CLI entry → DM actions: runs · CLI can start DM-enhanced engagement flows
- Feed actions → Like: uses · Feed flows perform likes
- Feed actions → Combined flow: uses · Feed flows can combine actions
- Feed actions → Story views: uses · Feed subsystem includes story viewing
- Hashtag actions → Follow: uses · Hashtag flows can follow discovered users
- Hashtag actions → Like: uses · Hashtag flows can like discovered content
- Hashtag actions → Comment: uses · Hashtag flows can comment on content
- Followers target → Combined flow: uses · Follower-targeted flows favor combined engagement sequences
- Followings target → Follow: uses · Following-targeted flows emphasize follow actions
- Location target → Comment: uses · Location-targeted flows support comments
- Custom target → Like: uses · Custom target flows can like posts
- Account cleanup → API layer: uses · Maintenance tasks share the same Instagram integration
- DM actions → API layer: uses · DM variants depend on the shared API layer
- API layer → Instagram: integrates · All automation ultimately acts on Instagram
- Logs → Feed actions: persists · Feed interactions are recorded for idempotency
- Logs → Hashtag actions: persists · Hashtag interactions are recorded for idempotency
- Logs → Followers target: persists · Follower-targeted runs are recorded for idempotency
- Logs → Followings target: persists · Following-targeted runs are recorded for idempotency
- Logs → Location target: persists · Location-targeted runs are recorded for idempotency
- Logs → Custom target: persists · Custom target runs are recorded for idempotency
- Logs → Account cleanup: persists · Maintenance tasks also use logs as durable state