How programandonocosmos/cashtools-api works
Main Components
• API/Web Server: Representing the Rocket-based application running as the core HTTP/GraphQL server.
• GraphQL Layer: Highlight the GraphQL resolvers (in src/graphql_resolvers.rs) that handle query/mutation endpoints using Juniper.
• Services Layer: Include the distinct service components (in src/services) such as account, transaction, and user services that encapsulate business logic.
• Authentication Component: Show the JWT-based authentication (see src/jwt.rs) that secures access to API endpoints.
• External Integrations: Include components for external communications such as Nubank integration (modules under src/nubank) and possibly email sending (src/sendemail.rs).
• Utilities & Models: Although more internal, it’s useful to note that entities (src/entities) and models (src/models) represent the domain objects, while utilities (src/utils) provide supporting functionality.
Relationships & Interactions
• The API/Web Server (Rocket) receives HTTP requests and routes them to the corresponding GraphQL resolvers or REST endpoints.
• GraphQL resolvers interface with the services layer to perform business logic.
• Services interact with the Database (via Diesel) to perform CRUD operations.
• External integrations like the Nubank module and email functionality are invoked from within the services to handle specific tasks (e.g., authentication with an external banking API, sending notifications).
• The migrations folder and Diesel configuration indicate continuous schema evolution; include a note about this migration management as part of database setup.
Architectural Patterns & Technologies
• The project uses an MVC-like separation between models/entities (representing data), services (business logic), and the API layer (controllers/resolvers).
• The use of Diesel for database communication indicates a focus on strong typing and migration-based schema management.
• JWT authentication is key for API security.
• Rocket and Juniper define the structure for API endpoints (possibly REST and GraphQL).
• External integration modules (like src/nubank) show a plug-in approach to extend functionality.