A search engine application built with Node.js, Elasticsearch, and Docker for searching and managing people profiles.
- 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
- Node.js
- Elasticsearch 7.0.1
- Docker & Docker Compose
- TypeScript
- Bun (Package Manager)
Before you begin, ensure you have the following installed:
- Docker and Docker Compose
- Bun (for package management)
- Node.js (version 22 or later)
- Clone the repository:
git clone https://github.com/codesjedi/people-search-engine
cd people-search-engine
- Install dependencies:
bun install
- Start the application using Docker Compose:
docker compose up
The application will be available at:
- API: http://localhost:3000
- Elasticsearch: http://localhost:9200
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
Base URL: http://localhost:3000
GET / Searches for people profiles based on name.
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
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"
}'
People profile schema:
{
name: string;
lastName: string;
age: number;
email: string;
linkedin: string;
profession: string;
country: string;
gender: string;
}
The project uses two Docker containers:
- API Service (Node.js application)
- Elasticsearch Service
Environment variables:
NODE_ENV
: Application environmentES_HOST
: Elasticsearch hostNODE_PORT
: API portELASTIC_URL
: Elasticsearch URL
To run the project in development mode: 1. Start the services:
docker compose up
- For hot-reload during development:
bun run dev