This is a full-stack web application that allows users to classify objects into two categories based on their textual features. The system learns and improves in real-time from user feedback.
The project consists of a Go backend providing a REST API and a React (TypeScript) frontend. The entire stack, including a MySQL database, is containerized with Docker for easy setup and deployment.
- 🧠 Real-time Learning: The system updates its knowledge base after every user-confirmed classification.
↔️ Feature Separation: Automatically identifies common properties shared between both classes, unique properties for each, and irrelevant ("none") properties.- ⚙️ Flexible Management: The UI allows for adding, removing, moving, and renaming properties and classes on the fly.
- 🚀 Modern Stack: Built with Go for the backend, React/Vite/TS for the frontend, and MySQL for persistence.
- 🐳 Fully Containerized: The entire project runs with a single
docker-compose upcommand.
- Backend: Go,
net/http,go-sql-driver/mysql - Frontend: React, TypeScript, Vite, Nginx (for serving static files)
- Database: MySQL 8.0
- DevOps: Docker, Docker Compose
This is the recommended way to run the project for demonstration or development. Ensure you have Docker and Docker Compose installed.
-
Clone the repository:
git clone https://github.com/AntonHritsai/self-learning-classifier.git cd self-learning-classifier -
Set up environment variables: Create a
.envfile by copying the example. The default values are already configured for local Docker development.cp .env.example .env
-
Launch the project: This command will build the images, start all containers, and set up the network.
docker-compose up --build
-
Access the application:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080
If you prefer to run the services natively, you will need:
- Go 1.22+
- Node.js 20+
- A running MySQL 8.0 instance
- Navigate to the
Backenddirectory:cd Backend - Install dependencies:
go mod tidy
- Set the required environment variables to connect to your MySQL instance. For example:
export DB_HOST=127.0.0.1 export DB_PORT=3306 export DB_USER=your_user export DB_PASSWORD=your_password export DB_NAME=slc
- Run the server:
The backend will be available at
go run ./cmd/api
http://localhost:8080.
- Navigate to the
Frontenddirectory:cd Frontend/slc-frontend - Install dependencies:
npm install
- Create a
.env.localfile and specify the backend API URL:VITE_API_URL=http://localhost:8080 - Run the development server:
The frontend will be available at
npm run dev
http://localhost:5173(or another port specified by Vite).
The Go backend includes a suite of unit tests for handlers, services, and core logic. The tests use in-memory mocks for the repository to ensure isolation and speed.
To run the tests, navigate to the Backend directory and execute:
cd Backend
go test -v ./....
├── Backend/ # Go Backend
│ ├── cmd/api/ # Application entry point
│ ├── internal/ # All business logic
│ └── ...
├── Frontend/
│ └── slc-frontend/ # React Application
│ ├── src/ # Frontend source code
│ └── ...
├── docs/ # Documentation and assets
├── .env.example # Example environment file
└── docker-compose.yml # Orchestration file for all services
The application is configured using environment variables. See .env.example for a complete list. Key variables include:
| Variable | Default | Description |
|---|---|---|
\DB_HOST |
db |
Hostname of the MySQL database service. |
\DB_USER |
slc |
MySQL user. |
\MYSQL_PASSWORD |
slcpass |
Password for the MySQL user. |
\DB_NAME |
self-learning-classifier |
Name of the database. |
\BACKEND_PORT |
8080 |
Port on which the Go backend listens. |
\FRONTEND_PORT |
3000 |
Port on which the Nginx frontend is exposed. |
\VITE_API_URL |
http://localhost:8080\ |
URL of the backend API for the frontend to use. |
Base URL: /api/v1
| Method | Path | Description |
|---|---|---|
\POST |
/init |
Initializes the classes and their seed properties. |
\POST |
/reset |
Resets the state for the current user. |
\POST |
/classify |
Classifies a given set of properties. |
\POST |
/feedback |
Provides feedback to train the model. |
\GET |
/state |
Retrieves the current state of the classifier. |
\POST |
/prop/add |
Adds a new property to a specific area. |
\POST |
/prop/remove |
Removes a property from a specific area. |
\POST |
/prop/move |
Moves a property between areas. |
\POST |
/prop/rename |
Renames a property within an area or globally. |
\POST |
/classes/rename |
Renames a class. |
\GET |
/status |
Health check endpoint. |
