How congdinh2008/vivu-chat-compose works
Main Components
• Frontend Client: This comprises the entire React application (located in src/client). It handles the UI, chat interactions (chat input, message display, model selector, notifications via Toast components), and routing (using Protected and Admin routes).
• Backend Server: Built with Spring Boot (located in src/server), it encapsulates REST controllers (e.g., ChatController, AuthController, AdminController) that manage authentication, chat messaging, and user/account operations. It also implements JWT-based security, manages business logic via services, and interacts with repositories for data persistence.
• Database: PostgreSQL serves as the relational database storage (configured through Spring Data JPA). Include its connection points (datasource configured in application.properties and Docker environment variables).
• AI Model Service (Ollama): This service (with its own Docker setup and configured through OllamaConfig and API controllers) provides the means to connect to various AI models. It interacts with the backend to support real-time chat with dynamic AI model selections.
• Reverse Proxy / NGINX: Serves to host the frontend and possibly route API requests for production deployments.
• Docker Infrastructure: Docker Compose coordinates all these services (frontend, backend, PostgreSQL, Ollama, and NGINX) and their volume management, network configuration, and platform-specific instructions.
Key Relationships and Interactions
• The Frontend Client communicates with the Backend API (via endpoints for authentication, chat operations, and model switching) using HTTP.
• The Backend Server interacts with the PostgreSQL Database for user, chat, and session persistence.
• The Backend also calls out to the Ollama API (or containerized service) to fetch AI responses and model details.
• NGINX acts as the entry point from the internet, directing requests to the appropriate service (static files for the UI, API calls, etc.).
• Docker Compose files define these relationships, ensuring that all services are networked and can access each other.
Important Architectural Patterns and Principles
• Separation of Concerns: The division between frontend delivery (React with its component-based design) and backend business logic (Spring Boot controllers and services) ensures modularity.
• Security Patterns: Use of JWT in Spring Security and proper route guards on the client-side to protect sensitive resources.
• Configuration Management: Environment variable and Docker Compose configuration plays a key role in deploying different stacks (like ARM vs. AMD architectures).
• Microservices-ish Decomposition: Although not a full microservices ecosystem, the clear separation between the frontend, backend, and auxiliary services (AI model and NGINX) can be seen as a multi-container approach that mirrors microservices principles.
Relevant Technologies and Frameworks
• Frontend: ReactJS, TypeScript, TailwindCSS, React Router.
• Backend: Spring Boot 3, Spring Security (JWT), Spring Data JPA, WebFlux.
• Database: PostgreSQL.
• Infrastructure: Docker & Docker Compose, NGINX.
• AI Service Integration: Ollama API (for local AI models).