How dakshesh14/anukool works
Project Type and Purpose
• This is a single-page, AI-powered web application designed to help job seekers generate customized cover letters.
• The project leverages FastAPI as its backend framework and uses AI models (by default OpenAI’s or alternatively a local Llama-2 model) to craft cover letter content.
• The application includes components for PDF ingestion, template-based HTML rendering, and dynamic interactions via static assets (JS and CSS).
Analyzing the File Structure
• Top-level files like main.py and ingest.py indicate entry points for the web server and for preparing document data.
• The presence of a data_model folder (with query.py and an __init__.py) suggests a module responsible for managing data queries or interactions.
• Helper modules (helper.py, constants.py) indicate utility functions and constant definitions that support the application's core logic.
• The templates folder contains HTML files (including those for PDF output) that serve as the frontend’s view layer.
• The static folder houses CSS, JavaScript, and image resources which are critical for the client-side presentation.
• The .env.example file and requirements.txt indicate that environment configuration and dependency management are important parts of the deployment process.
Key Components to Highlight
a. Frontend:
• User Interface: Represented by the HTML templates (templates/index.html, templates/pdf/cover_letter.html) and static assets (CSS, JS, images). This component handles user interaction in the browser.
b. Backend:
• Ingest Module: ingest.py manages the ingestion of PDFs into the system. This should be depicted as a separate process/module that integrates with data sources.
• Data Model and Helper Layers: Group data_model (with its query capabilities) and helper.py (along with constants.py). This layer provides business logic, query processing, and abstraction over raw data.
• Environment Configuration: Show .env (populated from .env.example) to indicate that runtime configuration (like selecting the AI model or providing API tokens) influences backend behavior.
c. AI and Model Integration:
• External AI Service: Represent the integration with OpenAI’s API (by default) or a local Llama-2 model (when configured). Highlight that the choice is driven by the MODEL_NAME variable in the environment and model files downloaded into a “models” folder (note: although the file tree does not show a models folder, the README mentions that one should be created/populated as needed).
• LangChain Integration: Include this as part of the processing pipeline that might orchestrate interactions between the backend and the AI model.
Interactions and Data Flow
• The FastAPI backend processes the request (using main.py), possibly invoking functions in helper.py or modules in data_model.
• If the user triggers cover letter generation or PDF creation, the backend module assembles the content, calls the external AI service using either OpenAI or the locally served Llama-2 model (as determined by the environment configuration).
• Data returned from the AI service is passed back to the backend, which then renders HTML templates (located in the templates folder) or produces a generated PDF.
• Finally, the response (HTML page or downloadable PDF) is sent back to the client.
Architectural Patterns and Design Principles
• Separation of Concerns: The system is modular, clearly separating the UI (templates/static), application logic (FastAPI and helper modules), and external integrations (AI model services).
• Configurability: With environment variables handling model selection and API tokens, the design allows dynamic behavior based on deployment (local model vs. external API).
• Extensibility: The clear structure (with distinct data_model and ingestion modules) suggests that future additions (like new data sources or functionalities) can be added without major refactoring.