A full-stack web application that predicts numerology numbers (1-33) based on keywords or text input using machine learning. Built with Svelte frontend, ASP.NET Core backend with GraphQL API, and scikit-learn for ML predictions.
numerology-classifier-graphql/
├── backend/
│ └── NumerologyAPI/
│ ├── Program.cs # Main entry point
│ ├── appsettings.json # Configuration
│ ├── NumerologyAPI.csproj # Project file
│ ├── Models/
│ │ └── Prediction.cs # Data model
│ ├── Data/
│ │ └── AppDbContext.cs # Database context
│ ├── GraphQL/
│ │ ├── Query.cs # GraphQL queries
│ │ ├── Mutation.cs # GraphQL mutations
│ │ └── Types/
│ │ └── PredictionType.cs # GraphQL type
│ └── Services/
│ └── PredictionService.cs # ML service
├── frontend/
│ ├── package.json # Dependencies
│ ├── vite.config.js # Vite config
│ ├── svelte.config.js # Svelte config
│ └── src/
│ ├── main.js # Entry point
│ ├── app.css # Global styles
│ ├── App.svelte # Root component
│ ├── routes/
│ │ ├── Predict.svelte # Prediction page
│ │ └── History.svelte # History page
│ └── lib/
│ └── graphql.js # GraphQL client
├── ML/
│ ├── train_data.csv # Training dataset (330 rows)
│ ├── train_model.py # Model training script
│ ├── predict.py # Prediction script
│ ├── requirements.txt # Python dependencies
│ └── numerology_model.pkl # Trained model (generated)
└── README.md # This file
git clone <repository-url>
cd numerology-classifier-graphql
cd ML
pip install -r requirements.txt
python3 train_model.py
cd ../backend
dotnet new webapi -n NumerologyAPI
cd NumerologyAPI
Install required NuGet packages:
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package HotChocolate.AspNetCore
dotnet add package HotChocolate.Data.EntityFramework
Copy all the C# files into their respective folders, then:
dotnet restore
dotnet build
cd ../../frontend
npm install
cd backend/NumerologyAPI
dotnet run --urls "http://localhost:5000"
cd frontend
npm run dev
Get all predictions:
query {
predictions {
id
inputText
predictedNumber
timestamp
}
}
Create a new prediction:
mutation {
addPrediction(inputText: "love harmony balance") {
id
inputText
predictedNumber
timestamp
}
}
type Query {
predictions: [Prediction!]!
prediction(id: Int!): Prediction
}
type Mutation {
addPrediction(inputText: String!): Prediction!
}
type Prediction {
id: Int!
inputText: String!
predictedNumber: Int!
timestamp: DateTime!
}
If you modify train_data.csv:
cd ML
python3 train_model.py
Then restart the backend to use the new model.
Edit backend/NumerologyAPI/appsettings.json:
{
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://localhost:5000"
}
}
}
}
frontend/src/lib/graphql.js:export const client = new Client({
url: 'http://localhost:5000/graphql',
// ...
});
backend/NumerologyAPI/Program.cs:builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.WithOrigins("http://localhost:5173") // Frontend URL
.AllowAnyHeader()
.AllowAnyMethod();
});
});
python: command not foundpython3 instead. Update PredictionService.cs:FileName = "python3", // Change from "python" to "python3"
Model not found. Please train the model first.Solution:
cd ML
python3 train_model.py
Address already in useappsettings.json or kill the process:# Find the process
lsof -i :5000
# Kill it
kill -9 <PID>
Access to fetch at 'http://localhost:5000/graphql' from origin 'http://localhost:5173' has been blocked by CORS policyProgram.cs matches your frontend URL.SQLite Error: database is lockedrm backend/NumerologyAPI/numerology.db
dotnet run --urls "http://localhost:5000"
train_data.csv and retrain:cd ML
python3 train_model.py
ML/train_data.csvnumber,keywordspython3 train_model.pyFrontend files are in frontend/src/:
App.svelte - Main layout and navigationroutes/Predict.svelte - Prediction interfaceroutes/History.svelte - History displayapp.css - Global stylesAfter changes, Vite will hot-reload automatically.
rm backend/NumerologyAPI/numerology.db
dotnet run
cd frontend
npm run build
frontend/dist/cd backend/NumerologyAPI
dotnet publish -c Release -o ./publish
backend/NumerologyAPI/publish/