How sourasishbasu/ledgerly works
Main Components
• Frontend: Although the file tree does not include a dedicated “frontend” folder, the README reveals that the user interface is built with NextJS. Represent this as a standalone “Website/NextJS” component that interacts with the backend API.
• Backend API Service: Use the “services/backend” directory as the basis for the core FastAPI service. This service handles user actions (registration, login, CRUD operations for receipts) and interacts with the database.
• Receipt OCR Service: Derived from “services/receipt-ocr,” this helper service processes receipt images using language models and extracts data. This is deployed as a container and mapped to an AWS Lambda function.
• Database: Represent the Postgres database (using AWS RDS or a containerized “postgres” option mentioned in the README, with the schema provided in ledgerly.sql). Label it appropriately with details like DB credentials and connection endpoints.
• AWS Storage: Include an “S3 Bucket” component for image storage. It serves as the repository for receipt images used by the backend.
• AWS Compute: Represent AWS Lambda (for running the receipt-ocr container image) and EC2 (for hosting Docker containers and running the main services).
• Reverse Proxy: Add Traefik as a dynamic reverse proxy that handles the routing of web requests, SSL termination (via Let's Encrypt), and log management.
• Monitoring Stack: Indicate the monitoring infrastructure including Prometheus (with its scraping configs), Grafana (for dashboard visualization), Node Exporter, cAdvisor, and GoAccess. These elements are crucial for performance and availability tracking.
Relationships and Interactions
• The frontend (NextJS website) for user interfaces.
• The backend API (FastAPI) service for RESTful requests.
• Within the backend service, denote interactions with:
• The S3 Bucket for image upload and retrieval.
• Container orchestration via Docker Compose, linking all containerized components (backend, receipt OCR, Traefik, monitoring tools) to the underlying EC2 host.
• For monitoring, show Prometheus scraping endpoints on all containerized services (via Node Exporter, cAdvisor) and Grafana reading from Prometheus. Also include GoAccess streaming logs from Traefik.
Architectural Patterns & Key Technologies
• Microservices: The separation between the backend (API) and receipt OCR logic demonstrates a microservices-type approach.
• Containerization: Emphasize the consistent use of Docker for reproducible deployments.
• Infrastructure-as-Code: Note the use of Ansible playbooks and Docker Compose for automated deployments.
• Cloud Integration: AWS services (ECR, Lambda, RDS, S3, EC2) and external integrations (Traefik, monitoring tools) are integral to the system.
• Observability: The inclusion of Prometheus, Grafana, Node Exporter, cAdvisor, and GoAccess indicates a strong focus on monitoring and log aggregation.