How jdevries3133/calcount works
Project Type and Purpose
• The README makes clear that Calcount is “A GPT Calorie counter app.” This is a full-stack web application built using Rust.
• It integrates user management (auth), calorie tracking (balancing), content (blog) and interactive elements (count chat) for a personalized experience. External services such as Stripe for subscription management and OpenAI for language/model responses are also key.
File Structure for Architectural Components
• The Rust source files in the src/ directory are organized into modules such as auth, balancing, blog, count_chat, legal, metrics, preferences, and stripe. This modularizes the backend application’s functionality.
• The presence of Dockerfile, Makefile, and Terraform files (infra.tf) suggests containerized deployments and infrastructure-as-code practices.
• SQL migration files under the migrations/ directory and numerous sqlx query files indicate a strong database component with compiled queries.
• The src/static directory, Tailwind configuration (tailwind.config.js, tailwind.css) and HTMX files hint at a frontend layer delivered as static assets and enhanced via JavaScript.
• Several scripts and githooks provide details about deployment and development processes.
Main Components
a. Client/Frontend:
– Represent the browser/user interface, which loads static assets (HTML, CSS from Tailwind, JS, HTMX-based pages).
– Label how HTMX works with the backend for dynamic updates.
b. Web Server / Application Backend (Rust):
– Showcase the central Rust application which is composed of multiple modules:
• Authentication Module: (src/auth) for login, registration, session handling, and password reset.
• Calorie Balancing Module: (src/balancing) for tracking/checkpoint functions.
• Blog Module: (src/blog) for managing posts.
• Count Chat Module: (src/count_chat) that interacts with OpenAI and includes helper JS files.
• Preferences Module: (src/preferences) for handling user settings.
• Stripe Module: (src/stripe) for subscription creation, customer portal operations, webhooks, etc.
• Other modules such as legal, metrics, and shared middleware.
c. Database:
– A central SQL database that is managed by the migrations and sqlx query integrations.
– Show data flow between application modules and the database.
d. External Services:
– OpenAI API: Integrated in the count_chat module for LLM-powered functionality.
– Stripe API: Integrated in the stripe module for handling subscriptions, billing, and customer portal link creation.
e. Infrastructure / Deployment:
– Include containerization (Docker) and CI/CD pipelines (via GitHub workflows in .github/workflows/ci_cd.yml).
– Highlight infrastructure-as-code elements with Terraform (infra.tf).
Relationships and Interactions
• Backend modules communicating with the database using query executions.
Architectural Patterns and Technologies
• The project uses a modular monolithic architecture, where all business logic is split into clearly defined modules.
• MVC (or similar) aspects: Controllers (src/controllers.rs, src/routes.rs) manage requests, and models (src/models.rs, module-specific models in stripe, preferences, etc.) represent data.