A comprehensive web indexing and search platform built with .NET 9, Next.js, TypeSense, and MassTransit for event-driven architecture.
This project follows a microservices architecture with the following components:
- WebIndexer Gateway (Port 5106) - API Gateway using YARP reverse proxy
- WebIndexer API (Port 5237) - Main API service with PostgreSQL database
- WebIndexer Search (Port 5062) - Search service with TypeSense integration
- Web Indexer UI - Next.js frontend application
- Shared Kernel - Shared domain library
Before running the application, ensure you have the following installed:
- .NET 9 SDK
- Node.js 18+
- pnpm (recommended) or npm
- PostgreSQL 15+
- RabbitMQ
- TypeSense
# Install PostgreSQL and create database
createdb WebIndexer
# Or using psql:
psql -U postgres
CREATE DATABASE WebIndexer;
CREATE USER admin WITH PASSWORD 'admin123';
GRANT ALL PRIVILEGES ON DATABASE WebIndexer TO admin;# Using Docker (recommended)
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
# Or install locally and start service
# Windows: Start RabbitMQ service
# Linux/Mac: sudo systemctl start rabbitmq-server# Using Docker (recommended)
docker run -d --name typesense -p 8108:8108 -v/tmp/typesense-data:/data typesense/typesense:0.25.1 --data-dir /data --api-key=mysecretapikey --listen-port 8108 --enable-cors
# Or install locally
# Follow TypeSense installation guide for your OSsrc/
├── Frontend/
│ └── web-indexer-ui/ # Next.js frontend application
├── SharedKernel/
│ └── SharedKernel/ # Shared domain library (NuGet package)
├── WebIndexer/
│ └── WebIndexer/ # Main API service
├── WebIndexerGateway/
│ └── WebIndexerGateway/ # API Gateway service
└── WebIndexerSearch/
└── WebIndexerSearch/ # Search service
First, build and pack the shared kernel library:
cd src/SharedKernel/SharedKernel
dotnet packThis creates the WebIndexer.SharedKernel.1.0.0.nupkg file that other services depend on.
Make sure PostgreSQL, RabbitMQ, and TypeSense are running:
# Start PostgreSQL (if not running as service)
# Windows: Start PostgreSQL service
# Linux/Mac: sudo systemctl start postgresql
# Start RabbitMQ (if using Docker)
docker start rabbitmq
# Start TypeSense (if using Docker)
docker start typesenseOpen multiple terminal windows and run each service:
cd src/WebIndexer/WebIndexer
dotnet restore
dotnet ef database update # Apply database migrations
dotnet runService URL: http://localhost:5237
cd src/WebIndexerSearch/WebIndexerSearch
dotnet restore
dotnet runService URL: http://localhost:5062
cd src/WebIndexerGateway/WebIndexerGateway
dotnet restore
dotnet runService URL: http://localhost:5106
cd src/Frontend/web-indexer-ui
pnpm install
pnpm devFrontend URL: http://localhost:3000
- Base URL: http://localhost:5106
- Health Check: GET
/health - Gateway Info: GET
/ - Search API: GET
/api/search?query={query}&page={page}&perPage={perPage} - Search Stats: GET
/api/search/stats - Create Website: POST
/websites
- Base URL: http://localhost:5237
- Create Website: POST
/websites
- Base URL: http://localhost:5062
- Search: GET
/api/search?query={query}&page={page}&perPage={perPage} - Stats: GET
/api/search/stats - Swagger UI: http://localhost:5062/swagger
The main API service uses PostgreSQL with the following connection string:
Host=localhost;Database=WebIndexer;Username=admin;Password=admin123
All services use RabbitMQ with default credentials:
- Host: localhost
- Username: guest
- Password: guest
The search service connects to TypeSense with:
- Host: localhost
- Port: 8108
- API Key: mysecretapikey
- Protocol: http
When making changes to the database schema:
cd src/WebIndexer/WebIndexer
dotnet ef migrations add MigrationName
dotnet ef database updateUse the provided .http files to test endpoints:
src/WebIndexer/WebIndexer/WebIndexer.http- Test main APIsrc/WebIndexerGateway/WebIndexerGateway/WebIndexerGateway.http- Test gatewaysrc/WebIndexerSearch/WebIndexerSearch/WebIndexerSearch.http- Test search service
The Next.js frontend is configured to connect to the gateway at http://localhost:5106. The API service configuration is in src/Frontend/web-indexer-ui/app/services/api.ts.
-
Database Connection Failed
- Ensure PostgreSQL is running
- Verify connection string in
appsettings.json - Check if database and user exist
-
RabbitMQ Connection Failed
- Ensure RabbitMQ is running
- Check if port 5672 is available
- Verify credentials in configuration
-
TypeSense Connection Failed
- Ensure TypeSense is running on port 8108
- Check API key configuration
- Verify CORS settings
-
Port Already in Use
- Check if another instance is running
- Use
netstat -an | findstr :PORT(Windows) orlsof -i :PORT(Mac/Linux) - Kill the process or change port in
launchSettings.json
-
Shared Kernel Package Not Found
- Ensure you've built the shared kernel package first
- Run
dotnet packin the SharedKernel directory - Check if the
.nupkgfile exists in thenupkgsfolder
The services have the following startup order dependencies:
- External services (PostgreSQL, RabbitMQ, TypeSense)
- WebIndexer API (creates database schema)
- WebIndexer Search (creates TypeSense collections)
- WebIndexer Gateway (proxies to other services)
- Frontend (connects to gateway)
- Each service logs to console with different log levels
- Check individual service logs for specific errors
- Use Swagger UI at http://localhost:5062/swagger for search service testing
- Gateway provides detailed request/response logging
For production deployment, consider:
- Environment Variables: Replace hardcoded values with environment variables
- Docker Containers: Containerize each service for easier deployment
- Load Balancing: Use a proper load balancer instead of YARP for production
- Security: Implement proper authentication and authorization
- Monitoring: Add application monitoring and health checks
- SSL/TLS: Configure HTTPS for all services
- Backend: .NET 9, ASP.NET Core, Entity Framework Core
- Database: PostgreSQL
- Search: TypeSense
- Message Broker: RabbitMQ with MassTransit
- API Gateway: YARP (Yet Another Reverse Proxy)
- Frontend: Next.js 15, React 19, TypeScript, Tailwind CSS
- Package Manager: pnpm
- Architecture: Microservices, Domain-Driven Design (DDD), CQRS