How willlkhang/chatbot-platform works
1. Overall shape
- This is a polyglot monorepo with multiple independently deployable apps:
- a Next.js frontend
- a Spring Boot microservices backend
- several Python AI/support services
- The backend is organized around a single external entrypoint (the API gateway), while internal services are split by responsibility.
2. Frontend boundary
- frontend/my-fe is the user-facing UI built with Next.js/React and SCSS styling.
- It contains app routes for login, signup, and chat-like UI components.
- Architecturally, it should be drawn as the client that talks outward to backend APIs and, for AI features, may call service endpoints exposed through the backend or directly to supporting services depending on deployment.
3. API edge and routing
- springboot_be/gateway-service is the single backend entrypoint.
- It sits in front of the internal services and handles request routing, so the frontend does not need to know individual service locations.
- springboot_be/discovery-service provides service discovery, and springboot_be/config-service centralizes service configuration for the microservices.
4. Authentication and identity
- springboot_be/authorization-service is the OAuth2/authentication issuer.
- It contains custom password authentication classes and an auth controller, indicating token issuance and login handling are centralized here.
- springboot_be/base-service holds shared auth/domain DTOs such as User, LoginRequest, and UserResponse, suggesting it is a shared contract module rather than a runtime service.
- springboot_be/user-service is the resource-side user profile/registration service; its ResourceServerConfig suggests it validates tokens rather than issuing them.
5. Business services
- springboot_be/chat-service owns chat persistence and chat-message handling.
- springboot_be/personalization-service owns user-specific personalization state.
- These services have the standard Spring layers: controller, service, repository, and domain/model classes, so they should be drawn as separate bounded contexts behind the gateway.
6. Data storage
- The backend is designed to persist business data in Postgres; the repo includes a Docker init script under docker/postgres/init/01-schemas.sql.
- Some Python components use their own embedded stores:
- classifier_app/databases/data/resources.db for SQLite-based classifier data
- ragbot/data/*.sqlite for course/content corpora
- This implies a mixed-storage architecture: Postgres for core backend services, SQLite/files for AI tooling and local corpora.
7. AI / retrieval subsystem
- ragbot is a standalone RAG-style assistant pipeline.
- Its structure includes ingestion, repository, graph/node orchestration, reranking, cosine similarity utilities, prompt templates, and knowledge files.
- The important boundary is that this subsystem is content-driven: it ingests course/knowledge assets from ragbot/knowledge and ragbot/data, then serves retrieval/generation logic to the rest of the system.
8. Classification subsystem
- classifier_app is a separate Python service for text classification.
- It includes controller and database layers, a persisted LinearSVC joblib model, and SQLite-backed resources.
- This should be shown as an AI inference service that can be called over HTTP by the frontend or by other backend components when classification is needed.
9. Document extraction and data preparation
- unit_extractor is a utility service for extracting text from documents.
- It supports multiple source formats: PDF, DOC/DOCX, PPT/PPTX, TXT, and ZIP, then serializes extracted content to JSON or text.
- synthetic_data_generator is a separate offline pipeline that creates training data, likely feeding the classifier or related AI workflows.
- These two are best drawn as preprocessing/ETL tools, not user-facing runtime services.
10. Deployment model
- The repo includes Dockerfiles for the frontend, Python services, and each Spring Boot service, plus a top-level docker-compose.yml.
- That points to a containerized local/dev deployment where the gateway, discovery/config, auth, user, chat, and personalization services are run together with supporting Postgres and AI containers.
- The core architecture diagram should emphasize: UI → gateway → microservices → Postgres, with auth/token issuance as a separate path and AI services as auxiliary backends.
11. Suggested diagram boundaries
- Group the system into four boxes:
- Presentation: Next.js frontend
- Core backend platform: gateway, config, discovery, auth, user, chat, personalization, shared base-service
- Data layer: Postgres plus service-local SQLite/model files
- AI/support services: ragbot, classifier_app, unit_extractor, synthetic_data_generator
- The most important flows are login/token issuance, gateway-routed business requests, and AI-assisted content/query processing.
Main entry points: gateway-service API Gateway · authorization-service Auth Service · 01-schemas.sql Postgres · ICT159_all.sqlite Local AI Stores
Components 15
Presentation
User-facing frontend
- Next.js UI · User-facing web client with login, signup, and chat screens
frontend/my-fe
Core Backend
Spring Boot edge, identity, and business services
- API Gateway · Single backend entrypoint and request router
springboot_be/gateway-service - Config Service · Centralized Spring configuration source
springboot_be/config-service - Discovery · Service registry used by backend services
springboot_be/discovery-service - Auth Service · Authentication and token issuance boundary
springboot_be/authorization-service - User Service · User registration and resource-side account service
springboot_be/user-service - Chat Service · Chat persistence and message handling
springboot_be/chat-service - Personalization · User-specific personalization state and APIs
springboot_be/personalization-service - Base Contracts · Shared domain and DTO definitions for auth and users
springboot_be/base-service
Data Layer
Primary and service-local storage
- Postgres · Primary database for core backend services
docker/postgres/init/01-schemas.sql - Local AI Stores · SQLite corpora, model files, and knowledge assets
ragbot/data/ICT159_all.sqlite
AI Support
Retrieval, classification, and preprocessing services
- RAG Bot · Standalone retrieval and generation pipeline
ragbot - Classifier App · Text classification service with persisted LinearSVC model
classifier_app - Unit Extractor · Document text extraction and serialization pipeline
unit_extractor - Synthetic Data · Offline training data generation pipeline
synthetic_data_generator
Connections 22
- Next.js UI → API Gateway: API calls · Frontend sends application requests through the backend edge
- Next.js UI → Auth Service: login · Authentication flow for issuing tokens
- API Gateway → Discovery: register/lookup · Gateway relies on service discovery for routing
- API Gateway → Config Service: load config · Gateway and peers consume centralized configuration
- API Gateway → Auth Service: auth route · Gateway forwards authentication requests to the issuer
- API Gateway → User Service: user route · Gateway routes user/profile requests
- API Gateway → Chat Service: chat route · Gateway routes chat requests
- API Gateway → Personalization: prefs route · Gateway routes personalization requests
- Auth Service → Base Contracts: shared DTOs · Auth service uses shared login and user contracts
- User Service → Base Contracts: shared DTOs · User service uses shared login and user contracts
- Auth Service → Postgres: auth data · Identity and credential persistence
- User Service → Postgres: user data · Profiles and registration records
- Chat Service → Postgres: chat data · Conversation and message persistence
- Personalization → Postgres: prefs data · Stored personalization state
- RAG Bot → Local AI Stores: knowledge · Retrieval pipeline reads corpora and SQLite assets
- Classifier App → Local AI Stores: model/db · Classifier loads its joblib model and SQLite resources
- Unit Extractor → Local AI Stores: serialized text · Extraction output can feed local corpora and datasets
- Synthetic Data → Local AI Stores: training data · Offline generator produces dataset artifacts
- Unit Extractor → RAG Bot: ingest · Document extraction prepares content for retrieval
- Synthetic Data → Classifier App: train · Generated data can be used to train classification models
- RAG Bot → API Gateway: ai endpoint · AI assistant functionality may be exposed through the backend edge
- Classifier App → API Gateway: ai endpoint · Classification can be invoked through backend-facing APIs