mirror of
https://github.com/acedanger/finance.git
synced 2025-12-05 22:50:12 -08:00
5.5 KiB
5.5 KiB
GitHub Copilot Instructions for my-bank-app
Project Goal
This project is a web user interface (UI) for a CRUD (Create, Read, Update, Delete) application managing financial transactions for multiple bank accounts. The UI follows a two-column dashboard layout (Alternative 3 from the design phase).
Technology Stack
- Framework: Astro (latest version)
- Language: TypeScript, JavaScript (client-side scripts), HTML, CSS
- Styling: Plain CSS (
src/styles/global.css) - Data: Currently using static JSON files (
src/data/accounts.json,src/data/transactions.json). The goal is to eventually replace this with a backend API.
Current State & Key Features
- Layout: A two-column dashboard layout (
src/layouts/BaseLayout.astro,src/pages/index.astro) is implemented.- Sidebar: (
src/components/Sidebar.astro) Contains account selection dropdown and a collapsible section for adding new transactions. Includes an account summary section. - Main Content: (
src/components/MainContent.astro) Displays the header with the current account name and the transaction list.
- Sidebar: (
- Components: Separate Astro components exist for major UI sections (Sidebar, MainContent, TransactionTable, AddTransactionForm, AccountSummary).
- Data Loading: Initial data for accounts and transactions is loaded from static JSON files on the server-side (
src/pages/index.astro). - Account Switching: Selecting an account from the dropdown in the sidebar correctly updates the Main Content area (header, transaction table) and the Account Summary section using client-side JavaScript (
<script>tag inindex.astro). - Collapsible Form: The "Add Transaction" section in the sidebar (
src/components/AddTransactionForm.astro) can be expanded and collapsed using client-side JavaScript (<script>tag inAddTransactionForm.astro). - Basic Formatting: Utility functions (
src/utils.ts) exist for formatting currency and dates, used both server-side and client-side (mirrored inindex.astroscript). - Types: Basic TypeScript types for
AccountandTransactionare defined insrc/types.ts.
File Structure Overview
src/components/: Reusable UI components.src/data/: Static JSON data files (temporary).src/layouts/: Base page layout(s).src/pages/: Astro pages (routes).index.astrois the main page.src/styles/: Global CSS styles.src/types.ts: TypeScript type definitions.src/utils.ts: Utility functions (formatting, etc.).public/: Static assets.
Next Steps & TODOs
- Backend API Integration:
- Define the expected API endpoints (e.g.,
GET /api/accounts,GET /api/accounts/:id/transactions,POST /api/transactions,PUT /api/transactions/:id,DELETE /api/transactions/:id). - Replace static JSON data fetching in
index.astrowithfetchcalls to the backend API during server-side rendering (or potentially client-side, depending on strategy). - Update client-side logic to interact with the API for CRUD operations.
- Define the expected API endpoints (e.g.,
- Implement Create Functionality:
- Add client-side JavaScript to the
AddTransactionForm.astrocomponent (or enhance the script inindex.astro) to handle form submission. - Prevent default form submission.
- Perform basic client-side validation (required fields, numeric amount).
- Send a
POSTrequest to the backend API with the new transaction data. - On success:
- Clear the form.
- Collapse the form (optional).
- Refresh the transaction list for the current account (either by re-fetching or adding the new transaction to the client-side state).
- Update the account balance display.
- Handle API errors (display messages to the user).
- Add client-side JavaScript to the
- Implement Update Functionality:
- Add event listeners to the "Edit" buttons in
TransactionTable.astro. - When "Edit" is clicked:
- Expand the
AddTransactionForm(or potentially use a modal). - Populate the form fields with the data from the selected transaction.
- Change the form's submit button/logic to perform an update (
PUTrequest to/api/transactions/:id).
- Expand the
- On successful update:
- Clear/reset the form.
- Refresh the transaction list.
- Update the account balance.
- Handle API errors.
- Add event listeners to the "Edit" buttons in
- Implement Delete Functionality:
- Add event listeners to the "Delete" buttons in
TransactionTable.astro. - When "Delete" is clicked:
- Show a confirmation dialog (e.g.,
window.confirm). - If confirmed, send a
DELETErequest to/api/transactions/:id.
- Show a confirmation dialog (e.g.,
- On success:
- Remove the transaction row from the UI.
- Update the account balance.
- Handle API errors.
- Add event listeners to the "Delete" buttons in
- Refine State Management: As complexity grows, consider a more robust client-side state management solution if passing data via
define:varsand simple DOM manipulation becomes unwieldy (e.g., using Nano Stores or a more full-featured framework integration if needed later). - Error Handling: Implement more robust error handling and user feedback for API calls.
- Styling/UI Improvements: Refine CSS, potentially add loading indicators, improve responsiveness further.
Code Style & Conventions
- Use TypeScript where possible.
- Keep components focused on specific tasks.
- Utilize utility functions for common tasks like formatting.
- Comment code where logic is complex.
- Prioritize semantic HTML and accessibility.