Witaj w finale Python Safari! Jak każda wielka ekspedycja wymaga planowania, tak każdy projekt programistyczny potrzebuje solidnych fundamentów. W tym module połączysz wszystkie zdobyte umiejętności w jeden, kompleksowy projekt!
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 """Definicja projektu."""
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# Przykład
22capstone_project = ProjectDefinition(
23 name="AI Document Assistant",
24 problem_statement="Użytkownicy tracą czas na szukanie informacji w dokumentach",
25 target_users=["analitycy", "prawnicy", "badacze"],
26 success_metrics=[
27 "Redukcja czasu wyszukiwania o 70%",
28 "Dokładność odpowiedzi > 90%",
29 "Czas odpowiedzi < 2s"
30 ],
31 project_type=ProjectType.RAG_SYSTEM,
32 tech_stack=["Python", "FastAPI", "LlamaIndex", "Qdrant", "React"]
33)1@dataclass
2class UserStory:
3 """User story w formacie Agile."""
4 as_a: str
5 i_want: str
6 so_that: str
7 acceptance_criteria: list[str]
8 priority: int # 1-5, 1 = najwyższy
9
10stories = [
11 UserStory(
12 as_a="analityk",
13 i_want="zadać pytanie o dokumenty w języku naturalnym",
14 so_that="szybko znajdę potrzebne informacje",
15 acceptance_criteria=[
16 "System rozumie pytania po polsku",
17 "Odpowiedź zawiera źródła",
18 "Czas odpowiedzi < 3s"
19 ],
20 priority=1
21 ),
22 UserStory(
23 as_a="administrator",
24 i_want="łatwo dodawać nowe dokumenty",
25 so_that="baza wiedzy była aktualna",
26 acceptance_criteria=[
27 "Upload przez drag & drop",
28 "Obsługa PDF, DOCX, TXT",
29 "Automatyczna indeksacja"
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# Plan projektu
26sprints = [
27 Sprint(1, datetime(2024, 1, 1), [
28 Task("Setup projektu", 2, []),
29 Task("Konfiguracja CI/CD", 3, ["Setup projektu"]),
30 Task("Podstawowe API", 5, ["Setup projektu"]),
31 Task("Integracja Vector DB", 5, ["Podstawowe API"]),
32 ]),
33 Sprint(2, datetime(2024, 1, 15), [
34 Task("RAG Pipeline", 8, ["Integracja Vector DB"]),
35 Task("Chat interface", 5, ["Podstawowe 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}Pamiętaj: dobry plan to połowa sukcesu. W następnej lekcji zaprojektujemy architekturę systemu!