Study guide
Every feature works on this PC with Java and SQL Server only - no cloud AI service, no API key. Read the classes in the order shown; the comments at the top of each class explain the idea.
How a request flows
core/TenantFilterfinds the company (sub-domain or the user you act as) and puts it inTenantContext.core/TenantIdentifierResolvergives that id to Hibernate: every entity with@TenantIdis filtered automatically.core/GlobalModelAdviceadds the company's branding (#509) and the menu to every page.- The feature's controller calls its service; services use JPA repositories or
JdbcTemplate(always withtenant_id = ?). - Templates ask feature flags (#507) with
${@featureFlags.on('key')}.
Run, reset, test
Run:
mvnw spring-boot:run -Dspring-boot.run.profiles=localReset the demo data: run
database/reset-database.sql, then restart.Tests:
mvnw test (OCR accuracy, face recognition, NL parser, statistics, sentiment ...).Sub-domain tenant: open
http://siamsport.localhost:PORT/ - the browser sends *.localhost to this PC.| # | Feature | Technique | Read these classes |
|---|---|---|---|
| 496 | AI Chatbot | Intent rules + TF-IDF cosine similarity over knowledge-base articles | chatbot/ChatbotServicechatbot/TfIdfIndexcore/Text |
| 497 | AI Auto-fill | Regular expressions + heuristics + date parsing, scored per field | autofill/AutoFillServiceautofill/LeadController |
| 498 | OCR | Otsu threshold, line projection, connected components, template matching against rendered fonts | ocr/OcrEngineocr/GlyphLibraryocr/SampleImageService |
| 499 | Face Recognition | Local Binary Pattern Histograms (LBPH) + chi-square distance + threshold | face/LbphRecognizerface/FaceServiceface/SyntheticFaces |
| 500 | Recommendation Engine | Item-based collaborative filtering (cosine) + content similarity + popularity fallback | recommend/RecommendationService |
| 501 | Predictive Analytics | Holt-Winters seasonal smoothing, linear regression, logistic regression (gradient descent) | predict/ForecastServicepredict/ChurnModel |
| 502 | Natural Language Search | Rule-based parser: vocabulary from the database, number/compare phrases, sort words | nlsearch/QueryParsernlsearch/NlSearchService |
| 503 | Document Intelligence | Keyword classifier + field extractors + arithmetic validation; PDFBox for PDF text | docintel/DocumentAnalyzerdocintel/SampleDocuments |
| 504 | Sentiment Analysis | Lexicon with negation and intensifiers + Naive Bayes trained on labelled reviews | sentiment/SentimentAnalyzersentiment/NaiveBayessentiment/Lexicon |
| 505 | Anomaly Detection | Robust z-score (median / MAD), hour-of-day rarity, velocity window, rolling 3-sigma band | anomaly/AnomalyDetectoranomaly/AnomalyService |
| 506 | A/B Testing | Hash bucketing (FNV-1a), two-proportion z-test, confidence intervals, sample size | abtest/AbTestServiceabtest/Stats |
| 507 | Feature Flags | Rule evaluation with reasons, sticky percentage buckets, audit log | flags/FeatureFlagServiceflags/FlagController |
| 508 | Multi-tenant | Hibernate @TenantId + CurrentTenantIdentifierResolver + sub-domain / session resolution | core/TenantFiltercore/TenantIdentifierResolvertenancy/TenantService |
| 509 | White-label | Per-tenant CSS custom properties, validated colours, contrast check | branding/BrandingServicebranding/BrandingController |
| 510 | Geofencing | Haversine distance for circles, ray casting for polygons, state change events | geofence/GeoMathgeofence/GeofenceService |