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
Expected output:
Loading training data...
Training samples: 330
Unique numbers: [1, 2, 3, ..., 33]
...
Training accuracy: 0.xxx
Model saved to .../numerology_model.pkl
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"
The backend will start at: http://localhost:5000
You should see:
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
cd frontend
npm run dev
The frontend will start at: http://localhost:5173
Access the GraphQL API directly at: http://localhost:5000/graphql
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"
}
}
}
}
Edit frontend/src/lib/graphql.js:
export const client = new Client({
url: 'http://localhost:5000/graphql',
// ...
});
Edit backend/NumerologyAPI/Program.cs:
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.WithOrigins("http://localhost:5173") // Frontend URL
.AllowAnyHeader()
.AllowAnyMethod();
});
});
Error: python: command not found
Solution: Use python3 instead. Update PredictionService.cs:
FileName = "python3", // Change from "python" to "python3"
Error: Model not found. Please train the model first.
Solution:
cd ML
python3 train_model.py
Error: Address already in use
Solution: Change the port in appsettings.json or kill the process:
# Find the process
lsof -i :5000
# Kill it
kill -9 <PID>
Error: Access to fetch at 'http://localhost:5000/graphql' from origin 'http://localhost:5173' has been blocked by CORS policy
Solution: Verify CORS configuration in Program.cs matches your frontend URL.
Error: SQLite Error: database is locked
Solution: Close any database connections and restart the backend:
rm backend/NumerologyAPI/numerology.db
dotnet run --urls "http://localhost:5000"
Problem: Model predicts mostly the same numbers
Solution: Add more varied training data to 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.
The SQLite database is created automatically at:
backend/NumerologyAPI/numerology.db
To reset the database:
rm backend/NumerologyAPI/numerology.db
dotnet run
cd frontend
npm run build
Output will be in frontend/dist/
cd backend/NumerologyAPI
dotnet publish -c Release -o ./publish
Output will be in backend/NumerologyAPI/publish/
This project is provided as-is for educational and personal use.