Alan Wang's Technical Blog and Knowledge System
website·Indexed 32 days ago
https://www.alanwang.site/A collection of technical articles and summaries covering front-end development, including a Webpack tutorial, React components, source analysis of Axios and Mitt, algorithms (sorting and hashing), and a comprehensive front-end knowledge system including network protocols and memory management.
What's inside Alan Wang
- docs-ai-bot is a Github bot built using Probot that automatically generates summaries for blog posts.
Introduction to Expo for Web Developers
Expo is a framework for building mobile applications that can be compared to Next.js but for React Native. It is particularly useful for Web developers as it significantly lowers the learning curve and reduces the time spent on environment setup compared to standard React Native development.Overview of DocsMind document Q&A application
DocsMind is an open-source document question-and-answer application powered by OpenAI. It supports processing and querying files in Markdown (.md) and PDF formats.Overview of Expo for React Native Development
Expo is a framework for React Native that simplifies mobile app development, particularly for Web developers. It allows for a single codebase to run across Web, iOS, and Android. Key features include file-based routing (similar to Next.js), a comprehensive set of official SDKs, and the ability to create API services (Beta).Overview of the Docusaurus AI Summarization Bot
Thedocs-ai-botis a GitHub bot built with the Probot framework that automates the process of summarizing blog posts using the Google Gemini AI model. To avoid the need for a live server on a static site, the bot generates summaries during the build/commit phase and inserts them directly into the front matter of the markdown documents. This allows the summaries to be retrieved as static content.Project Link: https://github.com/3Alan/docs-ai-botOverview of alan-ui hand-drawn style component library
alan-ui is a component library developed with React that provides a hand-drawn visual style for user interfaces.Overview of Airbnb clone full-stack mobile app
A full-stack mobile application clone of Airbnb developed using Expo and MongoDB.Implement a RAG system for PDF documents
To allow an LLM to answer questions about long PDF documents that exceed the API token limit, use the following Retrieval-Augmented Generation (RAG) workflow:
- Extract text from the PDF.
- Split the text into smaller fragments (e.g., using periods
.or。as separators to maintain sentence-level semantic meaning). - Generate vector embeddings for each fragment using the OpenAI Embedding API.
- Store the vectors and original text fragments in a database (e.g., Postgres via Supabase).
- Convert the user's query into a vector using the same embedding model.
- Use the Cosine Similarity algorithm to find the most similar text fragments in the database.
- Provide these fragments as context to the LLM to generate an answer.
Understand the Publish-Subscribe pattern vs Observer pattern
Themittlibrary implements the Publish-Subscribe pattern. Unlike the Observer pattern where the Subject and Observer know about each other, the Publish-Subscribe pattern introduces an Event Bus (themittinstance) as a middleman. The publisher and subscriber are decoupled and do not have direct knowledge of each other; they only interact with the Event Bus.Understand the JavaScript Event Loop and Task Queue
JavaScript is single-threaded to avoid DOM synchronization issues. It uses an Event Loop to manage execution:
- Synchronous tasks are executed immediately in the execution stack.
- Asynchronous tasks are placed in a task queue.
- When the stack is empty, the Event Loop moves tasks from the queue to the stack.
Tasks are divided into:
- Macro-tasks:
script,setTimeout,setInterval. - Micro-tasks:
Promise.then(),process.nextTick.
Priority:
process.nextTick>Promise.then(). Micro-tasks are always executed before the next macro-task once the current execution stack is clear.Understand the Publish-Subscribe pattern in mitt
Themittlibrary implements the Publish-Subscribe pattern. Unlike the Observer pattern where the Subject and Observer know each other, the Pub-Sub pattern introduces an Event Bus (themittinstance) as a middleman. The publisher (emitter) and subscriber (listener) are decoupled; they do not have direct references to each other and only communicate through the Event Bus.Implement File-System Based Routing in Next.js
In Next.js, any React component exported from a file in the
pagesdirectory automatically becomes a route based on its filename.pages/about.jsmaps to/aboutpages/dashboard/settings/username.jsmaps to/dashboard/settings/username