How alexsantosfilho/desafio-dev works
Project Overview & Main Concern
• Project Type: This is a full-stack Ruby on Rails web application designed to process CNAB files—parsing, normalizing, and storing financial transaction data—and then display transactions by store along with account balances.
• Key Purpose: Facilitate file uploads (via a web form), parse the uploaded CNAB file, store the parsed data in a relational (PostgreSQL) database, and provide both a web UI and RESTful API (documented with Swagger via Rswag) to expose the functionality.
• Auxiliary Components: It also includes usage of Solid Cache, Solid Queue, and Solid Cable to manage caching, background jobs, and real-time communication respectively, as well as OAuth for authentication (and a simple sessions system) and overcommit for Git hook validations.
Analyzing the File Structure
• The project follows a standard Rails MVC structure with directories such as:
– app/controllers, app/models, app/views, and app/services where the core business logic occurs.
– app/javascript and app/assets for frontend assets and interactivity (leveraging Hotwire and Turbo).
– config for environment configuration, routes, database connections, and initializer scripts.
• There’s a dedicated directory structure for jobs, mailers, channels, and repositories as well, indicating clear separation of concerns.
• The inclusion of Dockerfile, docker-compose.yml, and various Git hook configurations (Overcommit, Kamal hooks) highlight that deployment and code quality checks are an integral part of the project.
a. Frontend Layer
– Web Interface: Views rendered from app/views (and assets in app/assets and JavaScript controllers in app/javascript) to provide the UI for file upload, transaction listings, dashboard, and login pages.
– API Documentation: Swagger UI (served at /api-docs) which leverages Rswag.
b. Backend Application Layer
– Controllers (e.g., SessionsController, TransactionsController, Api::V1::CnabController): Responsible for handling HTTP requests, initiating file upload processing, authentication (including OAuth callbacks) and API requests.
– Services: CNAB parsing logic (CnabParserService), transaction importing logic (Transactions import service), and store balance updater that encapsulates business logic.
– Jobs: Background processing through Solid Queue jobs for tasks like processing transactions asynchronously.
c. Database Layer
– PostgreSQL database holds the primary data models (Stores, Transactions, Users, Sessions).
d. External & Auxiliary Services
– External Authentication via OAuth (for Google, etc.)
– Real-time updates with Solid Cable (for live updates using Turbo Streams)
– Caching with Solid Cache and background job processing with Solid Queue
– Git hooks & code quality tools (Overcommit) and Docker for development and deployment.
Relationships, Data Flow & Architectural Patterns
• Clear separation of concerns (MVC) where incoming requests from the client (uploading a CNAB file or triggering an API call) flow from the frontend (via controllers) to the services that parse the file and update the models, which in turn interact with the PostgreSQL database.
• Database relationships (Store – Transaction and User – Session) and the REST API endpoints with proper versioning.
• Additional layers for Docker encapsulation (container boundaries) and external integrations (OAuth providers) should be highlighted.