跳到主要内容

SAAs_entp

profinformatique76
·
13,954 字符
·
≈ 4,535 tokens
You give one file to Cloud so that he can build a complete ERP system with you **in stages** — no
提示词内容
# 🏗️ guide building system ERP with Claude — Step by Step > You give one file to Cloud so that he can build a complete ERP system with you **in stages** — not all at once. > The basic idea: Each stage is separate, Claude finishes it, **stops**, you review and experiment, and then you move on to the next one. --- ## 📌 How Used The file This 1. Create a new empty folder for the system (e.g., ` erp -system` ) and open it in Cloud Code . 2. Copy the section **“ Golden Rules” * below into a file named ` CLAUDE.md` inside the project — this makes Cloud adhere to the style in every session . 3. When you are ready for any stage, copy its ** ready Prompt ** only (not all stages) and send it to Cloud. 4. Claude finishes the stage → **stops** → You test and make sure it works → Then the next stage begins. 5. ** Don't let him skip stages** or build anything that is not within the scope of the current stage. The order of the stages is intentional: each stage builds upon the one before it 👇 ``` Phase 0 : Setup Phase 1 Auth — Login Phase 2 Roles & Permissions — Permissions Phase 3 Inventory — Stock Phase 4 Sales Phase 5 Purchases Phase 6 Dashboard & Reports Phase 7 Improvements + AI Touches (Optional) ``` --- ## 🟡 Rules Golden ( stick it on ) (in ` CLAUDE.md` the heart of the project) markdown Claude's role in this project We're building an ERP system in stages. Follow these rules exactly: ## Basic rules 1. **Build only one stage at a time.* * Only what is required in the current stage — do not anticipate future stages . 2. **Pause after each stage.* *When you finish, summarize:* - What was done (files + features ). - How do I try it myself (clear steps). Anything that requires a decision from me. Then wait for my approval before you continue. 3. **If you need to modify something that already exists, tell me first.** And why — don't change something that's working for no reason. 4. **Ask if something is unclear** instead of assuming. Wrong assumptions cost us time. Code quality 5. Keep the code **simple, clear, and organized** — expressive names, small files, no repetition. 6. Follow the same code pattern as the existing folder . structure (naming , styling ). 7. Safety is not a luxury: ** Don't put In the code , perform validation on any input , and protect any route according to validation. 8. Any modification to the database must be done via ** migration **, not manually. ## After each stage 9. Create a simple ** seed data ** that I can experiment with. 10. Write a **quick test** or at least manual trial steps for the basic flow . 11. Suggest a clear ** commit ** message for the stage (stage = commit ). ``` --- ## 🧱 The Tech Stack Proposal > A cohesive and AI- friendly stack . If you have a different preference , change it here before you begin. | Class | Technology | Why | |--------|---------|-----| | Framework | **Next.js (App Router) + TypeScript ** | Frontend + API in one place | | Formatting | ** Tailwind CSS + shadcn / ui ** | Fast and clean UI | | Database | ** PostgreSQL ** (or SQLite for a quick start) | Strong relationships | | ORM | **Prisma** | Clear schema + migrations + type- safe | | Login | ** Auth.js ( NextAuth ) ** or ** Lucia ** | Ready and secure | | Validation | ** Zod ** | Checks any input | Note: Start with ** SQLite ** if you want a faster experience without setup , and you can switch to PostgreSQL later. --- ## 🗂️ The Data Model (Complete reference — we build it table by table with each stage) This is the final form of the tables. ** We don't build it all at once** — each stage adds its own tables . ``` User (id, name , email, password_hash , role_id , is_active , created_at ) Role (id, name, description) ← admin / accountant / storekeeper / sales Permission (id, key, description) ← مثال: "sales.create", "inventory.read" RolePermission (role_id, permission_id) Category (id, name) Product (id, sku, name, category_id, cost_price, sell_price, stock, reorder_level, is_active) StockMovement (id, product_id, type, qty, ref_type, ref_id, note, created_at) ← in/out/adjust Customer (id, name, phone, email, balance) SalesInvoice (id, number, customer_id, user_id, date, status, subtotal, discount, total) SalesItem (id, invoice_id, product_id, qty, unit_price, line_total) Supplier (id, name, phone, balance) PurchaseOrder (id, number, supplier_id, user_id, date, status, total) PurchaseItem (id, po_id, product_id, qty, unit_cost, line_total) ``` **The pivotal relationship:** Any SalesItem decreases Product.stock and performs a StockMovement (out) . Any PurchaseItem increases it and performs a StockMovement (in) . This is the heart of ERP —data moves on its own. --- # 🚀 Stages Each stage contains: **Goal · Required · Not Now · Finish Mark · Prompt Ready to Copy**. --- ## Phase 0 — Setup ** Objective: * * A working empty project with a stack + connected database + basic layout + sidebar without any features . ** Required: ** - Scaffold the project ( Next.js + TS + Tailwind + shadcn / ui ). - Connecting Prisma to the database + First empty migration . - Basic Layout : sidebar containing links to upcoming stages ( placeholders ) + header . - A simple `/` page " Hello ERP ". **Not now :* * Any auth , any real spreadsheet, any feature page . **Completion Mark ( Definition of Done ): ** - ` npm run dev ` works without errors. - Prisma is connected and the migration is working. - I check the layout and sidebar in the browser. > ** Prompt For copying:* * > ``` > Read CLAUDE.md and ERP-BUILD-GUIDE.md first. We are only in Phase 0 (foundation). Create a scaffold for the Next.js project (App Router) + TypeScript + Tailwind + shadcn / ui , Connect Prisma to SQLite with the first empty migration , and create a basic layout with a sidebar. > With placeholders for the stages: Auth , Inventory, Sales, Purchases , Dashboard , A simple homepage. Don't build any other features . Let me know when you're finished. How do I try? Stop. > ``` --- ## Phase 1 — Auth (Login) ** Objective: * A user who can log in and out, and the pages are protected. ** Required: ** - Table ` User` + Auth.js ( credentials : email + password with hashing ). - Page `/ login` , logout , session . - Protecting internal pages (anyone not logged in will be thrown at `/ login` ). - Seed : One admin user to test. **Not now :** Roles and permissions (this is Phase 2 ), i.e., the inventory/sales screen. **Completion Mark : ** - Log in with admin and access the dashboard . - If I'm not logged in, I can't open any internal page. - I logged out successfully. > ** Prompt For copying:* * > ``` We're currently in Phase 1 ( Auth ) . Add the User table in Prisma + Auth.js ( credentials ). > email/ password with secure hashing ), page/ login , logout , and protection of all internal pages. Create a seed account for an admin user to test it. Don't do that. roles /permissions Now . Tell me. How > I'm trying to log in and out, then I'll pause for a review. > ``` --- ## Phase 2 — Roles & Permissions (RBAC) ** Objective: * Every user has a role, and every role has permissions, and the system respects them in the UI and API . ** Required: ** Role` , `Permission`, ` RolePermission` tables + bind ` User.role_id` . - 4 roles: admin / accountant / storekeeper / sales , and permissions in the ` module.action` style . - Helper ` can ( user, " sales.create ") ` is used in the API and UI . - Hide links/buttons based on permissions + reject the API if there are no permissions. - A simple screen for managing users and their roles ( admin only). - Seed : The four users in their respective roles. **Not now :* * Any data module (inventory/sales). **Completion Mark : ** - I'm in sales and I can't see the accounting screens. API He refuses any action that is not within my rights, even if I call him by hand . > ** Prompt For copying:* * > ``` We are in Phase 2 ( Roles & Permissions) . Add the Role /Permission/ RolePermission tables. > And link the user to the role. Create 4 roles ( admin, Accountant , storekeeper , sales ) and their permissions > in module.action style , and helper The `can ( )` function applies in both the UI (hide) and API (reject). Work admin screen for managing users and roles + seed For four users . Don't build Modules > Data. Tell me How do I try to differentiate between a turn and a turn, stop. > ``` --- ## Phase 3 — Inventory ** Objective: * * First real data module — items, balances and inventory movement. ** Required: ** - Tables ` Category` , `Product`, ` StockMovement` . - CRUD for items ( list + add + edit ) is protected by the ` inventory .* ` permission. - Display current balance + manual balance adjustment function ` StockMovement` ( adjust ) . - Visual alert if the balance is < ` reorder_level `. - Seed : A few varieties and categories . **Not now :* * Linking inventory to sales/purchases ( will come with each module ). **Completion Mark : ** - I add an item and it appears in the list with its balance. - I manually adjust the balance and the transaction is recorded . - Items that are below the minimum order quantity are distinguished . > ** Prompt For copying:* * > ``` We are in Phase 3 (Inventory) . Add the Category , Product, StockMovement + CRUD tables. For items protected by inventory privileges , view the balance and enable manual balance adjustment. StockMovement , and highlight items below the order limit. Seed for experimental items. Not tied to sales . Now . Tell me . How do I try? Stop. > ``` --- ## Phase 4 — Sales ** Objective: * A sales invoice that automatically deducts from inventory — the most important flow in the system. ** Required: ** - ` Customer` , ` SalesInvoice` , ` SalesItem` tables . - Sales invoice creation screen (select customer + items + quantities) protected by ` sales .* `. - When saving: Calculate the total + **deduct the quantity from ` Product.stock` ** + perform ` StockMovement` (out) — all in ** one transaction **. - Sales are prohibited if the balance is insufficient. - Invoice list + Invoice display page. - Customer management ( basic CRUD ). **Not now :** Returns, Advanced Printing, Purchases. **Completion Mark : ** - By creating a sales invoice → the inventory decreases immediately and the transaction is recorded . I can't sell more than the balance. > ** Prompt For copying:* * > ``` We are in Phase 4 (Sales) . Add Customer. SalesInvoice , SalesItem . Create an invoice screen. The sales (customer + items + quantities) are protected by sales .* When saving, calculate the total and deduct from > Product.stock and perform StockMovement (out) in a single transaction , and prevent the sale if the balance is insufficient. Not enough. Create an invoice list + invoice display + customer CRUD + seed . Don't process returns or anything. > Purchases. Tell me How do I try a complete sales cycle, stop. > ``` --- ## Phase 5 — Purchases ** Objective: * * Purchase order to replenish inventory — reverse sales. ** Required: ** - Tables ` Supplier` , ` PurchaseOrder` , ` PurchaseItem` . - Purchase order screen (supplier + items + quantities + cost) protected by ` purchases .* `. - Upon receipt: **increase ` Product.stock` ** + ` StockMovement` (in) in transaction . - Update ` cost_price` for the item (optional) + purchase order list + CRUD for suppliers. **Not now :* * Complex financial calculations, the dashboard . **Completion Mark : ** - By placing a purchase order and receiving it → the inventory increases and the transaction is recorded. > ** Prompt For copying:* * > ``` We are in Phase 5 ( Purchases ) . Add Supplier. PurchaseOrder , PurchaseItem . Screenshot A purchase order (supplier + items + quantities + cost) is protected by purchases .* , and upon receipt, provide > Product.stock and perform StockMovement (in) in the transaction . Order List + CRUD Suppliers + Tell me . How do I try a complete buying cycle? Stop. > ``` --- ## Phase 6 — Dashboard & Reports ** Objective: * * The complete picture — numbers and graphics collected from all modules . ** Required: ** - The Dashboard page contains KPIs : Total sales for the month, number of invoices, items under order, top-selling items. - A simple graph (sales in days/months) using a lightweight charts library. - Low stock items report + Top customers report. - Everyone sees according to their own authority. **Not now :* * Advanced PDF/Excel export , AI . **Completion Mark : ** After I buy/sell, the numbers are in the Dashboard It's changing, right? > ** Prompt For copying:* * > ``` We are in Phase 6 (Dashboard) . Create a Dashboard page with KPIs (monthly sales, number Invoices, items below order, best-selling items) + Simple sales graph + > Low-category and high-value customer reports, all within the established guidelines. Tell me. How do I test the numbers? > You speak after a sale/purchase, stop. > ``` --- ## Phase 7 — Improvements + AI Touches (Optional) > After the foundation is solid, you can add them one by one (each one being a small phase on its own): - 🤖 ** Assistant In Arabic : * * " Do it invoice For Ahmed B3 Laptop → The function is executed (calling ). - 📉 ** Expect Stock is depleted ** from the date of sale. - 📸 ** Reading Bills Suppliers Image ** ( OCR + AI ). - 🗣️ ** Reports By speaking ** ( Ask In Arabic → Table / Drawing ). - 🧾 print Bills PDF , returns, multi- currency , multi- warehouse . > ** Rule:* * Any addition from countries = independent phase , adopts and experiments on its own. --- # # ✅ reminder last - **Stage → Experience → Approval → Next stage .* * There is no "Do it all". - After each working stage: Make a ** commit ** (this is an excellent time to use Git as we learned ). - If a stage gets too big, divide it in half — smaller = safer and clearer. If you feel that the code is still Clinging on , **stop and clean up** before you continue. Good luck 🚀 — Syntax Academy
讨论