Welcome to the finale of Python Safari! Just as every great expedition requires planning, every programming project needs solid foundations. In this module, you will combine all the skills you've acquired into one comprehensive project!
1from dataclasses import dataclass
2from enum import Enum
3
4class ProjectType(Enum):
5 WEB_APP = "web_application"
6 API = "api_service"
7 ML_PIPELINE = "ml_pipeline"
8 RAG_SYSTEM = "rag_system"
9 AUTOMATION = "automation"
10
11@dataclass
12class ProjectDefinition:
13 """Project definition."""
14 name: str
15 problem_statement: str
16 target_users: list[str]
17 success_metrics: list[str]
18 project_type: ProjectType
19 tech_stack: list[str]
20
21# Example
22capstone_project = ProjectDefinition(
23 name="AI Document Assistant",
24 problem_statement="Users waste time searching for information in documents",
25 target_users=["analysts", "lawyers", "researchers"],
26 success_metrics=[
27 "70% reduction in search time",
28 "Answer accuracy > 90%",
29 "Response time < 2s"
30 ],
31 project_type=ProjectType.RAG_SYSTEM,
32 tech_stack=["Python", "FastAPI", "LlamaIndex", "Qdrant", "React"]
33)1@dataclass
2class UserStory:
3 """User story in Agile format."""
4 as_a: str
5 i_want: str
6 so_that: str
7 acceptance_criteria: list[str]
8 priority: int # 1-5, 1 = highest
9
10stories = [
11 UserStory(
12 as_a="analyst",
13 i_want="ask questions about documents in natural language",
14 so_that="I can quickly find the information I need",
15 acceptance_criteria=[
16 "System understands questions in English",
17 "Response includes sources",
18 "Response time < 3s"
19 ],
20 priority=1
21 ),
22 UserStory(
23 as_a="administrator",
24 i_want="easily add new documents",
25 so_that="the knowledge base stays up to date",
26 acceptance_criteria=[
27 "Upload via drag & drop",
28 "Support for PDF, DOCX, TXT",
29 "Automatic indexing"
30 ],
31 priority=2
32 )
33]1from datetime import datetime, timedelta
2
3@dataclass
4class Task:
5 name: str
6 story_points: int # Fibonacci: 1, 2, 3, 5, 8, 13
7 dependencies: list[str]
8 assigned_to: str = ""
9
10@dataclass
11class Sprint:
12 number: int
13 start_date: datetime
14 tasks: list[Task]
15 velocity: int = 20 # Story points per sprint
16
17 @property
18 def end_date(self) -> datetime:
19 return self.start_date + timedelta(days=14)
20
21 @property
22 def total_points(self) -> int:
23 return sum(t.story_points for t in self.tasks)
24
25# Project plan
26sprints = [
27 Sprint(1, datetime(2024, 1, 1), [
28 Task("Project setup", 2, []),
29 Task("CI/CD configuration", 3, ["Project setup"]),
30 Task("Basic API", 5, ["Project setup"]),
31 Task("Vector DB integration", 5, ["Basic API"]),
32 ]),
33 Sprint(2, datetime(2024, 1, 15), [
34 Task("RAG Pipeline", 8, ["Vector DB integration"]),
35 Task("Chat interface", 5, ["Basic API"]),
36 Task("Document upload", 5, ["RAG Pipeline"]),
37 ])
38]1tech_decisions = {
2 "backend": {
3 "choice": "FastAPI",
4 "reasons": ["Async", "Type hints", "Auto docs", "Performance"]
5 },
6 "vector_db": {
7 "choice": "Qdrant",
8 "reasons": ["Self-hosted", "Filtering", "Rust performance"]
9 },
10 "llm": {
11 "choice": "OpenAI GPT-4",
12 "reasons": ["Quality", "Function calling", "Reliable"]
13 },
14 "rag_framework": {
15 "choice": "LlamaIndex",
16 "reasons": ["Flexibility", "Integrations", "Community"]
17 }
18}Remember: a good plan is half the success. In the next lesson, we will design the system architecture!