A Node.js system that uses Ollama local AI to apply business rules to text using natural language processing and intelligent analysis.
- Node.js 16+
- Ollama installed and running locally
- llama3 model downloaded in Ollama
# Install dependencies
npm install
# Verify Ollama is running
curl http://localhost:11434/api/tags
# Download llama3 model
ollama pull llama3
# Check available models
ollama list
# Install all dependencies
npm run setup-frontend
# Start both backend and frontend
npm run start-all
This will start both the backend (port 3001) and frontend (port 5173).
# Start backend server
PORT=3001 npm run server
# In another terminal, start frontend
cd frontend
npm run dev
Then open http://localhost:5173 in your browser for a beautiful web interface.
npm start
# Development
PORT=3001 npm run dev
# Production
PORT=3001 npm run server
The project includes a beautiful Vue 3 + Tailwind CSS frontend located in the frontend/
directory.
- π¨ Modern, responsive design with Tailwind CSS v3
- β‘ Real-time text analysis
- π Server status monitoring
- π Clear error handling and loading states
- π Display of active business rules
- π CORS-enabled communication with backend
cd frontend
npm install
npm run dev
The frontend will be available at http://localhost:5173
Evaluates input using defined rules.
Request:
{
"input": "Text to analyze"
}
Response:
{
"success": true,
"input": "Text to analyze",
"result": "Analysis result from AI",
"timestamp": "2025-08-25T15:17:31.598Z"
}
Server health check.
API documentation and information.
Request:
{
"input": "John Silva has email [email protected]"
}
Response:
{
"success": true,
"input": "John Silva has email [email protected]",
"result": "Status: APPROVED\nObservations: Valid email...",
"timestamp": "2025-08-25T10:00:00.000Z"
}
Service health check.
API documentation.
The rules are defined in rules.txt
and include:
- Email validation
- Numeric limit verification
- Date validation
- Code detection
- Format analysis
To modify rules, edit the rules.txt
file and restart the service.
local-rules-engine/
βββ src/
β βββ index.js # Main RulesEngine class
β βββ server.js # Express REST server
β βββ services/
β βββ ollamaService.js # Ollama communication service
βββ rules.txt # Business rules in natural language
βββ package.json # Project configuration
βββ README.md # This file
# Install dependencies
npm install
# Run in development mode
npm run dev
# Run CLI version
npm start
# Run server
npm run server
- Load Rules: The system reads business rules from
rules.txt
- Process Input: User input is combined with rules to form a prompt
- AI Analysis: The prompt is sent to Ollama's llama3 model
- Return Results: The AI's analysis is returned to the user
The system can analyze:
- Email format validation
- Numeric ranges (0-1000)
- Date formats (DD/MM/YYYY)
- Text formatting issues
- Code language detection
- Business logic compliance
- Ollama must be running on
localhost:11434
- llama3 model must be available
- Node.js ES modules support (type: "module" in package.json)
MIT