Transform natural language queries into executable API test cases using LLM-powered semantic understanding
Quick Start · Documentation · Docker · Contributing
- Overview
- Features
- Architecture
- Tech Stack
- Quick Start
- Environment Setup
- Docker Deployment
- Development Setup
- API Documentation
- Embedding Models
- LLM Providers
- Testing
- CI/CD
- Project Structure
- Troubleshooting
- Security
- Contributing
- License
NLPForge is an enterprise-grade platform that bridges the gap between natural language and API testing. Describe what you want to test in plain English, and NLPForge processes your request through a two-stage retrieval pipeline to produce structured, executable API test cases.
Input
"Authenticate with email milansoni@nlpforge.com and password secure123"
|
v
NLPForge Processing Pipeline
1. Semantic Understanding ......... Generate query embedding via Ollama
2. Template Matching .............. Vector similarity search in Redis (Top-5)
3. Re-ranking ..................... FlashRank cross-encoder scoring
4. Slot Extraction ................ LLM-powered value extraction
|
v
Output
{
"api_name": "User_Login",
"base_url": "https://api.nlpforge.com",
"endpoint": "/auth/login",
"method": "POST",
"extracted_request_body": {
"email": "milansoni@nlpforge.com",
"password": "secure123"
}
}
- Natural language query processing with multi-model embedding support
- Two-stage retrieval: vector similarity (Stage 1) followed by neural re-ranking (Stage 2)
- Real-time similarity scoring with confidence metrics
- Query filtering by intent, similarity range, and date
- AI-powered synthetic data creation across 8 LLM providers
- Configurable distribution: 70% valid, 20% edge cases, 10% extreme scenarios
- Export to CSV and JSON formats
- Automatic embedding generation on dataset creation
- Postman-style API endpoint builder with slot/parameter definitions
- Minimum 500-word description and 3+ sample utterances per template
- Domain tagging and categorization
- Draft/review/approved workflow with version history
- Real-time KPIs: templates, datasets, embeddings, queries
- Intent distribution visualization and query performance tracking
- Usage statistics and model accuracy monitoring
- JWT authentication with email verification (OTP)
- API keys encrypted at rest (Fernet cipher)
- Multi-tenant data isolation
- Rate limiting (100 req/min per IP via SlowAPI + Redis)
- Full audit logging and activity tracking
- Fully async architecture (asyncio end-to-end)
- Redis vector caching with HNSW indexes
- Background job processing for dataset generation
- Docker Compose orchestration with health checks on all services
graph TB
subgraph BROWSER["<b>CLIENT</b>"]
direction LR
FE["<b>Next.js 16 Frontend</b><br/>React 18 • TypeScript • TailwindCSS"]
end
subgraph DOCKER["<b>DOCKER COMPOSE STACK</b>"]
direction TB
subgraph BACKEND["<b>FastAPI Backend</b> Python 3.11+ • Async"]
direction TB
subgraph ROUTES["API Layer <i>/api/v1/*</i>"]
direction LR
RA["Auth"]
RT["Templates"]
RD["Datasets"]
RE["Embeddings"]
RQ["Query"]
RK["Ranking"]
RC["Config"]
RL["Audit"]
end
subgraph SERVICES["Service Layer <i>20+ async services</i>"]
direction LR
SA["AuthService<br/><i>JWT • bcrypt</i>"]
SB["EmbeddingService"]
SC["MultiModelSemanticService<br/><i>Pipeline Orchestrator</i>"]
SD["DatasetGenerator"]
SE["RankingEngine<br/><i>FlashRank</i>"]
SF["SlotExtraction<br/><i>LLM-powered</i>"]
SG["AuditService"]
end
ROUTES --> SERVICES
end
subgraph AIML["<b>AI / ML Services</b>"]
direction LR
subgraph OLLAMA["Ollama Server"]
OE["Embedding Models<br/><i>nomic-embed-text • bge-m3<br/>mxbai • 15+ models</i>"]
OL["LLM Inference<br/><i>Llama 3.x • Qwen • Mistral</i>"]
end
FR["<b>FlashRank</b><br/><i>ms-marco-MiniLM-L-12-v2</i><br/>Cross-Encoder Reranker"]
end
subgraph LLM_CLOUD["<b>Cloud LLM Providers</b>"]
direction LR
P1["OpenAI<br/><i>GPT-4.1 • o3/o4</i>"]
P2["Google Gemini<br/><i>2.5 Pro/Flash</i>"]
P3["Anthropic<br/><i>Claude 4</i>"]
P4["Grok • DeepSeek<br/>HuggingFace • Custom"]
end
subgraph DATA["<b>Data Layer</b>"]
direction LR
PG[("<b>PostgreSQL 15</b><br/><i>Users • Templates • Datasets<br/>LLM Config • Audit Logs</i>")]
RDS[("<b>Redis Stack 7.2</b><br/><i>Vector Embeddings (HNSW)<br/>KNN Search • Cache</i>")]
end
end
FE <-->|"REST API<br/><i>Axios • JWT Auth</i>"| ROUTES
SB -->|"Generate<br/>embeddings"| OE
SF -->|"Extract<br/>slots"| OL
SE --> FR
SD -->|"Cloud API<br/><i>Encrypted keys</i>"| LLM_CLOUD
SA --> PG
SD --> PG
SG --> PG
SB --> RDS
SC --> RDS
classDef frontend fill:#1a1a2e,stroke:#e94560,stroke-width:2px,color:#eee
classDef backend fill:#16213e,stroke:#0f3460,stroke-width:2px,color:#eee
classDef aiml fill:#0f3460,stroke:#533483,stroke-width:2px,color:#eee
classDef cloud fill:#533483,stroke:#e94560,stroke-width:2px,color:#eee
classDef data fill:#1a1a2e,stroke:#53a8b6,stroke-width:2px,color:#eee
classDef routes fill:#0d2137,stroke:#0f3460,stroke-width:1px,color:#ccc
classDef services fill:#0d2137,stroke:#0f3460,stroke-width:1px,color:#ccc
class FE frontend
class BACKEND,RA,RT,RD,RE,RQ,RK,RC,RL,SA,SB,SC,SD,SE,SF,SG backend
class OLLAMA,OE,OL,FR aiml
class P1,P2,P3,P4 cloud
class PG,RDS data
The core innovation of NLPForge -- combining fast vector recall with precise neural re-ranking for accurate natural-language-to-API matching.
flowchart LR
subgraph INPUT["<b>Input</b>"]
Q["User Query<br/><i>'Authenticate with email<br/>and password secure123'</i>"]
end
subgraph STAGE1["<b>Stage 1 — Vector Similarity</b>"]
direction TB
EMB["Ollama Embedding<br/><i>nomic-embed-text (768-dim)</i>"]
VEC["Redis HNSW Index<br/><i>KNN Search (k=5)</i>"]
S1OUT["Top-5 Candidates<br/><i>Cosine similarity scores</i>"]
EMB --> VEC --> S1OUT
end
subgraph STAGE2["<b>Stage 2 — Neural Re-ranking</b>"]
direction TB
CROSS["FlashRank Cross-Encoder<br/><i>ms-marco-MiniLM-L-12-v2</i>"]
SCORE["Pairwise Scoring<br/><i>Sigmoid → 0.0 – 1.0</i>"]
S2OUT["Re-ranked Results"]
CROSS --> SCORE --> S2OUT
end
subgraph EXTRACT["<b>Slot Extraction</b>"]
direction TB
LLM["LLM Provider<br/><i>Gemini / GPT / Claude / Ollama</i>"]
JSON["Structured JSON<br/><i>endpoint, method, params</i>"]
LLM --> JSON
end
Q --> EMB
S1OUT -->|"Top-5<br/>candidates"| CROSS
S2OUT -->|"Best<br/>match"| LLM
classDef inputStyle fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px,color:#1b5e20
classDef stage1Style fill:#e3f2fd,stroke:#1565c0,stroke-width:2px,color:#0d47a1
classDef stage2Style fill:#fff3e0,stroke:#ef6c00,stroke-width:2px,color:#e65100
classDef extractStyle fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px,color:#4a148c
class Q inputStyle
class EMB,VEC,S1OUT stage1Style
class CROSS,SCORE,S2OUT stage2Style
class LLM,JSON extractStyle
| Stage | Method | Model | Output |
|---|---|---|---|
| Stage 1 | KNN vector similarity search in Redis (HNSW index) | Ollama embedding model (e.g., nomic-embed-text) |
Top-5 candidates scored by cosine similarity |
| Stage 2 | Cross-encoder pairwise ranking | FlashRank ms-marco-MiniLM-L-12-v2 |
Final ranked results with 0–1 relevance scores |
| Extraction | LLM-powered slot filling | Any of 8 supported providers | Structured JSON with endpoint, method, parameters |
See RERANKING_ARCHITECTURE.md and STAGE2_DETAILED_EXPLANATION.md for mathematical details.
Expand full user flow diagram
flowchart TD
subgraph AUTH["Authentication"]
A1[/"New User"/] --> A2{{"Choose Action"}}
A2 -->|New Account| A3["Sign Up"]
A2 -->|Existing User| A4["Sign In"]
A3 --> A5["Verify Email (OTP)"]
A5 --> A6["Account Activated"]
A4 --> A6
A6 --> A7(["Dashboard"])
end
subgraph TEMPLATE["Template Creation"]
A7 --> B1["Navigate to Templates"]
B1 --> B2["Create New Template"]
B2 --> B3["Fill Details<br/><i>API Name • Description (500+ words)<br/>HTTP Method • Endpoint<br/>Parameters • 3+ Samples • Tags</i>"]
B3 --> B4["Save as Draft"]
B4 --> B5["Submit for Review"]
B5 --> B6{{"Expert Review"}}
B6 -->|Approved| B7["Template Approved"]
B6 -->|Rejected| B8["Revise & Resubmit"]
B8 --> B5
end
subgraph SETTINGS["Model Configuration"]
B7 --> C1["Navigate to Settings"]
C1 --> C2["Configure LLM Provider<br/><i>Select provider • Enter API key<br/>Test connection</i>"]
C2 --> C3["LLM Configured"]
C3 --> C4["Configure Embedding Model<br/><i>Download model • Set as default</i>"]
C4 --> C5["Embedding Model Active"]
end
subgraph DATASET["Dataset Generation"]
C5 --> D1["Navigate to Datasets"]
D1 --> D2["Generate New Dataset"]
D2 --> D3["Select Approved Template"]
D3 --> D4["Configure Generation<br/><i>Row count • Prompt • Scenario mix<br/>70% valid • 20% edge • 10% extreme</i>"]
D4 --> D5["Start Generation"]
D5 --> D6["LLM Processing..."]
D6 --> D7["CSV Dataset Created"]
end
subgraph EMBEDDING["Embedding Process"]
D7 --> E1["Embed Dataset"]
E1 --> E2["Generating Vectors..."]
E2 --> E3["Vectors Stored in Redis<br/><i>HNSW index per model</i>"]
E3 --> E4["Dataset Embedded"]
end
subgraph SEARCH["Semantic Search"]
E4 --> F1["Navigate to Query"]
F1 --> F2["Enter Natural Language Query"]
F2 --> F3["Two-Stage Pipeline<br/><i>Stage 1: Vector Similarity (Top-5)<br/>Stage 2: FlashRank Re-ranking</i>"]
F3 --> F4["Results Ranked"]
F4 --> F5["Structured JSON Output"]
end
classDef authStyle fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px,color:#1b5e20
classDef templateStyle fill:#e3f2fd,stroke:#1565c0,stroke-width:2px,color:#0d47a1
classDef settingsStyle fill:#fff3e0,stroke:#ef6c00,stroke-width:2px,color:#e65100
classDef datasetStyle fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px,color:#4a148c
classDef embeddingStyle fill:#e0f7fa,stroke:#00838f,stroke-width:2px,color:#006064
classDef searchStyle fill:#fce4ec,stroke:#c2185b,stroke-width:2px,color:#880e4f
class A1,A2,A3,A4,A5,A6,A7 authStyle
class B1,B2,B3,B4,B5,B6,B7,B8 templateStyle
class C1,C2,C3,C4,C5 settingsStyle
class D1,D2,D3,D4,D5,D6,D7 datasetStyle
class E1,E2,E3,E4 embeddingStyle
class F1,F2,F3,F4,F5 searchStyle
| Phase | Steps | What Happens |
|---|---|---|
| Authentication | Sign Up → Verify Email → Sign In | Create account, confirm via OTP, get JWT token |
| Templates | Create → Fill Details → Submit → Approve | Build API template with 500+ word description, 3+ samples |
| Settings | Configure LLM → Configure Embedding | Set up AI provider keys and select embedding model |
| Datasets | Select Template → Configure → Generate | LLM creates synthetic test data (CSV/JSON) |
| Embedding | Embed Dataset → Store Vectors | Generate embeddings, store in Redis HNSW index |
| Search | Enter Query → Two-Stage Pipeline → Results | Semantic search with vector recall + neural re-ranking |
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | Next.js 16, React 18.3, TypeScript 5, TailwindCSS 3.4, Radix UI | App Router SPA with server components |
| Data Fetching | TanStack Query v5, Axios | Server state management and HTTP client |
| UI/UX | Framer Motion, Recharts, Lucide Icons | Animations, charts, iconography |
| Backend | FastAPI 0.123+, Python 3.11+, Pydantic v2 | Async REST API with validation |
| ORM | SQLAlchemy 2.0 (async), Alembic | Database toolkit and migrations |
| Database | PostgreSQL 15 (asyncpg driver) | Relational data, user accounts, templates |
| Vector DB | Redis Stack 7.2 (HNSW indexes) | Embedding storage and KNN search |
| Embeddings | Ollama (15+ models) | Local embedding generation |
| LLM | 8 providers (OpenAI, Gemini, Anthropic, Grok, DeepSeek, Ollama, HuggingFace, Custom) | Dataset generation and slot extraction |
| Re-ranking | FlashRank (ms-marco-MiniLM-L-12-v2) |
Neural cross-encoder scoring |
| Auth | python-jose (JWT), Passlib (bcrypt), Fernet (API key encryption) | Authentication and secrets management |
| DevOps | Docker Compose, GitHub Actions | Containerization and CI/CD |
| Testing | pytest, Jest, Playwright | Backend unit/integration, frontend unit/E2E |
| Requirement | Minimum | Recommended |
|---|---|---|
| Docker & Docker Compose | v2.0+ | Latest |
| RAM | 8 GB | 16 GB+ |
| Disk Space | 10 GB | 20 GB+ |
| Git | v2.0+ | Latest |
git clone https://github.com/Iammilansoni/NLPFT-2.git
cd NLPFT-2cp Backend/.env.example Backend/.env
cp Frontend/.env.example Frontend/.env.localEdit Backend/.env with your values:
# Generate a secure key:
# python -c "import secrets; print(secrets.token_urlsafe(32))"
SECRET_KEY=your_generated_secret_key_here
# Get from: https://aistudio.google.com/apikey
GEMINI_API_KEY=your_gemini_api_key
# Database passwords
POSTGRES_PASSWORD=your_secure_postgres_password
REDIS_PASSWORD=your_secure_redis_password
# Email (for registration and password reset)
SMTP_USER=your_email@gmail.com
SMTP_PASSWORD=your_gmail_app_passworddocker compose up -d --buildFirst run downloads container images and may take several minutes. Monitor progress:
docker compose logs -f| Service | URL | Credentials |
|---|---|---|
| Web App | http://localhost:3000 | Create new account |
| API Docs (Swagger) | http://localhost:8000/docs | -- |
| API Docs (ReDoc) | http://localhost:8000/redoc | -- |
| pgAdmin | http://localhost:5050 | admin@example.com / admin123 |
| RedisInsight | http://localhost:8001 | -- |
| Redis Commander | http://localhost:8081 | admin / admin123 |
- Register an account at
/auth/registerand verify your email - Create a template defining your API endpoint (500+ word description, 3+ samples)
- Generate a dataset using your preferred LLM provider
- Embed the dataset to create searchable vectors
- Query with natural language to get structured JSON results
| Variable | Required | Description |
|---|---|---|
SECRET_KEY |
Yes | JWT signing key (minimum 32 characters) |
SECRET_KEY_ENCRYPTION |
Yes | Fernet key for API key encryption at rest |
GEMINI_API_KEY |
Yes | Google Gemini API key for dataset generation |
POSTGRES_USER |
Yes | PostgreSQL username (default: nlpforge) |
POSTGRES_PASSWORD |
Yes | PostgreSQL password |
POSTGRES_DB |
Yes | PostgreSQL database name (default: nlpforge) |
REDIS_PASSWORD |
Yes | Redis password |
SMTP_HOST |
Yes | SMTP server host (default: smtp.gmail.com) |
SMTP_PORT |
Yes | SMTP port (default: 587) |
SMTP_USER |
Yes | SMTP username/email |
SMTP_PASSWORD |
Yes | SMTP password (use Gmail App Password) |
OLLAMA_BASE_URL |
No | Ollama server URL (default: http://localhost:11434) |
FRONTEND_URL |
No | Frontend URL for CORS (default: http://localhost:3000) |
CORS_ORIGINS |
No | Comma-separated allowed origins |
LOG_LEVEL |
No | Logging level: DEBUG, INFO, WARNING (default: INFO) |
ENVIRONMENT |
No | development or production |
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_API_URL |
Yes | Backend API base URL (default: http://localhost:8000) |
Note: Never commit
.envfiles with real credentials to version control.
All services run in Docker containers (PostgreSQL, Redis, Ollama, Backend, Frontend, admin tools):
# Start all services
docker compose up -d --build
# View logs
docker compose logs -f
# View logs for a specific service
docker compose logs -f backend
# Check service health
docker compose ps
# Stop services
docker compose down
# Full reset (removes all data)
docker compose down -v && docker compose up -d --build| Service | Port | Description |
|---|---|---|
| Frontend | 3000 | Next.js web application |
| Backend | 8000 | FastAPI server |
| PostgreSQL | 5433 | Database (mapped from 5432) |
| Redis | 6379 | Vector database |
| RedisInsight | 8001 | Redis web UI |
| Redis Commander | 8081 | Redis management |
| pgAdmin | 5050 | PostgreSQL admin |
| Ollama | 11434 | LLM inference (internal to Docker network) |
Use docker-compose.dev.yml to run infrastructure in Docker while developing the application locally with hot reload.
docker compose -f docker-compose.dev.yml up -dollama serve
# In a separate terminal:
ollama pull nomic-embed-text # Recommended embedding model
ollama pull llama3.2:3b-instruct-q4_K_M # LLM for dataset generationcd Backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
alembic upgrade head
uvicorn app.main:app --reload --port 8000cd Frontend
npm install
npm run devThe frontend is available at http://localhost:3000 and the backend API docs at http://localhost:8000/docs.
Interactive documentation is available when the backend is running:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Authentication
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/auth/register |
Register new user |
POST |
/api/v1/auth/login |
User login |
POST |
/api/v1/auth/logout |
User logout |
POST |
/api/v1/auth/refresh |
Refresh access token |
POST |
/api/v1/auth/forgot-password |
Request password reset email |
POST |
/api/v1/auth/reset-password |
Reset password with token |
Templates
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/v1/template-builder/templates |
List all templates |
POST |
/api/v1/template-builder/templates |
Create new template |
GET |
/api/v1/template-builder/templates/{id} |
Get template by ID |
PUT |
/api/v1/template-builder/templates/{id} |
Update template |
DELETE |
/api/v1/template-builder/templates/{id} |
Delete template |
Datasets
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/v1/datasets |
List all datasets |
POST |
/api/v1/datasets/generate |
Generate new dataset |
GET |
/api/v1/datasets/{id} |
Get dataset details |
DELETE |
/api/v1/datasets/{id} |
Delete dataset |
GET |
/api/v1/datasets/{id}/download |
Download dataset (CSV/JSON) |
Query & Search
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/multi-model-query |
Multi-model semantic search |
POST |
/api/v1/embeddings/search |
Vector similarity search |
POST |
/api/v1/ranking/rerank |
Re-rank search results |
Embeddings
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/embeddings/validate |
Validate embedding model |
GET |
/api/v1/embeddings/download |
Download embedding vectors |
Configuration
| Method | Endpoint | Description |
|---|---|---|
GET/PUT |
/api/v1/llm-config |
LLM provider configuration |
GET/PUT |
/api/v1/user-settings |
User embedding preferences |
GET |
/api/v1/audit-logs |
Audit trail |
NLPForge supports 15+ embedding models via Ollama. Choose based on your accuracy, speed, and resource requirements.
| Model | Parameters | Dimensions | Context | Speed | Best For |
|---|---|---|---|---|---|
nomic-embed-text |
137M | 768 | 8192 | Fast | Default -- production RAG, long documents |
all-minilm |
22-33M | 384 | 256 | Fastest | Prototyping, edge devices, low resources |
mxbai-embed-large |
335M | 1024 | 512 | Moderate | State-of-the-art accuracy, enterprise search |
bge-m3 |
567M | 1024 | 8192 | Moderate | Multilingual (100+ languages), hybrid retrieval |
snowflake-arctic-embed |
22-335M | 256-1024 | 512 | Fast | Enterprise retrieval, multiple size options |
qwen3-embedding |
0.6-8B | 1024-4096 | 8192 | Slow | Maximum quality, research workloads |
granite-embedding |
30-278M | 256-768 | 512 | Fast | IBM enterprise, multilingual |
| Model | Parameters | Context | Best For |
|---|---|---|---|
bge-base |
109M | 512 | Balanced performance, general retrieval |
bge-large |
335M | 512 | High accuracy English, QA, semantic search |
nomic-embed-text-v2-moe |
300M (MoE) | 8192 | Multilingual, state-of-the-art |
snowflake-arctic-embed2 |
568M | 8192 | Frontier model, long context |
embeddinggemma |
300M | 2048 | Google ecosystem, versatile |
paraphrase-multilingual |
278M | 512 | 50+ languages, semantic similarity |
- Navigate to Settings > Embedding Model
- Select your preferred model (downloads automatically if not installed)
- Re-embed existing datasets if switching models -- each model produces different vector dimensions
Tip: Start with
nomic-embed-textfor most use cases. Usebge-m3for multilingual content, orqwen3-embedding:8bfor maximum quality.
NLPForge supports 8 LLM providers for dataset generation and slot extraction. All API keys are encrypted at rest.
| Provider | Notable Models | Notes |
|---|---|---|
| OpenAI | GPT-4.1, GPT-4o, o3, o4 | Premium quality, production workloads |
| Google Gemini | Gemini 2.5 Pro/Flash, Gemini 2.0 | High-quality outputs, generous free tier |
| Anthropic | Claude 4, Claude 3.5 Sonnet | Nuanced understanding, safety-focused |
| Grok (xAI) | Grok 3, Grok 4 | Fast reasoning, up to 2M token context |
| DeepSeek | DeepSeek Chat, Coder, R1 | Strong reasoning, code generation |
| Ollama | Llama 3.x, Qwen 2.5, Mistral | Local inference, privacy-first, no API key |
| HuggingFace | Meta Llama, Gemma, Qwen, Mistral | Cloud inference API |
| Custom | Any OpenAI-compatible endpoint | Self-hosted models, custom URLs |
- Navigate to Settings > LLM Providers
- Add your API key for the desired provider
- Select the default provider and model
- Adjust model parameters (temperature, max tokens, etc.)
cd Backend
# Run all unit tests
pytest -v --tb=short -m "not integration"
# Run a specific test
pytest -k test_function_name
# Run with coverage
pytest --cov
# Run integration tests (requires running infrastructure)
pytest -m integrationBackend tests use SQLite in-memory by default (configured in tests/conftest.py). Use @pytest.mark.asyncio for async tests.
cd Frontend
# Jest unit tests
npm test
# Watch mode
npm run test:watch
# Playwright E2E tests
npm run test:e2e
# E2E tests with interactive UI
npm run test:e2e:uiThe project uses GitHub Actions for continuous integration and security auditing.
Runs on push to main/develop and on pull requests to main:
| Job | What it does |
|---|---|
| Backend Lint | Runs Ruff on app/ |
| Backend Tests | Runs pytest (unit tests only, SQLite in-memory) |
| Frontend Build | Runs ESLint and next build |
Runs weekly (Monday 9:00 UTC) and on manual trigger:
| Job | What it does |
|---|---|
| Backend Audit | pip-audit scans Python dependencies for vulnerabilities |
| Frontend Audit | npm audit scans Node.js dependencies for vulnerabilities |
NLPForge/
├── Backend/
│ ├── app/
│ │ ├── api/v1/ # REST API endpoints
│ │ │ ├── auth.py # Authentication (register, login, password reset)
│ │ │ ├── datasets.py # Dataset management & generation
│ │ │ ├── embeddings.py # Embedding operations
│ │ │ ├── embedding_validation.py
│ │ │ ├── email_verification.py
│ │ │ ├── llm_config.py # LLM provider configuration
│ │ │ ├── template_builder.py
│ │ │ ├── ranking.py # Re-ranking service
│ │ │ ├── multi_model_query.py
│ │ │ ├── user_settings.py
│ │ │ ├── audit_logs.py
│ │ │ └── admin.py
│ │ ├── core/ # Configuration and utilities
│ │ │ ├── config.py # Application settings (Pydantic BaseSettings)
│ │ │ ├── security.py # JWT, password hashing, API key encryption
│ │ │ ├── postgres.py # Async database session management
│ │ │ └── logger.py
│ │ ├── models/ # SQLAlchemy ORM models & Pydantic schemas
│ │ │ ├── database_models.py
│ │ │ └── schemas/
│ │ ├── services/ # Business logic layer (20+ async services)
│ │ │ ├── auth_service.py
│ │ │ ├── embedding_service.py
│ │ │ ├── multi_model_semantic_service.py # Pipeline orchestration
│ │ │ ├── redis_vector_service.py # Stage 1: vector search
│ │ │ ├── dataset_service.py
│ │ │ ├── llm_config_service.py
│ │ │ ├── audit_service.py
│ │ │ └── ...
│ │ ├── nlp/ # NLP processing
│ │ │ ├── ranking_engine.py # Stage 2: FlashRank re-ranking
│ │ │ ├── dataset_generator.py # LLM-based dataset creation
│ │ │ └── embedding_manager.py
│ │ ├── llm/ # LLM provider integrations
│ │ │ ├── provider_factory.py # Factory pattern entry point
│ │ │ └── providers/ # OpenAI, Gemini, Anthropic, Grok, etc.
│ │ └── main.py # FastAPI app entry point
│ ├── alembic/ # Database migrations
│ ├── tests/ # pytest test suite
│ ├── requirements.txt
│ └── Dockerfile
│
├── Frontend/
│ ├── app/ # Next.js App Router pages
│ │ ├── auth/ # Login, register, verify email, password reset
│ │ ├── dashboard/ # Main dashboard with KPIs
│ │ ├── templates/ # Template management
│ │ ├── datasets/ # Dataset management & generation wizard
│ │ ├── query/ # Semantic search interface
│ │ ├── settings/ # LLM and embedding model configuration
│ │ └── ... # About, terms, privacy, contact, etc.
│ ├── components/ # Reusable React components
│ │ ├── ui/ # Base components (buttons, cards, dialogs, forms)
│ │ ├── dashboard/ # Dashboard-specific components
│ │ ├── search/ # Search interface components
│ │ ├── datasets/ # Dataset management UI
│ │ ├── settings/ # Settings page components
│ │ └── ...
│ ├── lib/ # API client, types, validators, utilities
│ ├── hooks/ # Custom React hooks
│ ├── contexts/ # React Context providers (Auth, Sidebar)
│ ├── styles/ # Global CSS and theme variables
│ ├── package.json
│ └── Dockerfile
│
├── .github/workflows/ # CI and security audit pipelines
│ ├── ci.yml
│ └── security.yml
├── docker-compose.yml # Production deployment
├── docker-compose.dev.yml # Development (infrastructure only)
├── CLAUDE.md # Developer guidance
├── RERANKING_ARCHITECTURE.md # Two-stage pipeline documentation
├── STAGE2_DETAILED_EXPLANATION.md
└── README.md
Docker: Services fail to start
# Check logs for the failing service
docker compose logs backend
docker compose logs postgres
# Restart everything
docker compose down && docker compose up -d --buildDocker: Port already in use
# Find the process using the port (Linux/Mac)
lsof -i :8000
# Kill it or change the port mapping in docker-compose.ymlDocker: Out of disk space
docker system prune -a --volumesAuth: "SECRET_KEY must be at least 32 characters"
# Generate a secure key
python -c "import secrets; print(secrets.token_urlsafe(32))"
# Paste the output into Backend/.env as SECRET_KEYAuth: "GEMINI_API_KEY not set"
- Visit https://aistudio.google.com/apikey
- Create a new API key
- Add to
Backend/.env:GEMINI_API_KEY=your_key
Ollama: Connection refused
# Check if Ollama is running
curl http://localhost:11434/api/tags
# If using Docker, check the container
docker compose logs ollama
# Start Ollama manually if running outside Docker
ollama serveOllama: Model not found
ollama pull nomic-embed-text
ollama pull llama3.2:3b-instruct-q4_K_MDatabase: PostgreSQL connection fails
docker compose ps postgres
docker compose logs postgres
# Reset database
docker compose down -v
docker compose up -d postgresDatabase: Redis connection fails
docker compose logs redis
# Test connection
docker compose exec redis redis-cli -a <password> pingFrontend: "Failed to fetch" or CORS errors
- Verify the backend is running: http://localhost:8000/docs
- Check
NEXT_PUBLIC_API_URLinFrontend/.env.local - Check that
CORS_ORIGINSinBackend/.envincludes the frontend URL - Inspect the browser console for specific error messages
Frontend: Build fails
docker compose build --no-cache frontend# Stop all services
docker compose down
# Remove all data (destructive)
docker compose down -v
# Remove NLPForge images
docker rmi $(docker images | grep nlpforge | awk '{print $3}')
# Full Docker cleanup
docker system prune -a| Practice | Description |
|---|---|
| JWT Authentication | Tokens signed with SECRET_KEY (minimum 32 characters), stored as HttpOnly cookies |
| API Key Encryption | LLM provider keys encrypted at rest using Fernet (SECRET_KEY_ENCRYPTION) |
| Password Hashing | Bcrypt via Passlib with automatic salt generation |
| Rate Limiting | 100 requests/minute per IP, enforced via SlowAPI with Redis backend |
| Multi-Tenant Isolation | All user data is scoped per-user; no cross-tenant access |
| Audit Logging | All significant actions are logged with timestamps and user context |
| CORS | Configurable allowed origins; defaults to localhost:3000 in development |
| Dependency Auditing | Weekly automated scans via pip-audit and npm audit |
Important: Generate unique
SECRET_KEYandSECRET_KEY_ENCRYPTIONvalues for each environment. Use Gmail App Passwords rather than real account passwords. Change default admin credentials for pgAdmin and Redis Commander in production.
Contributions are welcome. Here's how to get started:
# Fork and clone
git clone https://github.com/YOUR_USERNAME/NLPFT-2.git
cd NLPFT-2
# Set up environment
cp Backend/.env.example Backend/.env
cp Frontend/.env.example Frontend/.env.local
# Start infrastructure
docker compose -f docker-compose.dev.yml up -d
# Create a feature branch
git checkout -b feature/your-feature# Backend
cd Backend && pytest -v
# Frontend
cd Frontend && npm testgit commit -m "feat: add your feature"
git push origin feature/your-feature
# Open a Pull Request on GitHub| Prefix | Description |
|---|---|
feat: |
New feature |
fix: |
Bug fix |
docs: |
Documentation |
style: |
Formatting (no logic change) |
refactor: |
Code restructuring |
test: |
Adding or updating tests |
chore: |
Maintenance and tooling |
This project is licensed under the MIT License. See the LICENSE file for details.
![]() Milan Soni |
![]() Avadhi Singhal |
![]() Abhilash Joshi |


