🏛️ Midas Web Concept: Architectural Master Plan
This skill acts as the Orchestrator for the Midas Web Project. It defines the strictly ordered workflow for implementing features to ensure financial integrity and system stability.
🔄 The "Feature Implementation Pipeline"
When the user asks for a new feature (e.g., "Implement Buy Order logic"), you MUST follow this 4-step execution order. Do not skip steps.
PHASE 1: Data Modeling (The Foundation)
Refer to Skill: prisma-data-modeling
- •Analyze if the feature requires new tables or field modifications.
- •STOP & THINK: Does this involve money? If yes, are fields
Decimal(19,4)? - •CHECK: Are there high-frequency queries involved (like Cron Jobs)? If yes, define composite indexes.
- •Action: Generate/Update
schema.prisma.
PHASE 2: Math & Logic Strategy (The Rules)
Refer to Skill: financial-math
- •Identify the currencies involved (TRY, USD, or USDT).
- •Determine the source of funds (User Balance vs. Portfolio Balance).
- •CRITICAL: Plan how to handle precision. (e.g., "I will use
decimal.jsfor the price calculation before sending to DB"). - •Action: Write a mental (or scratchpad) plan for the calculation logic.
PHASE 3: Backend Implementation (The Engine)
Refer to Skill: nextjs-server-actions
- •Create the Server Action in
src/actions/. - •AUTH FIRST: Ensure
auth()is the first line. - •VALIDATION: Define the Zod schema.
- •ATOMICITY: Wrap DB writes in
prisma.$transaction. - •Action: Write the code implementing the logic defined in Phase 2.
PHASE 4: UI Integration (The Facade)
- •Connect the Server Action to the UI Component.
- •Use
useTransitionorsonner(toast) for user feedback. - •Types: Ensure the UI receives serialized data (convert Decimals to strings if passing to Client Components).
🚦 Scenario-Based Decisions
Scenario A: "User wants to buy Apple Stock (AAPL)"
- •Orchestrator: This is a
US_STOCKtrade. - •Math Skill: Check
portfolio['USD']balance. NOTuser.balance(TRY). - •Prisma Skill: Ensure
Transactionrecord is created. - •Action: Execute trade.
Scenario B: "User wants to Withdraw Money to Bank"
- •Orchestrator: Only TRY (
user.balance) can be withdrawn. - •Math Skill: Ensure requested amount <=
user.balance. - •Action: Create a
Transactionwith typeWITHDRAW.
🚫 Forbidden Patterns (Anti-Patterns)
- •Logic in UI: Never calculate trade totals inside a React Component. Do it in the Server Action.
- •Mixed Currency Math: Never sum
user.balance(TRY) +portfolio.value(USD) without an explicit FX rate conversion.
PHASE 4: Frontend Implementation (The Facade)
Refer to Skill: frontend-construction
- •Create UI components using
cn()and Tailwind. - •Connect Server Actions.
- •Security Check: Refer to
security-auditto ensure no sensitive data is leaked to Client Components.
PHASE 5: Refactoring & Verification (The Polish)
Refer to Skills: qa-testing, clean-code-refactoring
- •Refactor: Is the file too long? Extract logic. Are magic numbers used?
- •Test: Run the "Self-Correction" checklist (Money Test, Edge Cases).
- •Verify: Does it look and feel like a premium app?
PHASE 6: Documentation (The Legacy)
Refer to Skill: documentation-standard
- •Add JSDoc to new functions.
- •Update
README.mdif this is a major feature. - •Action: Confirm task completion to the user.
🚦 Scenario: "User wants to see Stock Detail Page"
- •Orchestrator: Needs UI + Data.
- •Data Skill: Fetch data from Yahoo via
unstable_cache. - •Frontend Skill: Build page with
<Suspense>and Skeleton. - •Docs Skill: Add comments explaining the caching strategy.