ZhiShi is an interactive web application designed to help users learn about different plant families, identify plants using a powerful AI-powered natural language search, and test their botanical knowledge through engaging quizzes. This project runs entirely in your browser, using a local AI model to ensure your data stays private.
- AI-Powered Plant Identifier: Describe a plant in your own words (e.g., "it has square stems and leaves in pairs") and the in-browser AI will identify the most likely plant families using semantic search. The entire process runs locally on your device—no data is ever sent to a server.
- Comprehensive Encyclopedia: Browse and search a detailed database of plant families, complete with descriptions, traits, common species, and images.
- Varied Botanical Quizzes: Test your knowledge with multiple quiz formats, including text-based and image-based challenges, from a central quiz selection page.
- Fully Responsive: Enjoy a seamless experience whether you're on a desktop or mobile device.
- Frontend: React, Vite, TypeScript
- Styling: Tailwind CSS, shadcn/ui
- AI/ML: Transformers.js (
@xenova/transformers) for in-browser semantic search.- Model:
bge-small-zh-v1.5for Chinese language sentence embeddings.
- Model:
- Routing: React Router
- Data Fetching/State: TanStack Query
The plant identifier uses a modern machine learning technique called semantic search to understand your descriptions. Here’s a simplified breakdown of the process:
- In-Browser AI: The app uses Transformers.js to run a sophisticated AI model (
bge-small-zh-v1.5) directly in your web browser. No special hardware or software is needed. - Embeddings Generation: When you type a description, the model converts your words into a numerical representation called an "embedding." It does the same for all the plant traits stored in its database.
- Cosine Similarity: The AI then compares the embedding of your query with the embedding of each plant trait using a mathematical calculation called "cosine similarity." This measures the "semantic distance" or similarity in meaning between your description and the traits.
- Ranking Results: The traits that are most semantically similar to your description are ranked highest, and the app shows you the corresponding plant families as the most likely matches.
Because this entire process happens on your computer (client-side), your search queries are completely private and the tool works even when you're offline (after the initial page load).
index.html- HTML entry pointvite.config.ts- Vite configuration filetailwind.config.js- Tailwind CSS configuration filepackage.json- NPM dependencies and scriptssrc/App.tsx- Root component of the projectsrc/main.tsx- Project entry pointsrc/index.css- Global CSS stylessrc/pages/- Contains the main pages of the application (Home, Encyclopedia, PlantIdentifier, Quiz).src/components/- Contains reusable React components, including UI elements from shadcn/ui.src/data/- Contains the plant data used by the application.
- All shadcn/ui components are pre-downloaded and available at
@/components/ui. You can find more components and documentation at shadcn/ui.
- Global styles are defined in
src/index.css. - Tailwind CSS utility classes are used for styling components. You can customize the theme and styles in
tailwind.config.js.
This project uses pnpm for package management. It is strongly recommended to use pnpm to ensure that the exact dependency versions from the lockfile (pnpm-lock.yaml) are used.
-
Clone the repository:
git clone https://github.com/yuzhounaut/ZhiShi.git cd ZhiShi -
Install Dependencies:
pnpm install
This command will install all the necessary dependencies based on the
pnpm-lock.yamlfile. -
Start the Development Server:
pnpm run dev
This will start the Vite development server, typically available at
http://localhost:5173.Note: The first time you run the application and access the AI Identifier, the machine learning models will be downloaded and cached by your browser. This might take a moment, so please be patient.
-
Build for Production:
pnpm run build
This command compiles the application into static assets in the
dist/directory, ready for deployment.
The @/ path alias points to the src/ directory.