How dokkazy/melodicapp works
Main Components
• Frontend (melodic-app)
• Built with Next.js – responsible for routing (pages), rendering (React components), API calls, and client state management.
• Backend API (melodic-api)
• API Layer: The “Api” folder (controllers and middleware). This layer handles incoming HTTP requests (e.g., AuthController, BasketController, OrderController, etc.), applies middleware (for exception handling), and provides HTTP endpoints.
• Application Layer: Contains business logic such as commands, queries, events, and validations (e.g., “Application/Feature” folders for Basket, Brand, Order, and Speakers). It also includes contracts, mapping profiles, reusable extension methods, and exception definitions.
• Domain Layer: Holds core business entities/models, value objects, and domain exceptions that represent the ecommerce business (e.g., Brand, Basket, Order, Speaker, etc.).
• Infrastructure Layer: Includes database configurations, Entity Framework migrations, repositories, and other implementations related to data access (see “Infrastructure/Database” and “Infrastructure/Repositories”).
• Identity: Manages authentication/authorization, with its own DbContext and configurations (found under “Identity” directories).
Relationships and Interactions
• The Next.js frontend communicates with the ASP.NET backend using HTTP (see the endpoints defined in the “Api” controllers and supported by API routes in the frontend “app/api” folder).
• Within the backend, the API controllers funnel calls to the Application layer where business logic is executed.
• The Application layer interacts with the Domain layer (which encapsulates business rules) and makes calls to the Infrastructure layer for data persistence and retrieval.
• The Identity component (with its own context and services) interfaces mainly with user authentication and authorization scenarios, enabling secure access to API endpoints.
• Events such as OrderSubmitted and OrderPaid are handled within the Application layer to manage business workflows across different domains (e.g., updating a Basket or Speaker state).
Architectural Patterns and Design Principles
• Layered or Clean Architecture: The separation into API, Application, Domain, Infrastructure, and Identity layers suggests a design focused on separation of concerns.
• Command-Query Responsibility Segregation (CQRS) is visible in how the Application layer separates Commands (for creating/updating data) and Queries (for data retrieval).
• Event Handling: The use of event handlers (for OrderSubmitted and OrderPaid) demonstrates an event-driven approach for decoupled processing.
• Repository Pattern: Repositories are used for data access operations that abstract underlying database interactions.
Relevant Technologies, Frameworks, and Libraries
• Next.js for the frontend, leveraging React components, SSR, and API routes.
• ASP.NET Core for the backend web API.
• Entity Framework for the ORM, with migrations for database schema management.
• Libraries for authentication (using JWT settings and Identity).
• Various libraries for client utilities (hooks, toast, and UI components in melodic-app).
• At the top or left, show the “Client Browser” interacting with the “Frontend (melodic-app)” interface.
• Application layer to the Domain (where core business entities reside), and highlight that it also communicates with the Infrastructure layer for persistence.
• Identity section separately to show its role in authentication, ensuring it interacts with both the API (to protect endpoints) and its own DB (configured using Entity Framework migrations).