Hands On "AI Engineering"

Hands On "AI Engineering"

180-Day AI and Machine Learning Course from Scratch

Week 1 : AIML Python Weekly Integration

May 22, 2026
∙ Paid

Introduction

Most “intro week” curricula leave you with a folder of disconnected scripts: one file proves you understand loops, another proves dictionaries, and a third prints a banner. That is fine for drills. It is weaker preparation for how engineers actually work—where syntax, structure, and a thin slice of system design show up in the same repository, under tests, behind an API, and sometimes in front of a user.

The week_1: aiml integrated project tree exists to consolidate Week 1 (Days 1–7) of a code-first AI/ML path into something you can run, extend, and reason about as a system. Day 1 lands as a real application surface (a React client talking to a FastAPI backend with a Gemini-backed chat route). Days 2–6 live in an installable package (week1_python) whose lesson objects are also exposed through FastAPI “lab” routes—so the same logic can be exercised from HTTP without spinning up extra demo servers. Day 7 becomes a command-line training simulator: stateful assistants, JSON persistence, and a menu-driven loop that feels closer to a small product than a textbook snippet.

For engineers and serious learners, the payoff is not “I finished seven files.” It is: I can trace how user intent becomes state, how state becomes I/O, and where each Python construct earns its place.


From Fundamentals to a Unified System

The progression is intentionally layered rather than repetitive.

  • Day 1 (environment + application shell) establishes the outer system: a FastAPI app (backend/app/main.py) with CORS, versioned routes under /api/v1, and a React SPA in frontend/. This is where “Python as glue for services” begins in practice—not only as a REPL language.

  • Day 2 (day02_variables) centers typed state in a small agent (SimpleAIAgent): strings, numbers, booleans, lists, and dictionaries cooperating in process_input and get_agent_status. The lab router mirrors the old “metrics dashboard” idea without requiring a second process.

  • Day 3 (day03_control_flow) moves decisions and iteration into first-class objects: DataValidator walks a dataset with rules and counters; SimpleSentimentAI shows branching logic standing in for a classifier. Control flow stops being abstract and becomes the gate between raw input and trustworthy downstream structures.

  • Day 4 (day04_lists_tuples) uses AIDataProcessor to show mutable collections for growing training artifacts versus immutable tuples for configuration-shaped records, plus batch-style prediction that returns (label, confidence) pairs—mirroring how ML code often shapes results.

  • Day 5 (day05_dictionaries_sets) promotes AIDataManager: nested dicts for model configuration, sets for deduplication and overlap checks, and metrics keyed by dataset name. This is the week’s “schema without a database” moment.

  • Day 6 (day06_functions) pulls cross-cutting utilities (clean_text, feature extractors, generate_analysis_report) into composable functions—what later becomes “preprocess → featurize → report” in real pipelines.

  • Day 7 (day07_trainer) integrates the week into a CLI game loop: TrainingSimulator orchestrates menus, nested interaction modes, and AIAssistant objects that classify input, learn new responses, track confidence, and serialize state to JSON under data/assistants/ (or WEEK1_ASSISTANTS_DIR).

Nothing here replaces a full ML stack; everything here rehearses the shapes ML code will inherit: validated inputs, structured intermediates, deterministic side effects, and clear boundaries.


Architecture Overview

At a high level, the system is a dual-surface runtime sharing one conceptual domain (“assistant / lab”):

  1. Product path — Browser → React → FastAPI → Gemini client (Day 1 chat) plus shared configuration (backend/config/settings.py, .env).

  2. Pedagogy path — HTTP clients or pytest → FastAPI week1_lab router → imports from week1_python days 2–7 → JSON responses (and optional print side effects in some lesson classes).

  3. Standalone path — python -m week1_python.day07_trainer for the Day 7 simulator, writing JSON artifacts the /api/v1/week1/day07/assistants route can list.

Optional legacy glue (legacy/day02_flask/) keeps a Flask dashboard story without duplicating the core lesson implementations.

Architecture diagram


Data / Control Flow

Two flows deserve separate mental models—HTTP lab and Day 7 REPL—but they rhyme.

HTTP lab: Request body → Pydantic model → instantiate a lesson class or call a module-level function → return a JSON-serializable dict. Example: POST /api/v1/week1/day04/predict builds AIDataProcessor, runs predict_batch on nested lists of floats, and returns lightweight prediction objects.

CLI simulator: input() → string choice or chat line → method on TrainingSimulator or AIAssistant → prints to stdout; optional JSON write on save.

In both cases, the “model” is pedagogical: randomness and heuristics stand in for expensive inference, which keeps the focus on structure.

Control-flow diagram

Nuance: For FastAPI routes, “state update” often means constructing a fresh object per request (stateless handler), except where week1_lab intentionally keeps a module-level _lab_agent for Day 2 demos—an honest teaching moment about global process memory in long-running servers.


State Management

Day 7 is where Python’s built-in collections become the persistence story. Each AIAssistant tracks:

  • skills as a Dict[str, List[str]] (categories to response templates),

  • scalars such as experience and confidence,

  • conversation_history as a List[Dict] with timestamps.

save_progress / load_progress serialize that graph to JSON—checkpoint semantics without a framework. TrainingSimulator adds process-level maps (self.assistants, self.current_assistant) and ensures the assistants directory exists.

The HTTP surface for Day 7 is deliberately read-only listing (GET .../day07/assistants), which keeps file-system races out of the demo API while still connecting the browser-side story to disk artifacts.

State machine (Day 7 trainer)

Reading the loop: Nested while True blocks in chat_mode and training_mode are “micro-states” entered from the main menu; 'back' returns control without tearing down the assistant. Quit optionally flushes JSON—mirroring production habits (explicit persistence, not silent loss).


Access Github Repository

Github Link:

https://github.com/sysdr/aiml-p/tree/main/week_1_aiml_integrated_project

Step-by-Step Implementation Guide

User's avatar

Continue reading this post for free, courtesy of AI Engineering.

Or purchase a paid subscription.
© 2026 AIE · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture