Insighta CLI is a powerful, globally installable command-line tool designed for the Insighta Labs+ Profile Intelligence System. It provides engineers and power users with secure, high-performance access to profile data, natural language search, and administrative controls.
The Insighta CLI is engineered for speed, security, and a premium terminal experience:
- Typer: The framework for building beautiful CLIs with Python.
- Rich: Used for high-fidelity terminal formatting, tables, and progress indicators.
- HTTPX: A next-generation HTTP client for Python, handling all asynchronous API communication.
- Python-Dotenv: For managing sensitive environment configurations.
- Asyncio: Powering the concurrent nature of network requests and the local callback server.
The CLI follows a modular architecture:
main.py: The entry point, defining commands and managing the user interface.auth_helper.py: A specialized module for handling OAuth 2.0 PKCE flows and local session management.api_client.py: A robust wrapper for the backend REST API, implementing automatic retries and token refresh logic.
To ensure maximum security, we implemented a custom OAuth 2.0 with PKCE (Proof Key for Code Exchange) flow:
- Initiation: The CLI generates a unique
stateand opens the user's browser to GitHub. - Local Callback: A temporary, lightweight
HTTPServeris launched onlocalhost:8080. - Redirection: After GitHub authentication, our backend processes the code and redirects the browser back to the CLI's local server.
- Token Capture: The local server captures the
access_tokenandrefresh_tokensecurely from the URL parameters. - Session Persistence: Credentials are encrypted and stored locally in
~/.insighta/credentials.json.
- Auto-Refresh: The CLI monitors token validity. If a request returns a
401 Unauthorized, theapi_clientautomatically uses therefresh_tokento obtain a new session without interrupting the user. - Graceful Failure: If both tokens are expired, the user is prompted to re-authenticate.
Leveraging the backend's vector search capabilities, the CLI allows users to query profiles using plain English (e.g., "young developers from Nigeria"), bridging the gap between technical data and human intuition.
- Python 3.10 or higher
- A GitHub account
# Clone the repository
git clone https://github.com/your-org/insighta-cli.git
cd insighta-cli
# Install in editable mode
pip install -e .Once installed, the insighta command will be available globally.
| Command | Description |
|---|---|
insighta login |
Authenticate with GitHub via secure PKCE flow. |
insighta logout |
Clear local credentials and terminate session. |
insighta whoami |
Display current user status and role. |
- List Profiles:
insighta profiles list --gender male --country NG --limit 10
- Natural Language Search:
insighta profiles search "software engineers in Lagos" - Get Detailed Profile:
insighta profiles get <profile-id>
- Create Profile (Admin Only):
insighta profiles create --name "Alice Johnson" - Export Data:
insighta profiles export --format csv
- Credentials: Stored at
~/.insighta/credentials.json. - Environment Variables:
INSIGHTA_BACKEND_URL: Override the default API endpoint.GITHUB_CLIENT_ID: OAuth client ID for authentication.
- Conventional Commits: All changes follow the
feat:,fix:,chore:convention. - API Versioning: All requests include the
X-API-Version: 1header for consistency. - Async-First: All network I/O is asynchronous to prevent terminal blocking.