This project is a lightweight chat client designed to run local AI models via Ollama. The entire stack is containerized using Docker and runs on top of lightweight Alpine Linux images.
- Docker and Docker Compose installed on your host machine.
- Ollama installed locally on your PC
By default, Ollama on Linux only listens on 127.0.0.1 (localhost). To allow the backend Docker container to communicate with it, configure Ollama to accept connections from the Docker network:
-
Create a service override configuration file:
sudo mkdir -p /etc/systemd/system/ollama.service.d && echo -e "[Service]\nEnvironment=\"OLLAMA_HOST=0.0.0.0\"" | sudo tee /etc/systemd/system/ollama.service.d/override.conf
-
Apply the configuration changes and restart the Ollama service:
sudo systemctl daemon-reload && sudo systemctl restart ollama -
Verify that Ollama is listening on all network interfaces:
ss -tlnp | grep 11434You should see
*:11434or0.0.0.0:11434instead of127.0.0.1:11434. -
Allow port 11434 in your Firewall (if UFW / firewalld is active): If UFW is active, incoming connections from Docker containers to port 11434 will be blocked by default. Allow the port:
sudo ufw allow 11434/tcp
- change file name from .env-test to .env
2.in file put your data
test_DB_HOST=
test_DB_PORT=
test_DB_USER=
test_DB_PASS=
test_DB_NAME=
SECRET_KEY =
ALGORITHM = HS256
ACCESS_TOKEN_EXPIRE_MINUTES = 3200Run the build and start all services in the background:
docker compose up -dUpon initial startup, Docker will automatically:
- Pull the required Alpine-based images.
- Build the React frontend in a temporary container and copy the static assets to Caddy.
- Verify PostgreSQL and Redis readiness via built-in healthchecks.
- Run database migrations using Alembic.
- Spin up Prometheus, Grafana, and Loki with pre-configured settings.
Once successfully started, the services will be accessible at the following URLs:
| Service | Browser URL | Description |
|---|---|---|
| AI Chat (Frontend) | 🌐 http://localhost | Caddy serves the React application on the standard port 80. |
| API Documentation | 📖 http://localhost/docs | Interactive Swagger UI for testing API endpoints. |
| Grafana | 📊 http://localhost:3000 | Metrics dashboard. Automatically logs in as Admin. |
| Prometheus | ⏱️ http://localhost:9090 | Time-series database containing metrics. |
| adminer | 💻 http://localhost:8080/ | admin panel in browser. |
Monitoring dashboards are set up and imported automatically:
- Open Grafana (http://localhost:3000).
- Navigate to Dashboards in the left sidebar.
- Open the Application folder and select AIWEBHOST Chat Dashboard.
- You will see real-time charts displaying:
- User activity and message count.
- Response latency from Ollama models.
- Redis cache hits/misses and PostgreSQL database metrics.
convenient admin panel in your browser
- Open Adminer (http://localhost:8080).
- Login using:
- System: PostgreSQL
- Server: db
- User: postgres
- Password: 1
- Database: ai-slop
- Check container status:
docker compose ps
- Stream backend logs in real-time:
docker compose logs -f backend
- Restart a specific service (e.g., Caddy):
docker compose restart caddy
- Rebuild the project after code changes:
docker compose up --build -d
- Stop and remove all containers:
docker compose down
To prevent conflicts with services that might already be running on your local machine:
- Redis inside Docker does not expose port
6379to the host. The backend container communicates with it directly inside the internal Docker network. - PostgreSQL is forwarded to port
5433on the host machine (instead of the standard5432). If you need to connect to the database directly from PyCharm, pgAdmin, or another client, use port5433(username:postgres, password:1, database:aiwebhost).
- Backend (FastAPI): Built by me (exception:
send_messageendpoint there AI helped with images). - Frontend (Vite + React): Fully vibecoded
- DevOps (Docker, Caddy, Grafana, Prometheus): AI helped with configuration.
AI Tools & Skills Used: