Skip to content

codesjedi/people-search-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

People Search Engine

A search engine application built with Node.js, Elasticsearch, and Docker for searching and managing people profiles.

🚀 Features

  • Full-text search capabilities for people profiles
  • RESTful API endpoints
  • Elasticsearch integration for efficient searching
  • Docker containerization for easy deployment
  • TypeScript implementation for type safety

🛠️ Tech Stack

  • Node.js
  • Elasticsearch 7.0.1
  • Docker & Docker Compose
  • TypeScript
  • Bun (Package Manager)

📋 Prerequisites

Before you begin, ensure you have the following installed:

  • Docker and Docker Compose
  • Bun (for package management)
  • Node.js (version 22 or later)

🔧 Installation

  1. Clone the repository:
git clone https://github.com/codesjedi/people-search-engine
cd people-search-engine
  1. Install dependencies:
bun install
  1. Start the application using Docker Compose:
docker compose up

The application will be available at:

🏗️ Project Structure

people-search-engine/
├── src/
│   ├── elastic.ts        # Elasticsearch configuration and utilities
│   └── index.ts         # Main application entry point
├── Dockerfile           # Docker configuration for the API
├── docker-compose.yml   # Docker Compose configuration
├── package.json        # Project dependencies and scripts
└── README.md           # Project documentation

🔍 API Endpoints

Base URL: http://localhost:3000

Endpoints

Search Profiles

GET / Searches for people profiles based on name.

Query Parameters

Parameter Type Required Description
name string yes Name to search for
{
  "success": true,
  "data": [
    {
      "name": "string",
      "lastName": "string",
      "age": "number",
      "email": "string",
      "linkedin": "string",
      "profession": "string",
      "country": "string",
      "gender": "string"
    }
  ]
}

Error Response (422 Unprocessed Entity)

{
  "error": true,
  "data": "Missing required parameter 'name'"
}

Add New Profile

POST / Creates a new person profile. Request Body

{
  "name": "string",      // required
  "lastName": "string",  // required
  "age": "number",       // optional
  "email": "string",     // optional
  "linkedin": "string",  // optional
  "profession": "string",// optional
  "country": "string",   // optional
  "gender": "string"     // optional
}

Success Response (200 OK)

{
  "success": true,
  "data": {
    // Created profile data
  }
}

Error Responses 422 Unprocessed Entity

{
  "error": true,
  "data": "Missing required parameter 'name' or 'lastName'"
}

500 Internal Server Error

{
  "success": false,
  "data": "Unknown error"
}

Error Handling

The API returns appropriate HTTP status codes and error messages:

  • 200: Successful operation
  • 422: Missing required parameters
  • 500: Server error

Example Requests

Search for a Profile

curl -X GET 'http://localhost:3000/?name=John'

Create a New Profile

curl -X POST http://localhost:3000/ \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "John",
    "lastName": "Doe",
    "age": 30,
    "email": "[email protected]",
    "profession": "Developer",
    "country": "USA",
    "gender": "male"
  }'

💾 Data Model

People profile schema:

{
  name: string;
  lastName: string;
  age: number;
  email: string;
  linkedin: string;
  profession: string;
  country: string;
  gender: string;
}

🐳 Docker Configuration

The project uses two Docker containers:

  1. API Service (Node.js application)
  2. Elasticsearch Service

Environment variables:

  • NODE_ENV: Application environment
  • ES_HOST: Elasticsearch host
  • NODE_PORT: API port
  • ELASTIC_URL: Elasticsearch URL

🛠️ Development

To run the project in development mode: 1. Start the services:

docker compose up
  1. For hot-reload during development:
bun run dev

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published