{"id":30007603,"url":"https://github.com/pak-app/ai-powered-code-snippet-search","last_synced_at":"2026-04-11T02:04:29.146Z","repository":{"id":307816191,"uuid":"1027225713","full_name":"pak-app/ai-powered-code-snippet-search","owner":"pak-app","description":"A AI-Powered Code Snippet Search Engine: Explain and Find :mag_right:","archived":false,"fork":false,"pushed_at":"2025-09-06T11:58:17.000Z","size":171,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-06T13:23:04.538Z","etag":null,"topics":["grpc","mongoose","nodejs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pak-app.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-27T15:25:22.000Z","updated_at":"2025-09-06T11:39:34.000Z","dependencies_parsed_at":"2025-08-02T12:30:48.189Z","dependency_job_id":null,"html_url":"https://github.com/pak-app/ai-powered-code-snippet-search","commit_stats":null,"previous_names":["pak-app/ai-powered-code-snippet-search"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pak-app/ai-powered-code-snippet-search","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pak-app%2Fai-powered-code-snippet-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pak-app%2Fai-powered-code-snippet-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pak-app%2Fai-powered-code-snippet-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pak-app%2Fai-powered-code-snippet-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pak-app","download_url":"https://codeload.github.com/pak-app/ai-powered-code-snippet-search/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pak-app%2Fai-powered-code-snippet-search/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006838,"owners_count":26084203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grpc","mongoose","nodejs","typescript"],"created_at":"2025-08-05T08:46:27.789Z","updated_at":"2025-10-11T10:14:02.449Z","avatar_url":"https://github.com/pak-app.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AI-Powered Code Snippet Search\n\nThis project is a powerful, AI-driven code snippet search engine. It allows users to store and search for code snippets using natural language descriptions, thanks to vector embeddings generated by a sentence-transformer model. The system is built with a microservices architecture, featuring a Node.js/Express API for client interactions and a Python gRPC service for AI-powered embedding generation.\n\n## Project Status\n\n**This project is currently under development and is not yet complete.**\n\n- The `GET /api/snippets` route for searching snippets is not yet implemented and contains a bug.\n\n## Features\n\n-   **Natural Language Search**: Find code snippets by describing what you're looking for, not just by keyword matching.\n-   **Store Code Snippets**: Save your most-used code snippets, complete with descriptions, language, and tags.\n-   **Microservices Architecture**: A scalable and maintainable design with separate services for the client-facing API and the AI embedding model.\n-   **gRPC Communication**: Efficient and high-performance communication between the Node.js and Python services.\n-   **MongoDB Database**: A flexible and scalable NoSQL database for storing code snippets and their vector embeddings.\n\n## Architecture\n\nThe project is composed of two main microservices:\n\n1.  **Client API (`client-api`)**: A Node.js/Express application that provides a RESTful API for creating and searching for code snippets. It handles user requests, validates input, and communicates with the `embedding-api` to get vector embeddings for code descriptions. It then stores the snippets, along with their embeddings, in a MongoDB database.\n\n2.  **Embedding API (`embedding-api`)**: A Python application that exposes a gRPC service for generating vector embeddings. It uses the `sentence-transformers` library to convert text descriptions into high-dimensional vectors.\n\nHere is a diagram illustrating the architecture:\n\n```\n+-----------------+      +-----------------+      +-------------------+\n|      Client     |-----\u003e|   Client API    |-----\u003e|   Embedding API   |\n| (e.g., Postman) |      |  (Node.js)      |      |     (Python)      |\n+-----------------+      +-------+---------+      +-------------------+\n                                  |\n                                  |\n                                  v\n                          +-----------------+\n                          |    MongoDB      |\n                          |    Database     |\n                          +-----------------+\n```\n\n## Technologies\n\n-   **Client API**:\n    -   Node.js\n    -   Express.js\n    -   TypeScript\n    -   Mongoose (for MongoDB)\n    -   gRPC\n    -   Joi (for validation)\n\n-   **Embedding API**:\n    -   Python\n    -   gRPC\n    -   `sentence-transformers`\n\n-   **Database**:\n    -   MongoDB\n\n-   **API Specification**:\n    -   Protobuf (for gRPC)\n\n## Sentence Transformer Model\n\nThe `embedding-api` uses the `all-MiniLM-L6-v2` model from the `sentence-transformers` library to generate vector embeddings. This model is a high-performance, lightweight model that is well-suited for a variety of sentence and text embedding tasks.\n\n-   **Model**: `all-MiniLM-L6-v2`\n-   **Hugging Face URL**: [https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2)\n\n## Getting Started\n\n### Prerequisites\n\n-   Node.js and npm\n-   Python and pip\n-   MongoDB\n\n### Installation\n\n1.  **Clone the repository:**\n\n    ```bash\n    git clone https://github.com/your-username/ai-powered-code-snippet-search.git\n    cd ai-powered-code-snippet-search\n    ```\n\n2.  **Set up the Client API:**\n\n    ```bash\n    cd client-api\n    npm install\n    ```\n\n3.  **Set up the Embedding API:**\n\n    ```bash\n    cd ../embedding-api\n    python -m venv .venv\n    source .venv/bin/activate\n    pip install -r requirements.txt\n    ```\n\n### Running the Services\n\n1.  **Start the Embedding API:**\n\n    ```bash\n    cd embedding-api\n    python server.py\n    ```\n\n    The gRPC server will start on `localhost:50051`.\n\n2.  **Start the Client API:**\n\n    In a new terminal window:\n\n    ```bash\n    cd client-api\n    npm start\n    ```\n\n    The REST API will be available at `http://localhost:3000`.\n\n## API Reference\n\n### Create a Snippet\n\n-   **Endpoint**: `POST /api/snippets/create`\n-   **Description**: Creates a new code snippet.\n-   **Request Body**:\n\n    ```json\n    {\n        \"code\": \"console.log('Hello, World!');\",\n        \"language\": \"javascript\",\n        \"description\": \"A simple hello world program in JavaScript.\",\n        \"tags\": [\"hello-world\", \"javascript\"]\n    }\n    ```\n\n-   **Response**:\n\n    -   **201 Created**: If the snippet is created successfully.\n    -   **400 Bad Request**: If the request body is invalid.\n\n### Search for a Snippet\n\n-   **Endpoint**: `GET /api/snippets`\n-   **Description**: Searches for code snippets based on a natural language query.\n-   **Note**: This endpoint is currently under development and is not functional.\n-   **Query Parameters**:\n\n    -   `q` (string, required): The natural language search query.\n\n-   **Response**:\n\n    -   **200 OK**: Returns an array of matching snippets.\n    -   **400 Bad Request**: If the `q` query parameter is missing.\n\n## gRPC Service (`embedding.proto`)\n\nThe `embedding-api` exposes a gRPC service for generating vector embeddings.\n\n### Service Definition\n\n```proto\nservice EmbedService {\n  rpc GenerateEmbedding (EmbedRequest) returns (EmbedResponse);\n}\n```\n\n### Messages\n\n```proto\nmessage EmbedRequest {\n  string code = 1;\n  string language = 2;\n  string description = 3;\n  repeated string tags = 4;\n}\n\nmessage EmbedResponse {\n  repeated float embedding = 1;\n}\n```\n\n## Project Structure\n\n```\n.\n├── client-api\n│   ├── src\n│   │   ├── controller\n│   │   ├── middlewares\n│   │   ├── models\n│   │   ├── routes\n│   │   └── ...\n│   ├── package.json\n│   └── ...\n├── embedding-api\n│   ├── gRPCMethods\n│   │   ├── embedding_pb2.py\n│   │   └── embedding_pb2_grpc.py\n│   ├── server.py\n│   └── ...\n├── protos\n│   └── embedding.proto\n└── README.md\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a pull request or open an issue.\n\n## License\n\nThis project is licensed under the MIT License. See the `LICENSE` file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpak-app%2Fai-powered-code-snippet-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpak-app%2Fai-powered-code-snippet-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpak-app%2Fai-powered-code-snippet-search/lists"}