How iamgolden55/tax-invoice-agent works
Main Components Identification
• API Server: Represent the FastAPI server (located in the api folder and initiated with main.py) which exposes an endpoint (/ask) to serve client requests.
• LangChain Agent: Highlight the standalone agent logic (agent.py) where interactions with the OpenAI API occur.
• Data Processing & Analysis: Show the CSV dataset (in the data directory) that feeds salary details for generating payslips and performing analyses.
• Tools Module: Include components from the tools folder, such as:
• data_retriever.py: Handles data access.
• email_sender.py: Manages the email dispatch of payslips.
• invoice_generator.py: Handles PDF generation for invoices.
• Output Artifacts: Display the generated PDFs:
• Payslips (in the payslips folder)
• Invoices (in the invoices folder)
Relationships and Interaction Flow
• Clients (could be via Postman, EchoAPI, or any external system) send POST requests to the FastAPI endpoint (/ask).
• The FastAPI server (api/main.py) routes the queries to the LangChain Agent (agent.py) which decides the necessary action.
• For payslip generation, it interacts with the CSV dataset in the data folder.
• For PDF conversion, it calls tools/invoice_generator.py and possibly a corresponding tool for generating payslips.
• For emailing, it calls tools/email_sender.py.
• For data analysis, the agent processes the CSV dataset to calculate metrics such as average salary.
• The generated PDFs are then stored in the corresponding directories (invoices or payslips) and can optionally be emailed back to the users.
• The response is then delivered over the API.
Architectural Patterns & Design Principles
• Separation of Concerns: Different modules handle distinct tasks (API routing, agent logic, PDF generation, emailing, and data retrieval).
• Integration with External APIs: Emphasize the integration with the OpenAI API and LangChain library.
• Deployment Considerations: Highlight that Heroku deployment uses Procfile and runtime.txt to manage the Python runtime environment.
Relevant Technologies & Frameworks
• FastAPI: For building the RESTful API.
• LangChain & OpenAI API: For the intelligent agent processing queries.
• Python Tools: Including modules for PDF generation, email sending, and CSV data manipulation.
• Heroku: Hosting and deployment platform.
• Possibly Uvicorn: As the server runner.
Elements
• Each component should be clearly labeled (e.g., "FastAPI Server", "LangChain Agent", "CSV Data Source", "Payslip Generator", "Email Sender").
• Data input from clients to API server.
• API server forwarding requests to the LangChain Agent.
• The output artifacts being saved in specific folders.
Detailed Component Overview
• API Layer:
• “api/main.py” as the entry point for requests.
• Annotation for endpoints (e.g., /ask).
• Intelligent Agent:
• “agent.py” as the central logic component that interprets and decides on actions.
• Data Layer:
• “data” folder with the CSV salary dataset.
• That this dataset is the source for payslip generation and analytics.
• Tools Layer:
• Lay out the three major utilities in the "tools" folder, mapping them to their function (data retrieval, email sending, invoice generation).
• Output/Artifacts:
• Storage for “payslips” and “invoices”.
• Flow from the agent’s instructions to the generation and storage of PDFs.
• External Services:
• A reference for the OpenAI API and any deployment-related services (Heroku).