In this tutorial we will setup three containers:
- api-service
- frontend-simple
- frontend-react
- vector-db
- Have Docker installed
This tutorial covers setting up three main components:
- A Python container for our API services
- A web server container for the frontend
- A vector database container for RAG (Retrieval Augmented Generation)
Each container will run in isolation but communicate with each other to create our complete cheese application.
- Clone or download from here
It is important to note that we do not want any secure information in Git. So we will manage these files outside of the git folder. At the same level as the cheese-app-v2
folder create a folder called secrets. Add the secret file from the ml-workflow
tutorial.
Your folder structure should look like this:
|-cheese-app-v2
|-images
|-src
|---api-service
|---frontend-simple
|---frontend-react
|---vector-db
|-secrets
|-persistent-folder
We will set up and initialize our vector database with cheese-related content for Retrieval Augmented Generation (RAG).
- Navigate to the vector-db directory:
cd cheese-app-v2/src/vector-db
- Build and run the container:
sh docker-shell.sh
- Initialize the database. Run this within the docker shell:
python cli.py --download --load --chunk_type recursive-split
This process will:
- Download the cheese knowledge base (chunks + embeddings)
- Load everything into the vector database for RAG functionality
Note: This step is crucial for enabling our cheese assistant to provide accurate, knowledge-based responses.
Keep this container running while setting up the backend API service and frontend apps.
We will create a backend container running a FastAPI-based REST API service.
- Navigate to API Service Directory
cd cheese-app-v2/src/api-service
- Build & Run Container
sh docker-shell.sh
- Review Container Configuration
- Check
docker-shell.sh
:- Port mapping:
-p 9000:9000
- Development mode:
-e DEV=1
- Port mapping:
- Check
docker-entrypoint.sh
: Dev vs. Production settings
- Start the API Service
Run the following command within the docker shell:
uvicorn_server
Verify service is running at http://localhost:9000
- Enable All Routes in
api/service.py
# Additional routers here
app.include_router(newsletter.router, prefix="/newsletters")
# app.include_router(podcast.router, prefix="/podcasts")
# app.include_router(llm_chat.router, prefix="/llm")
# app.include_router(llm_cnn_chat.router, prefix="/llm-cnn")
# app.include_router(llm_rag_chat.router, prefix="/llm-rag")
# app.include_router(llm_agent_chat.router, prefix="/llm-agent")
-
Go to
http://localhost:9000/docs
and test the newsletters routes -
For each module we have a separate route:
- Newsletters (
api/routers/newsletters.py
) - Podcasts (
api/routers/podcasts.py
) - LLM Chat (
api/routers/llm_chat.py
) - LLM + CNN Chat (
api/routers/llm_cnn_chat.py
) - LLM Rag (
api/routers/llm_rag_chat.py
) - LLM Agent (
api/routers/llm_agent_chat.py
)
- Newsletters (
-
Enable all the routes
Fast API gives us an interactive API documentation and exploration tool for free.
- Go to
http://localhost:9000/docs
- You can test APIs from this tool
Keep this container running while setting up the backend API service and frontend apps.
This section covers building a basic frontend using HTML & JavaScript that will interact with our API service.
- Navigate to the frontend directory:
cd cheese-app-v2/src/frontend-simple
- Build & Run the container:
sh docker-shell.sh
- Launch the development web server:
http-server
- Visit
http://localhost:8080/index.html
- You should see the cheese app landing page
- Open
http://localhost:8080/newsletters.html
- Verify that cheese newsletters are loading (requires running API service)
- Review the code in
newsletters.html
to understand the API integration
- Open
http://localhost:8080/chat.html
- Test the chat by asking a cheese-related question (e.g., "How is cheese made?")
- Review the code in
chat.html
to understand how the Gemini LLM integration works
Note: The API service must be running for both the newsletter and chat features to work properly.
- Navigate to the React frontend directory:
cd cheese-app-v2/src/frontend-react
- Start the development container:
sh docker-shell.sh
First time only: Install the required Node packages
npm install
- Start the development server:
npm run dev
- View your app at: http://localhost:3000
Note: Make sure the API service container is running for full functionality
- Go to Home page
- Go to Newsletters, Podcasts - Review functionality
- Go to Chat Assistant. Try LLM, LLM + CNN, RAG chats
- Open folder
frontend-react/src
- Data Service (
src/services/DataService.js
) - Review Data Service methods that connects frontend to all backend APIs
- Open folder
frontend-react/src/app
- Review the main app pages
- Home (
src/app/page.jsx
) - Newsletters (
src/app/newsletters/page.jsx
) - Podcasts (
src/app/podcasts/page.jsx
) - Chat Assistant (
src/app/chat/page.jsx
)
- Home (
- Open folder
frontend-react/src/components
- Review components of the app
- Layout for common components such as Header, Footer
- Chat for all the chat components
- Run
docker container ls
- Stop any container that is running
- Run
docker system prune
- Run
docker image ls