AI JavaScript project without learning JavaScript?

What could possibly go wrong? Welcome to my obituary...

AI JavaScript project without learning JavaScript?

Introduction: The Inception of AiREPLI

AIrepli began as a concept focused on enhancing user experience on social platforms through AI. The core idea was to leverage OpenAI's GPT to automate personalized, intelligent responses. This project required careful consideration of the technical stack, given the need for a balance between performance, cost, and development speed.

The Technical Stack Unpacked

Frontend: Why Vanilla JavaScript, HTML, and CSS?

Choosing vanilla JavaScript was a deliberate decision to maintain control over the project without the overhead of additional frameworks. It afforded me the flexibility to implement custom features without the weight of unused code from larger libraries. This decision ensured quick loading times, a crucial factor for a browser extension where user experience is paramount.

HTML and CSS provided the scaffolding and styling, respectively. I focused on semantic HTML to ensure accessibility and SEO, while CSS was optimised for responsiveness across different browser environments.

Backend: The Serverless Advantage with Node.js and Netlify Functions

Node.js was the backbone of the backend due to its non-blocking I/O and event-driven architecture, enabling efficient handling of concurrent requests — essential for a real-time application interfacing with AI.

Netlify Functions were a strategic choice. They provided a serverless environment that scaled automatically and charged for actual use rather than pre-allocated capacity. This was crucial for keeping costs down and managing the "cold start" problem often associated with serverless functions.

AI Integration: Interfacing with OpenAI's GPT

The integration with OpenAI's GPT required meticulous management of API requests. I implemented a caching strategy to minimise duplicate requests and used asynchronous JavaScript to handle API responses, ensuring non-blocking operations and a smooth user experience.

Continuous Integration and Deployment on Netlify

Netlify's CI/CD pipeline was a game-changer. With each git push, Netlify would run a series of automated tasks, including build processes, tests, and deployment. This ensured that AIrepli was always up-to-date with the latest code changes and bug fixes without manual intervention.

Version Control with Git and GitHub

GitHub was the repository of record. Using feature branching and pull requests, I could meticulously review changes before they were merged into the production codebase, minimising the risk of introducing errors.

Overcoming Twitter's Automation Challenges

The Policy Dilemma

Twitter's automation rules are designed to curb spam and protect genuine user interaction. To comply, I had to ensure that airepli's automated responses could not be misused for spamming purposes. This meant implementing rate limiting and adding checks to prevent misuse, while still maintaining the tool's value proposition.

The main issue was getting the text data from a post. Twitter's DOM manipulation makes this very complex and scraping for information is an automation that is against Twitter's developer policy so the obvious route was signing up a developer and getting access to the API.

The API Pricing Impasse

The Twitter API's cost structure posed significant challenges for my solo venture. The complimentary tier offered just three endpoints—POST /2/tweets, DELETE /2/tweets/:id, and GET /2/users/me—which were insufficient for airepli's needs. I required additional endpoints available in the 'Basic' tier, specifically GET /2/tweets/:id and GET /2/tweets, to fully realise the project's potential.

At $100 monthly, the 'Basic' tier provided access to 10,000 tweets, but with the caveat that both GET endpoints counted against this limit. With user operations capped at 100 monthly generations, this effectively limited my user base to 50 subscribers. With a planned standard subscription fee of $5 per user, reaching this cap would generate $250 in monthly recurring revenue.

Sounds good? Time to up the tiers and turn Pro 😎

Upgrading to the 'Pro' tier would cost $5000 per month—a crazy 50x jump requiring 20x users overnight to break even. I'm not a betting man but betting on such growth felt more like whimsical optimism than a strategic business decision. In the high-stakes game of startup scalability, I chose to look for a more viable path forward.

Like bet on San Marino to win the World Cup...

The Pivot: Broadening AiREPLI's Horizon

Shifting focus from a Twitter/LinkedIn-centric tool to a universal text assistant required significant architectural changes. Less reliance on APIs meant more reliance on my overwhelming experience with JavaScript. What could could go wrong? It's just Java without the Script you morons.

I had to abstract the functionality to be platform-agnostic, which involved designing a flexible input system that could handle various contexts and types of content.

Backend Evolution: Adapting to a Broader Mission

The backend's evolution to support a broader range of inputs was perhaps the most significant technical challenge. The serverless functions were refactored to be more generic, allowing them to process a wide variety of text inputs. This was achieved by abstracting the text processing and response generation functionalities, making them reusable across different platforms and contexts.

Lessons from the Trenches

  • Flexibility: The project underscored the importance of an adaptable architecture, especially in response to external platform changes.

  • User-Centric Design: Feedback loops with users were crucial for refining UI/UX and ensuring the tool met their needs.

  • Cost Management: The serverless model proved its worth in balancing functionality with operational costs.

  • Market Fit: A universal tool had broader appeal and use cases, highlighting the importance of pivoting when necessary.

Conclusion: AiREPLI's Continued Evolution

The transition of airepli to a universal text reply tool is not the end but a new beginning. The technical decisions and pivots made along the way are a blueprint for similar ventures. As airepli continues to evolve, I will share deeper dives into specific challenges and solutions, aiming to enrich the technical community's knowledge and toolset.