Skip to content

Emin-ACIKGOZ/Micro-AI-Chat-App

Repository files navigation

This project describes a comprehensive chat application that integrates a Spring Boot backend, a React frontend, a PostgreSQL database, and the Ollama AI service, all orchestrated with Docker Compose.

Prerequisites

Before setting up the Chat App, ensure you have the following installed:

  • Docker and Docker Compose: For containerization and service management.
  • Maven: For building the Spring Boot backend.
  • JDK 21: For compiling and running the Java Spring Boot backend.
  • Node.js: For frontend development tasks (e.g., npm install, npm start outside Docker).

Setup and Run

Follow these steps to get your Chat App running:

  1. Build and Package Backend: Whenever you modify the Spring Boot backend code, execute the following command to build and package it:

    mvn clean package
  2. Start Services: Navigate to the project root directory (where docker-compose.yml is located) and run:

    docker-compose up --build

    This command will build and start all services:

    • Backend: Accessible on port 8080 (Spring Boot, JDK 21).
    • Frontend: Accessible on port 3000 (Node.js, React).
    • Ollama AI Service: Accessible on port 11434.
    • PostgreSQL Database: Accessible on port 5432.
  3. Apply Backend Changes: After rebuilding your Spring Boot backend with Maven, rebuild and restart only the backend container to apply the updates:

    docker-compose build backend
    docker-compose up -d backend
  4. Apply Frontend Changes: If you make changes to the Node.js/React frontend code, you'll need to rebuild and restart its container to see the updates:

    docker-compose build frontend
    docker-compose up -d frontend

Environment Variables

Configure the following environment variables for proper service operation:

  • Backend (Spring Boot):
    • SPRING_DATASOURCE_URL: JDBC URL for PostgreSQL database connection.
    • SPRING_DATASOURCE_USERNAME: Username for database authentication.
    • SPRING_DATASOURCE_PASSWORD: Password for database authentication.
  • Frontend (Node.js/React):
    • REACT_APP_BACKEND_URL: The URL of the backend service.

Volumes and Persistence

Data persistence is managed through Docker volumes:

  • ollama-data: Ensures persistence of Ollama AI service data.
  • postgres-data: Persists PostgreSQL database data.
  • Database initialization is handled by the ./user-manager-database/init.sql script.

Network

All services communicate over a dedicated Docker bridge network named app-network.

Ports

The following ports are exposed by the services:

Service Port
Backend 8080
Frontend 3000
Ollama 11434
Database 5432

Notes

  • Ensure that ports 8080, 3000, 11434, and 5432 are not in use by other applications before starting the services.
  • To stop and remove all containers, networks, and volumes defined in docker-compose.yml, use docker-compose down.
  • For any code changes in the frontend (Node.js/React) or backend (Spring Boot/JDK 21), remember to rebuild their respective Docker images and restart their containers to apply the updates.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors