AI & Automation
Python Intermediate: Secure AI Apps with FastAPI & Ollama
Build a secure RAG assistant that answers questions from your own documents — running 100% on your laptop, with no cloud and no API keys.
- Intermediate
- 3 days
- HRD Corp claimable
Overview
This 3-day hands-on course is the next step after Python Basics. Participants who already know how to build a FastAPI CRUD API learn to add AI features using local LLMs through Ollama.
Together, they build a RAG application: an AI assistant that answers questions from an organisation’s own documents, with source citations. Everything runs 100% on the participant’s own laptop, with no cloud and no API keys, so sensitive data never leaves the machine. The course ends with a team capstone project, deployed with Docker and presented on Demo Day.
Delivery is face-to-face and instructor-led: about 30% theory and 70% hands-on labs. Participants bring their own laptops.
The course is for participants who have completed Python Basics, and for Python and backend developers who want to build AI-powered applications. No AI or machine learning background is needed, and no GPU: Ollama runs the models on a normal laptop CPU. It suits companies and government agencies that want an assistant over internal documents without sending those documents to a cloud AI service.
Participants leave with a complete, containerised RAG application, the slides and lab guides, full source code, their team’s capstone project and a Certificate of Completion. Join a public session, or run it in-house for your team. It is HRD Corp claimable, subject to grant approval; see how HRD Corp claims work.
After the course
LangChain and LangGraph take the same ideas further, into chains and AI agents, and Docker Essentials shows how to package and deploy what you build.
Schedule is tentative and subject to change based on the trainer’s delivery, participants’ progress, and training needs.
What you’ll learn
- Explain how LLMs work and run AI models locally with Ollama
- Write effective prompts that reduce AI hallucination
- Build async FastAPI endpoints with streaming AI responses
- Store application data in PostgreSQL using SQLAlchemy and Alembic
- Ingest, chunk and index documents using LlamaIndex and FAISS
- Build a complete RAG pipeline that answers questions with source citations
- Secure AI endpoints with OAuth2 and JWT authentication
- Build multi-turn chat with session memory
- Evaluate and improve AI answer quality
- Package and deploy the full AI application with Docker Compose
Who should join
- Participants who have completed Python Basics
- Python and backend developers who want to build AI-powered applications
- No AI or machine learning background required
Prerequisites: Completed Python Basics, or equivalent: building FastAPI endpoints with Pydantic models, connecting FastAPI to a database with SQLAlchemy, and testing APIs in Swagger UI or Postman. Comfortable with the terminal, pip and virtual environments. Laptop with 8GB RAM minimum (16GB recommended), 20GB free disk space, admin rights and virtualisation enabled — no GPU required.
Course modules
-
01 LLM Concepts & Local AI with Ollama
How a Large Language Model generates an answer: tokens, context windows, temperature and why LLMs hallucinate. Cloud vs local AI, model sizes, and running models locally with Ollama from the terminal, its REST API and Python.
-
02 Prompt Engineering for Reliable Answers
System and user messages; role, task, context and format; zero-shot and few-shot prompting; structured JSON output validated with Pydantic; and getting the model to say "I don't know" instead of guessing.
-
03 Python Async & FastAPI Foundations
Async and await, the event loop, async HTTP calls, routers, dependency injection and project structure — then streaming LLM answers word by word and handling an unavailable model.
-
04 Database Integration with SQLAlchemy & Alembic
Async SQLAlchemy with PostgreSQL, models and relationships, per-request sessions, Alembic migrations, and saving users, documents and chat history for auditing.
-
05 Document Ingestion, Chunking & Embeddings
Loading PDF, Word and text files with LlamaIndex, cleaning text, chunk size and overlap, metadata, embeddings with nomic-embed-text, and building a searchable FAISS vector index with an upload API.
-
06 Retrieval-Augmented Generation (RAG) Pipeline
The RAG architecture, retrieving the most relevant chunks, grounded prompts, source citations, similarity thresholds, and refusing questions the documents cannot support.
-
07 Authentication & Authorization (OAuth2 & JWT)
Password hashing, the OAuth2 password flow, JWT tokens and expiry, role-based access control, document-level permissions by role and department, and prompt-injection risks — and why access control happens before retrieval, not in the prompt.
-
08 Multi-turn Chat with Session Memory
Why LLMs are stateless, chat sessions and message history, memory windows, token budgeting, query rewriting for follow-up questions, and keeping each user's conversations private.
-
09 RAG Evaluation, Testing & Best Practices
Metadata filtering, building an evaluation set, measuring retrieval and answer quality, tuning chunk size and top-k, and pytest suites that mock the LLM.
-
10 Docker Deployment
A Dockerfile for FastAPI, Docker Compose for multi-service AI apps, volumes for models and indexes, environment configuration, health checks, and common deployment issues.
-
11 Capstone Project & Demo Day
Teams plan, build, evaluate and present a secure, containerised RAG assistant for a real use case, answering questions from real documents with citations and explaining their design, security and evaluation choices.
FAQ
+ Is this course HRD Corp claimable?
Yes, subject to your grant approval. Tarsoft is a registered training provider and will help with the application.
+ Do I need a GPU or paid AI subscription?
No. Ollama runs models on a normal laptop CPU — llama3.2:1b on 8GB RAM, llama3.2:3b on 16GB or more. No cloud accounts or API keys are needed, so your data never leaves your machine.
+ What should I install before Day 1?
Python 3.11+, VS Code with the Python extension, Ollama (with llama3.2:1b and nomic-embed-text pulled), Docker Desktop, PostgreSQL, Git and uv. We send a setup guide in advance.
+ What do I take home?
A complete, containerised RAG application, slides and lab guides, full source code, your team's capstone project, and a certificate of completion.
Related courses
Python Basics: Build a Secure CRUD API with FastAPI
Go from Python fundamentals to a working, secure REST API with FastAPI and PostgreSQL in two hands-on days. No coding experience needed.
- 2 days
- Beginner
RM1,500 / pax
LangChain: Build Smart AI Apps Powered by Your Own Data
Learn LangChain's building blocks — prompts, chains, memory, RAG and agents — and build a chatbot that answers from your own documents.
- 2 days
- Beginner to Intermediate
RM1,500 / pax