Skip to main content
New Self-paced AI courses — learn ML, deep learning, and agents on your schedule. Enroll free

Complete AI

Python and FastAPI

No prerequisites. Learn Python from your first line of code, then Git, the web, HTTP and SQL, then build, secure, test, containerise and deploy production-grade APIs with FastAPI — with hand-drawn diagrams, runnable examples, practice questions and coding challenges.

Beginner 120 hours · Self-paced 99.0 USD · 225 lessons · ~5999 min read

31 topics 225 lessons Start anywhere
Grounded in sources, not a frozen script Ideas in this path map to readings and the Research Lab. See how we refresh lessons as the field moves.

What you’ll get out of this course

  • Build practical skill in “Python and FastAPI” with text-first lessons and clear checkpoints.
  • Level: Beginner—follow the syllabus in order or jump to the modules you need.
  • Reinforce ideas with end-of-topic checks and (where available) hands-on coding tasks.

Trust & quality

Content is designed and maintained by the Deep AI Minds team—structured for working adults, with frequent updates as tooling and best practices evolve.

Content currency: ~100% of lessons on the current curriculum revision

Syllabus

We structured this course to build your skills step by step

Scroll through each module below—open lessons in place or jump into a topic. Everything runs in order, but you’re free to explore.

Topic 1
Learning module

Module 1 · Start here: programming, Python and your workspace

What programming is, why Python, installing everything, the terminal, notebooks, the REPL, reading errors, and how to study this course.

1.1 What is programming? What is Python? 22 min
1.2 Why Python 22 min
1.3 Your environment: installing Python and an editor 26 min
1.4 The terminal and command-line basics 26 min
1.5 Notebooks and scripts 24 min
1.6 The REPL and quick experiments 22 min
1.7 Reading error messages 26 min
1.8 How to take this course 24 min
Topic 2
Learning module

Module 2 · Python basics: values, variables, decisions, loops and functions

The core language from zero: names and values, comparisons, if/else, for and while loops, patterns, functions, modules, input and output, style, and two mini projects.

2.1 Variables and types 24 min
2.2 Names, objects and the memory model 26 min
2.3 Truthiness and comparisons 26 min
2.4 Control flow: if, elif, else 28 min
2.5 Loops: for, while, break and continue 30 min
2.6 Nested loops and pattern problems 30 min
2.7 Functions and modules 27 min
2.8 input(), print() and basic I/O 26 min
2.9 Writing readable code: PEP 8 and good habits 29 min
2.10 Mini projects: a guessing game and a calculator 30 min
Topic 3
Learning module

Module 3 · Numbers and operators

Integers, floats, the math module, rounding and money, precedence, complex numbers, fractions, number systems and bits.

3.1 Integers and floats 24 min
3.2 Arithmetic and the math module 26 min
3.3 Precision, rounding and money 28 min
3.4 Operator precedence and associativity 30 min
3.5 Complex numbers and Fraction 28 min
3.6 Number systems, binary, hex and bitwise operators 32 min
Topic 4
Learning module

Module 4 · Collections deep dive: lists, tuples, sets and dictionaries

Every built-in collection in depth, with slicing, unpacking, comprehensions, nesting, and how to choose the right one.

4.1 Lists in detail 24 min
4.2 Sequences, slicing and unpacking 25 min
4.3 Tuples and sets 26 min
4.4 Dictionaries in detail 27 min
4.5 Comprehensions, mastered 26 min
4.6 Nested data structures 27 min
4.7 Choosing the right collection 25 min
Topic 5
Learning module

Module 5 · Working with data

Lists and dicts as tables, rows and columns, grouping and aggregating, sorting and ranking, and a small data project.

5.1 Lists and dictionaries together 24 min
5.2 Toward arrays 26 min
5.3 Rows and columns as lists 26 min
5.4 Grouping and aggregating with dicts 27 min
5.5 Sorting and ranking data 27 min
5.6 Mini project: a gradebook and an inventory 30 min
Topic 6
Learning module

Module 6 · Functions in depth

Function design from parameters to decorators: args/kwargs, lambdas, closures, scope, decorators, recursion and memoisation.

6.1 Function anatomy: parameters and return values 22 min
6.2 *args, **kwargs and defaults 24 min
6.3 Lambdas and higher-order functions 24 min
6.4 Closures and scope (LEGB) 24 min
6.5 Decorators explained 26 min
6.6 Decorators with arguments, stacking and class decorators 28 min
6.7 Recursion basics 26 min
6.8 Recursion, memoisation and its limits 26 min
Topic 7
Learning module

Module 7 · Text, errors, files and context managers

Strings in depth, unicode, exceptions, files and paths, simple classes and context managers — the everyday tools of real programs.

7.1 Strings, formatting and parsing 22 min
7.2 String methods, Unicode and encodings 24 min
7.3 try, except and useful errors 24 min
7.4 Raising and designing custom exceptions 26 min
7.5 Files and pathlib 26 min
7.6 Reading and writing files in practice 27 min
7.7 Classes for structure (a first look) 25 min
7.8 Context managers and the with statement 26 min
Topic 8
Learning module

Module 8 · Iterators and generators

The iteration protocol, generators and yield, generator expressions, itertools, custom iterables and lazy pipelines.

8.1 The iterator protocol 22 min
8.2 Generators with yield 24 min
8.3 Generator expressions 22 min
8.4 itertools you will actually use 26 min
8.5 Writing your own iterable 24 min
8.6 Lazy pipelines and streaming data 28 min
Topic 9
Learning module

Module 9 · Object-oriented Python

Classes and objects from scratch to design: attributes, methods, inheritance, dunder methods, dataclasses, properties, abstract classes, composition and patterns.

9.1 OOP thinking: objects and responsibilities 22 min
9.2 Classes and instances 24 min
9.3 Inheritance and polymorphism 26 min
9.4 Dunder methods (operators) 27 min
9.5 Dataclasses 28 min
9.6 Properties and encapsulation 26 min
9.7 Abstract classes and interfaces 26 min
9.8 Composition over inheritance and common design patterns 30 min
Topic 10
Learning module

Module 10 · Type hints and protocols

Annotations, generics, Optional/Union, TypedDict/Literal, static checking, and how frameworks like FastAPI read type hints at runtime.

10.1 Type hints, the practical guide 24 min
10.2 Optional and union types 26 min
10.3 Generics and protocols 28 min
10.4 TypedDict and Literal 27 min
10.5 The static type-checking workflow 27 min
10.6 How frameworks read type hints at runtime 34 min
Topic 11
Learning module

Module 11 · Standard library tour

The batteries included: datetime, json/csv, re, collections, functools, logging, os/sys/environment, hashing/UUID/encoding.

11.1 datetime essentials 22 min
11.2 json and csv 24 min
11.3 Regular expressions with re 26 min
11.4 The collections module 24 min
11.5 functools essentials 25 min
11.6 Logging in depth 26 min
11.7 os, sys and environment variables 26 min
11.8 Hashing, UUIDs, secrets and encoding 28 min
Topic 12
Learning module

Module 12 · Python internals and performance

How CPython runs code, memory and references, copying pitfalls, measuring speed, Big-O and making programs faster.

12.1 How CPython runs your code 24 min
12.2 Memory, references and garbage collection 26 min
12.3 Mutability, copying and common pitfalls 26 min
12.4 Measuring performance: timeit and profiling 26 min
12.5 Algorithmic complexity and Big-O 27 min
12.6 Making Python faster: practical techniques 28 min
Topic 13
Learning module

Module 13 · Concurrency: threads, processes and asyncio

Concurrency vs parallelism, the GIL, threads, processes, and a thorough tour of asyncio — the foundation for async FastAPI.

13.1 Threads vs processes vs async 22 min
13.2 The GIL and what it means 24 min
13.3 Threads in practice: locks and queues 26 min
13.4 Multiprocessing basics 27 min
13.5 asyncio fundamentals 27 min
13.6 Async iteration and task groups 28 min
13.7 asyncio patterns: timeouts, queues and semaphores 30 min
Topic 14
Learning module

Module 14 · Testing with pytest

Why and how to test: TDD, pytest basics, fixtures, parametrisation, mocking, edge cases, coverage and continuous testing.

14.1 Testing fundamentals and test-driven development 24 min
14.2 Writing your first tests 26 min
14.3 Fixtures and parametrize 28 min
14.4 Testing exceptions and edge cases 26 min
14.5 Mocking external calls and coverage 30 min
14.6 Test design, organisation and CI 28 min
14.7 A continuous testing workflow 28 min
Topic 15
Learning module

Module 15 · Packaging, dependencies and distribution

Virtual environments, pip/uv, project layout, pyproject.toml, building and publishing, CLI entry points, licences.

15.1 Virtual environments, pip and modern tooling 24 min
15.2 Project layout and virtual envs 24 min
15.3 pyproject.toml and publishing 26 min
15.4 Dependency management: requirements vs pyproject 26 min
15.5 Building a CLI entry point 26 min
15.6 Licence, metadata and a README that helps 26 min
Topic 16
Learning module

Module 16 · Git and GitHub for developers

Version control from scratch: commits, branches, merging, remotes, pull requests, conflicts and collaboration habits.

16.1 Why version control? 22 min
16.2 Git basics: init, add, commit 34 min
16.3 Branches and merging 34 min
16.4 Remotes, GitHub and pull requests 36 min
16.5 Conflicts, undoing mistakes and .gitignore 40 min
16.6 Collaboration workflows and code review 40 min
Topic 17
Learning module

Module 17 · How the web works: HTTP, REST and APIs

Networks, DNS, HTTP in depth, URLs, cookies, JSON, REST design, and calling APIs from Python — everything you need before building one.

17.1 The internet: IP addresses, DNS and ports 24 min
17.2 HTTP requests and responses 26 min
17.3 Status codes and headers 26 min
17.4 URLs, query strings and encoding 26 min
17.5 Cookies, sessions and state 27 min
17.6 JSON and data formats for APIs 28 min
17.7 REST API design principles 30 min
17.8 Calling APIs from Python with requests and httpx 32 min
Topic 18
Learning module

Module 18 · SQL and databases from scratch

Relational databases, SQL queries, joins, aggregation, transactions, indexes and using SQLite from Python (runnable in the browser).

18.1 What is a database and why do we need one? 22 min
18.2 SQL basics: SELECT, WHERE, ORDER BY, LIMIT 26 min
18.3 Aggregation: COUNT, SUM, GROUP BY, HAVING 28 min
18.4 Joins explained with pictures 32 min
18.5 INSERT, UPDATE, DELETE and transactions 30 min
18.6 Schema design: keys, indexes and normalisation 36 min
18.7 Using SQLite from Python 34 min
Topic 19
Learning module

Module 19 · FastAPI foundations: your first API

What an API is, installing FastAPI, your first endpoints, how FastAPI works under the hood, automatic docs, validation, dependencies and error handling at a glance.

19.1 What is an API, and why FastAPI? 22 min
19.2 Installing FastAPI and your first endpoint 24 min
19.3 HTTP, JSON and status codes in FastAPI 26 min
19.4 Path operations: GET, POST, PUT, PATCH, DELETE 30 min
19.5 How FastAPI works: ASGI, Starlette and Pydantic 32 min
19.6 Interactive docs: Swagger UI, ReDoc and OpenAPI 22 min
19.7 Routes and dependency injection (first look) 24 min
19.8 Request validation with Pydantic (first look) 24 min
19.9 Error handling in APIs (first look) 24 min
19.10 Serving models safely 26 min
Topic 20
Learning module

Module 20 · FastAPI requests and parameters

Path, query, body, header, cookie and form parameters, file uploads, validation with Annotated, and a complete in-memory CRUD API.

20.1 Path parameters, types and enums 22 min
20.2 Query parameters: defaults, optional and validation 24 min
20.3 Request bodies with Pydantic models 26 min
20.4 Headers, cookies and form data 26 min
20.5 File uploads and multipart requests 27 min
20.6 Annotated validation and reusable parameter types 25 min
20.7 The request lifecycle and debugging 27 min
20.8 Project: a complete CRUD API (in memory) 30 min
Topic 21
Learning module

Module 21 · Pydantic deep dive

Data validation and settings: models, fields, validators, nested models, serialisation, settings management, custom types and v2 internals.

21.1 Pydantic basics: models and types 24 min
21.2 Field constraints and validation 26 min
21.3 Custom validators: field and model 28 min
21.4 Nested models, lists and unions 28 min
21.5 Serialisation, aliases and JSON 28 min
21.6 Settings management with pydantic-settings 27 min
21.7 Advanced Pydantic: generics, config and performance 30 min
Topic 22
Learning module

Module 22 · FastAPI responses, errors and OpenAPI

Response models, status codes, custom responses, exception handlers, streaming, background tasks and shaping the OpenAPI schema.

22.1 Response models and output filtering 24 min
22.2 Status codes and response classes 24 min
22.3 HTTPException and custom exception handlers 26 min
22.4 Validation errors and the 422 response 26 min
22.5 Streaming and file responses 27 min
22.6 Background tasks 27 min
22.7 Customising OpenAPI: tags, examples and metadata 28 min
Topic 23
Learning module

Module 23 · Dependency injection and application structure

Dependency injection from first principles, Depends in depth, routers, middleware, lifespan, configuration and real project layouts.

23.1 Dependency injection from scratch 26 min
23.2 Depends, sub-dependencies and caching 27 min
23.3 Dependencies with yield and cleanup 27 min
23.4 APIRouter and modular projects 26 min
23.5 Middleware, CORS and request hooks 28 min
23.6 Lifespan, startup/shutdown and application state 26 min
23.7 Configuration, environments and a production project layout 30 min
Topic 24
Learning module

Module 24 · Databases with FastAPI and SQLAlchemy

ORM concepts, SQLAlchemy 2.0 models and sessions, CRUD, relationships, migrations with Alembic, async databases, transactions, pooling and repository patterns.

24.1 ORM concepts and SQLAlchemy Core 24 min
24.2 SQLAlchemy models, sessions and the unit of work 24 min
24.3 A database dependency and CRUD endpoints 24 min
24.4 Relationships: one-to-many and many-to-many 24 min
24.5 Pagination, filtering and sorting 24 min
24.6 Database migrations with Alembic 26 min
24.7 Async SQLAlchemy and aiosqlite 26 min
24.8 Transactions, the N+1 problem and query performance 30 min
24.9 PostgreSQL, connection pooling and the repository pattern 30 min
Topic 25
Learning module

Module 25 · Authentication and security

Authentication vs authorisation, password hashing, JWT, OAuth2 in FastAPI, roles and scopes, API keys, OWASP risks and rate limiting.

25.1 Authentication vs authorisation 24 min
25.2 Password hashing: bcrypt and Argon2 26 min
25.3 JSON Web Tokens explained from scratch 28 min
25.4 OAuth2 password flow and login endpoints in FastAPI 30 min
25.5 Protecting routes: roles and permissions 28 min
25.6 Scopes, API keys and social login overview 30 min
25.7 API security best practices and the OWASP API Top 10 30 min
25.8 Rate limiting and abuse protection 30 min
Topic 26
Learning module

Module 26 · Async, real-time features and background jobs

async def vs def in FastAPI, async HTTP clients, WebSockets, Server-Sent Events, task queues, caching with Redis and scheduling.

26.1 async def vs def in FastAPI 24 min
26.2 Async HTTP clients and concurrent calls 26 min
26.3 WebSockets and a chat example 28 min
26.4 Server-Sent Events and streaming updates 27 min
26.5 Task queues: Celery, ARQ and friends 28 min
26.6 Caching with Redis 29 min
26.7 Scheduled jobs, email and notifications 30 min
Topic 27
Learning module

Module 27 · Testing FastAPI applications

TestClient, fixtures for databases, dependency overrides, async tests, auth tests, coverage, linting and quality gates.

27.1 TestClient basics 26 min
27.2 pytest fixtures for APIs and databases 28 min
27.3 Dependency overrides and mocking 27 min
27.4 Async tests with httpx.AsyncClient 27 min
27.5 Testing authentication and permissions 28 min
27.6 Coverage, linting, ruff, mypy and pre-commit 29 min
Topic 28
Learning module

Module 28 · Docker, deployment and CI/CD

Containers, Dockerfiles for FastAPI, docker-compose with Postgres/Redis, servers and workers, HTTPS, secrets, GitHub Actions and cloud options.

28.1 Containers and Docker explained 22 min
28.2 Writing a Dockerfile for FastAPI 24 min
28.3 docker-compose with Postgres and Redis 26 min
28.4 Uvicorn, Gunicorn, workers and process management 25 min
28.5 Reverse proxies, HTTPS and domains 27 min
28.6 CI/CD with GitHub Actions 28 min
28.7 Cloud deployment options and release strategies 27 min
Topic 29
Learning module

Module 29 · Production engineering

Structured logging, metrics, monitoring, error tracking, versioning, performance and load testing, scaling, caching and reliability patterns.

29.1 Structured logging and request IDs 24 min
29.2 Health checks, metrics and monitoring 26 min
29.3 Error tracking, alerting and incident basics 27 min
29.4 API versioning and backwards compatibility 26 min
29.5 Performance profiling and load testing 28 min
29.6 Scaling, caching and reliability patterns 30 min
Topic 30
Learning module

Module 30 · Serving machine-learning models with FastAPI

From notebook to service: architecture, loading models once, prediction endpoints, batching, image inputs, LLM streaming and monitoring.

30.1 From notebook to service: architecture 24 min
30.2 Loading models at startup with lifespan 24 min
30.3 Prediction endpoints, schemas and validation 26 min
30.4 Batching, threadpools and async inference 27 min
30.5 Image and file inputs for vision models 28 min
30.6 LLM APIs, streaming and prompt services 28 min
30.7 Model versioning, monitoring and A/B testing 29 min
Topic 31
Learning module

Module 31 · Capstone projects and next steps

Five complete projects built step by step, architecture patterns, interview preparation and a roadmap for what to learn next.

31.1 Project 1: a Todo API, step by step 24 min
31.2 Project 2: a blog API with users and a database 28 min
31.3 Project 3: a URL shortener service 26 min
31.4 Project 4: an ML prediction service, end to end 27 min
31.5 Project 5: real-time chat and notifications 28 min
31.6 Architecture patterns: clean architecture and microservices 27 min
31.7 Python and FastAPI interview questions 34 min
31.8 Your roadmap: resources and what to learn next 26 min
Learner stories

What Our Learners Say

Feedback about Python and FastAPI. New submissions are reviewed before they appear here.

No published stories yet for this course — be the first to share yours below.

Share your experience

Sign in to share a testimonial. We keep one submission per account per course.

Sign in to share your story