Index: app/main.py
===================================================================
--- app/main.py	(revision 09d3003c611c2e5cca96053b698c75d2de415528)
+++ app/main.py	(revision fe689755dd3165a246590e1050fbd7e38098a6df)
@@ -48,9 +48,12 @@
         from_attributes = True
 
-class TransactionCreate(BaseModel):
+class TransactionCreateRequest(BaseModel):
     transaction_name: str
-    amount: float
-    net_amount: float
-    date: datetime  # Use this format for date strings "2024-12-21T12:00:00+02:00"
+    amount: float = 0.0  # Default to 0 if not provided
+    date: Optional[datetime] = None  # Default to None, will use current time if not provided
+    tag_id: Optional[int] = None  # Optional tag
+    target_account_id: int  # Mandatory target account
+    breakdowns: Optional[List[TransactionBreakdownResponse]] = None  # Optional list of breakdowns
+
 
 class TransactionUpdate(BaseModel):
@@ -174,14 +177,66 @@
 
 @app.post("/transactions/", response_model=TransactionResponse)
-def create_transaction(transaction: TransactionCreate, db: Session = Depends(get_db)):
+def create_transaction(transaction_request: TransactionCreateRequest, user: User = Depends(get_current_user), db: Session = Depends(get_db)):
+    """
+    Create a transaction and associate it with the user's accounts via breakdowns.
+    """
+    # Validate target account ownership
+    target_account = db.query(TransactionAccount).filter(
+        TransactionAccount.transaction_account_id == transaction_request.target_account_id,
+        TransactionAccount.user_id == user.user_id
+    ).first()
+    if not target_account:
+        raise HTTPException(status_code=403, detail="Access denied to target account.")
+
+    # Create transaction
     new_transaction = Transaction(
-        transaction_name=transaction.transaction_name,
-        amount=transaction.amount,
-        net_amount=transaction.net_amount,
-        date=transaction.date
+        transaction_name=transaction_request.transaction_name,
+        amount=transaction_request.amount,
+        net_amount=0.0,  # Will be updated based on breakdowns
+        date=transaction_request.date or datetime.utcnow(),  # Use current UTC time if not provided
     )
     db.add(new_transaction)
     db.commit()
     db.refresh(new_transaction)
+
+    # Associate a tag, if provided
+    if transaction_request.tag_id:
+        tag = db.query(Tag).filter(Tag.tag_id == transaction_request.tag_id).first()
+        if tag:
+            tag_assignment = TagAssignedToTransaction(
+                transaction_id=new_transaction.transaction_id,
+                tag_id=tag.tag_id
+            )
+            db.add(tag_assignment)
+
+    # Add breakdowns
+    net_amount = 0.0
+    if transaction_request.breakdowns:
+        for breakdown in transaction_request.breakdowns:
+            # Validate breakdown account ownership
+            breakdown_account = db.query(TransactionAccount).filter(
+                TransactionAccount.transaction_account_id == breakdown.transaction_account_id,
+                TransactionAccount.user_id == user.user_id
+            ).first()
+            if not breakdown_account:
+                raise HTTPException(status_code=403, detail=f"Access denied to breakdown account {breakdown.transaction_account_id}.")
+
+            # Create breakdown
+            new_breakdown = TransactionBreakdown(
+                transaction_id=new_transaction.transaction_id,
+                transaction_account_id=breakdown.transaction_account_id,
+                earned_amount=breakdown.earned_amount,
+                spent_amount=breakdown.spent_amount
+            )
+            db.add(new_breakdown)
+
+            # Calculate net amount
+            net_amount += breakdown.earned_amount - breakdown.spent_amount
+
+    # Update transaction's net amount
+    new_transaction.net_amount = net_amount
+    db.commit()
+    db.refresh(new_transaction)
+
     return new_transaction
 
@@ -285,9 +340,16 @@
     return {"message": "Tag assigned to transaction successfully"}
 
-@app.get("/transactions/{transaction_id}/tags", response_model=List[TagResponse])
-def get_transaction_tags(transaction_id: int, db: Session = Depends(get_db)):
+@app.get("/tags/transaction/{transaction_id}", response_model=List[TagResponse])
+def get_transaction_tags_for_user(transaction_id: int, user: User = Depends(get_current_user), db: Session = Depends(get_db)):
     transaction = db.query(Transaction).filter(Transaction.transaction_id == transaction_id).first()
     if not transaction:
         raise HTTPException(status_code=404, detail="Transaction not found")
 
+    # Ensure transaction belongs to the authenticated user
+    if not db.query(TransactionAccount).filter(
+        TransactionAccount.transaction_account_id == transaction_id,
+        TransactionAccount.user_id == user.user_id,
+    ).first():
+        raise HTTPException(status_code=403, detail="Access denied")
+
     return transaction.tags
Index: cli/cli_app.py
===================================================================
--- cli/cli_app.py	(revision 09d3003c611c2e5cca96053b698c75d2de415528)
+++ cli/cli_app.py	(revision fe689755dd3165a246590e1050fbd7e38098a6df)
@@ -216,13 +216,32 @@
     print("\nAdd Transaction")
     transaction_name = input("Enter transaction name: ")
-    amount = float(input("Enter amount: "))
-    date = input("Enter date (YYYY-MM-DDTHH:MM:SS+HH:MM): ")
-
-    response = requests.post(f"{BASE_URL}/transactions/", json={
+    amount = float(input("Enter amount (default 0): ") or 0)
+    date = input("Enter date (YYYY-MM-DDTHH:MM:SS+HH:MM+HH:MM: ")
+    target_account_id = int(input("Enter target transaction account ID: "))
+    tag_id = int(input("Enter tag ID (leave blank for none): ") or 0)
+
+    breakdowns = []
+    add_breakdown = input("Do you want to add breakdowns? (yes/no): ").lower()
+    while add_breakdown == "yes":
+        breakdown_account_id = int(input("Enter breakdown account ID: "))
+        earned_amount = float(input("Enter earned amount (default 0): ") or 0)
+        spent_amount = float(input("Enter spent amount (default 0): ") or 0)
+        breakdowns.append({
+            "transaction_account_id": breakdown_account_id,
+            "earned_amount": earned_amount,
+            "spent_amount": spent_amount
+        })
+        add_breakdown = input("Add another breakdown? (yes/no): ").lower()
+
+    payload = {
         "transaction_name": transaction_name,
         "amount": amount,
-        "net_amount": 0,
-        "date": date
-    }, headers=headers)
+        "date": date,
+        "target_account_id": target_account_id,
+        "tag_id": tag_id or None,
+        "breakdowns": breakdowns
+    }
+
+    response = requests.post(f"{BASE_URL}/transactions/", json=payload, headers=headers)
 
     if response.status_code == 200:
@@ -343,15 +362,25 @@
 
 def view_transaction_tags():
+    headers = {"Authorization": f"Bearer {access_token}"}
+
     print("\nView Transaction Tags")
     transaction_id = int(input("Enter transaction ID to view its tags: "))
 
-    response = requests.get(f"{BASE_URL}/transactions/{transaction_id}/tags")
-
-    if response.status_code == 200:
-        tags = response.json()
-        for tag in tags:
-            print(f"ID: {tag['tag_id']}, Name: {tag['tag_name']}")
-    else:
-        print(f"Error retrieving tags for transaction. {response.json().get('detail', 'Unknown error')}")
+    response = requests.get(f"{BASE_URL}/transactions/{transaction_id}", headers=headers)
+
+    if response.status_code == 200:
+        transaction = response.json()
+        print(f"Transaction: {transaction['transaction_name']}")
+
+        # Fetch tags linked to the transaction
+        tags_response = requests.get(f"{BASE_URL}/tags/transaction/{transaction_id}", headers=headers)
+        if tags_response.status_code == 200:
+            tags = tags_response.json()
+            for tag in tags:
+                print(f"Tag ID: {tag['tag_id']}, Name: {tag['tag_name']}")
+        else:
+            print(f"Failed to retrieve tags. Error: {tags_response.json().get('detail', 'Unknown error')}")
+    else:
+        print(f"Failed to retrieve transaction. Error: {response.json().get('detail', 'Unknown error')}")
 
 def view_reports():
