<analysis>**original_problem_statement:**
The user wants to build a replica of  with a completely new design and a yellow, blue, and purple theme. The application is named Airtime2Cash Nigeria.

**PRODUCT REQUIREMENTS:**

**User Frontend ():**
-   **Authentication:** Registration with legal name, active email, Nigerian phone number, BVN, NIN, username, password, and a 4-digit Transaction PIN. Users must upload an ID (Passport, NIN, or Driver's License, <500kb) for KYC verification. New users must be approved by an admin before they can access services.
-   **Dashboard:** Main user dashboard displaying wallet balance, stats, and a scrolling admin announcement board.
-   **Profile Page:** Users can view their profile details (name, email, phone, username, submitted ID) and change their password and Transaction PIN.
-   **Airtime to Cash:** A form for converting airtime. The form submission redirects the user to WhatsApp with a pre-filled message containing the transaction details, including a unique transaction ID.
-   **Wallet:** Users can view their wallet balance and request withdrawals to their bank account. Withdrawal requests are sent to the admin's preferred notification channel (WhatsApp/Telegram).
-   **Transaction History:** Users can view the status of their transactions (Pending, Approved, Rejected) in a paginated, two-column layout.
-   **Account Name Auto-fill:** On payment forms, the user's full name is automatically filled into the Account Name field and locked to prevent errors.

**Admin Backend ():**
-   **Authentication:** A separate, secure login page.
-   **Dashboard:** An overview of platform stats (total users, unverified users, etc.).
-   **User Management:** A paginated view of all users. Admin can Approve/Disapprove, Suspend, Delete, and individually credit/debit user wallets. Admin can also reset user passwords and Transaction PINs.
-   **KYC Management:** A paginated page to view users' KYC details (BVN, NIN, ID document). Admin can Approve/Reject submissions. Rejected users can re-submit.
-   **Transaction Management:** A paginated page to view and manage all user transactions (Approve/Reject).
-   **Settings:**
    -   **Conversion Rates:** Set rates, minimum conversion amounts, and policy links for each network.
    -   **General Settings:** Manage platform-wide settings like withdrawal charges.
    -   **Notice Board:** Post messages for the user dashboard's scrolling ticker.
    -   **AdSense:** A text box to save a Google AdSense script, which is rendered in non-intrusive locations on user pages.
    -   **Notifications:** Configure backend notifications, including Telegram bot credentials and choosing the preferred channel (WhatsApp/Telegram) for withdrawal alerts.
-   **Notifications:** Send emails to users for key events using Mailjet. Send notifications to the admin's Telegram for new transactions.

**User's preferred language**: English

**what currently exists?**
A full-stack application with a React frontend and a FastAPI/MongoDB backend. The user and admin sections are built out with distinct authentication. Core features are implemented, including user/admin dashboards, a complete KYC lifecycle (submission, admin review, rejection with re-submission), and transaction management.

Recent major completions include:
- A full wallet withdrawal system where funds are deducted upon request and refunded if rejected by an admin.
- A custom transaction ID format () that is now included in user history and WhatsApp notifications.
- Pagination and a two-column layout for all major data tables (Users, Transactions, KYC).
- User experience improvements like locking the account name on payment forms.
- A dynamic footer with an auto-updating copyright year.
- Refined Google AdSense placement to be less intrusive, based on user feedback.
- A backend notification system for admins via Telegram for new transactions.
- A migration from Resend to Mailjet for emails was started but is currently blocked.

**Last working item**:
-   **Last item agent was working:** Implementing an admin setting to choose the notification channel (WhatsApp or Telegram) for withdrawal requests. The user stated that withdrawal requests must go to whatsapp/telegram.
-   **Status:** IN PROGRESS
-   **Agent Testing Done:** N
-   **Which testing method agent to use?** both
-   **User Testing Done:** N

**All Pending/In progress Issue list**:
-   **Issue 1: Mailjet Integration Incomplete (P0)**
    -   **Description:** The migration from Resend to Mailjet for email notifications is blocked. The backend code has been updated, but it uses placeholder API keys. All email functionality is currently non-operational.
    -   **Attempted fixes:** The agent has updated  and  to support Mailjet. It has correctly identified the need for user credentials.
    -   **Next debug checklist:**
        1.  Use the  tool to request the **Mailjet API Key** and **Mailjet API Secret** from the user again. Explain that this is required to complete the email migration and fix notifications.
        2.  Once received, update the  and  variables in the  file.
        3.  Restart the backend service: backend: stopped
backend: started.
        4.  Trigger an action that sends an email (e.g., register a new user or have an admin approve a transaction) to test if the integration is working.
    -   **Why fix this issue and what will be achieved with the fix?** This will restore critical user communication for events like registration, account verification, and transaction status updates.
    -   **Status:** BLOCKED
    -   **Is recurring issue?** N
    -   **Should Test frontend/backend/both after fix?** backend
    -   **Blocked on other issue:** User input (API Keys).

**In progress Task List**:
-   **Task 1: Complete Admin-Chosen Withdrawal Notifications (P1)**
    -   **Where to resume:**
        1.  **Frontend ():** Add a UI component (e.g., a dropdown or radio button group) in the General Settings tab to allow the admin to select WhatsApp or Telegram as the .
        2.  **Frontend ():** Update the settings submission logic to include the  value when updating general settings.
        3.  **Clarification:** The user's request  is ambiguous. The agent implemented a *backend* notification to the admin's Telegram. It's unclear if the user also expects a *client-side redirect* for the user submitting the withdrawal. **The next agent must clarify this with the user before proceeding.**
        4.  **Frontend ():** Based on the clarification, update the withdrawal submission logic. If it's a client-side redirect, fetch the admin's  setting and redirect to the appropriate URL (WhatsApp or a new Telegram link).
    -   **What will be achieved with this?** The admin will be able to control how they are notified of new withdrawal requests, completing the user's request.
    -   **Status:** IN PROGRESS
    -   **Should Test frontend/backend/both after fix?** both
    -   **Blocked on something:** User clarification on the desired notification behavior (client-side redirect vs. backend-only alert).

**Upcoming and Future Tasks**
-   **Future Tasks:**
    -   **P2: Refactor :** The main backend file has grown to be very large and contains models, routes, and business logic all in one place. It should be broken down into a more maintainable structure (e.g., , , ).

**Completed work in this session**
-   **KYC Enhancement:** Added BVN and NIN fields to the KYC process, visible to admins.
-   **Wallet Withdrawal Feature:** Fully implemented the user withdrawal flow, including balance deduction, admin approval/rejection, and automated refunds on rejection.
-   **Custom Transaction ID:** Created and implemented a unique  transaction ID format across the application.
-   **Backend Notifications (Telegram):** Integrated Telegram for admin alerts on new transactions.
-   **Pagination & Layout:** Implemented pagination and a two-column grid on all user and admin list pages.
-   **UX - Account Name Lock:** The user's name is now auto-filled and locked on payment forms to enhance security and reduce errors.
-   **AdSense Placement:** Fixed AdSense errors and strategically placed ad units in the middle and bottom of pages as per user request.
-   **Dynamic Footer:** Added a site-wide footer with a copyright notice and an auto-updating year.

**Earlier issues found/mentioned but not fixed**
-   None.

**Known issue recurrence from previous fork**
-   None.

**Code Architecture**


**Key Technical Concepts**
-   **Frontend:** React, React Router, React Context API, Axios, TailwindCSS
-   **Backend:** FastAPI, Pydantic, Motor (async MongoDB driver)
-   **Database:** MongoDB
-   **Authentication:** JWT (JSON Web Tokens)
-   **Integrations:** Mailjet (in progress), Telegram, Google AdSense, WhatsApp (client-side)

**key DB schema**
-   **users:** 
-   **transactions:** 
-   **settings:** 
-   **notices:** 

**changes in tech stack**
-   Added  and  to .
-    has been logically replaced in the code but the package may still be in .

**All files of reference**
-   **/app/backend/server.py**: Heavily modified to add Mailjet logic, Telegram notifications, custom transaction IDs, and wallet withdrawal logic.
-   **/app/frontend/src/pages/AdminSettings.jsx**: Modified to add UI for Telegram configuration.
-   **/app/frontend/src/pages/UserWallet.jsx**: Modified to implement withdrawal form, auto-fill account name, and PIN verification.
-   **/app/frontend/src/pages/ConvertAirtime.jsx**: Modified to auto-fill account name and include transaction ID in WhatsApp message.
-   **/app/frontend/src/pages/KYCVerification.jsx**: Modified to add BVN/NIN fields.
-   **/app/frontend/src/pages/UserHistory.jsx**: Rewritten to support pagination and a two-column layout.
-   **/app/frontend/src/pages/AdminTransactions.jsx**: Rewritten to support pagination and a two-column layout.
-   **/app/frontend/src/pages/AdminUsers.jsx**: Rewritten to support pagination and a two-column layout.
-   **/app/frontend/src/pages/AdminKYC.jsx**: Rewritten to support pagination and a two-column layout.
-   **/app/frontend/src/components/Footer.jsx**: New file for the site footer.
-   **/app/frontend/src/components/UserLayout.jsx**: Modified to add the footer and fix AdSense placement.
-   **/app/frontend/src/components/AdminLayout.jsx**: Modified to add the footer.
-   **/app/frontend/src/components/GoogleAdSense.jsx**: Updated to handle different ad scripts and placements.
-   **/app/backend/.env**: Modified to remove Resend keys and add Mailjet placeholders.

**Areas that need refactoring**:
-   The  file is now over 1000 lines. It urgently needs to be broken down into separate files for models, routes, and services to improve maintainability.

**key api endpoints**
-   : Logic updated to handle  withdrawals, deduct from balance, and send Telegram notifications.
-   : Logic updated to handle refunding wallet on withdrawal rejection.
-   : Logic updated to save Telegram and other notification settings.

**Critical Info for New Agent**
-   **Mailjet Migration is BLOCKED:** The switch from Resend to Mailjet for emails is incomplete and all email functionality is currently broken. You **must** get the **Mailjet API Key and API Secret** from the user before proceeding with any other task.
-   **Clarify Withdrawal Notification Behavior:** Before completing the Admin-Chosen Withdrawal Notifications task, you must ask the user to clarify if the notification should be a backend-only alert for the admin (current implementation for Telegram) or a client-side redirect for the user (like the current WhatsApp flow for conversions).
-   **AdSense Placement:** The user is very particular about ad placement. The final agreed-upon locations are in the mid-section (between content blocks) and at the bottom of pages. **Never** place ads above the main navigation menu.
-   **Refactoring Overdue:** The  file is critically large. Propose refactoring this file into a more scalable structure after resolving the blocked Mailjet issue.

**documents and test_reports created in this job**
-    was updated by the testing agent.

**Last 10 User Messages and any pending HUMAN messages**
- on this page: https://cash-converter-11.preview.emergentagent.com/user/wallet the withdrawa request must go to whatsapp/telegram (depending on the one admin choses on the setup page)
- insert a footer Copyright © 2025. Airtime2Cash.com. Powered by Xpinokings Limited the year should be coded to change every new yeah (January 1st at midnight)
- ad is still showing before the menu. Remove ad access to top of the menu> force all ads to show mid section of the pages and at the bottom
- i dont want advert to show before the menu. all adverts should show below the page title
- remove that code and put this ... i want the advert to show in the most friendly part of the app so that users would not get offended
- i am waiting for approval. meanwhile, theire is adsense code error delete the current code on the app and inster this then test ...
- no-reply@pro.airtime2cash.com
- (Pending  for Mailjet API Key and Secret)
- change the email notification service from resend to Mailjet https://www.mailjet.com/docs/ then activate. my mailjet account is xpino2k@gmail.com
- 1. Let the transaction page, user management page, kyc page and all related pages have pagination of 20 items each in double columns ...

**Project Health Check:**
-   **Broken:** Email notifications are non-functional due to the incomplete Mailjet migration, which is waiting on user-provided API keys.
-   **Mocked:** None.

**3rd Party Integrations**
-   **Mailjet (Email):** Partially integrated. **Requires User API Key & Secret to function.**
-   **Telegram:** Integrated for backend notifications. Requires admin to configure Bot Token and Chat ID in settings.
-   **Google AdSense:** Integrated. Requires user to provide AdSense script via the admin panel.
-   **WhatsApp:** Used for client-side redirection on the airtime conversion form.
-   **Resend (Email):** Deprecated. In the process of being removed.

**Testing status**
-   **Testing agent used after significant changes:** YES
-   **Troubleshoot agent used after agent stuck in loop:** NO
-   **Test files created:** None in this session.
-   **Known regressions:** Email notifications are not working.

**Credentials to test flow:**
-   **Admin:**
    -   URL: 
    -   Username: 
    -   Password: 
-   **Test User:**
    -   URL: 
    -   Username: 
    -   Password: 
    -   Transaction PIN: 

**What agent forgot to execute**
-   The agent did not clarify the ambiguous user request regarding withdrawal notifications (client-side redirect vs. backend alert), making an assumption that could be incorrect.
-   The agent did not perform the  refactoring, which was noted as a need in the previous handover and has become more critical as the file has grown.</analysis>
