How javierscode/check-my-menu works
Main Components
• Backend Service: An Express.js application that follows hexagonal architecture. Its components include:
• Domain Layer: Entities (e.g., category, dish, restaurant, user), value objects, enums, and domain-level exceptions.
• Application Layer: Use-cases (e.g., create, edit, delete functionality for categories, dishes, restaurants, and user authentication) and application-specific exceptions.
• Infrastructure Layer: Controllers (handling HTTP requests), dependency injection setup, data transfer objects (DTOs), middlewares (auth, error handling), routing, persistence repositories (both in-memory and PostgreSQL implementations), and external utilities (e.g., JWT service, crypto, math utilities).
• Frontend Service: A Next.js application that contains:
• Client-side components: Organized into atoms, molecules, and organisms (e.g., AdminAside, DishCard, CategoryCard).
• Pages and routes: Both public (menu view for customers, domain-specific pages) and private administrative routes (for restaurant management) with associated server-side rendering logic (using get-server-side-props patterns for authentication).
• State and context management: Using custom hooks and context (such as auth context) to manage client-side state.
• API routes: Next.js API endpoints that complement the frontend functionality, particularly for authentication and data manipulation.
• Database: PostgreSQL is used as the primary persistence layer with Docker Compose handling service startup (port 54320). The backend interacts with this database through specific PostgreSQL repository implementations.
• Shared/Supporting Packages:
• ESLint configuration and tsconfig packages standardize the coding guidelines and TypeScript configurations across the monorepo.
• CI/CD pipelines (GitHub workflows) also play a supporting role in ensuring the deployments for both backend and web.
Relationships and Interactions
• User Interaction: Clients (restaurant users and customers) interact with the Next.js frontend via a web browser.
• API Communication: The web frontend makes API calls—either directly on Next.js API routes or as proxy calls—to the backend to perform CRUD operations (e.g., logging in, managing menus, generating QR codes).
• Backend Processing: The Express backend processes incoming requests, routes them through its controllers, and then delegates commands/queries to the application use-cases, which in turn call the domain logic.
• Data Flow to Persistence: The infrastructure layer’s repository implementations (PostgreSQL / in-memory alternatives) perform the actual database operations.
• Dependency Management: The dependency injection container assembles the various modules (controllers, use-cases, repositories, services) to maintain loose coupling.
Architectural Patterns and Technologies
• Hexagonal Architecture: Emphasize how the backend is divided into core domain logic, application services (use-cases), and external adapters (controllers, persistence, DI).
• MVC and Component-Based UI: The frontend follows typical Next.js architecture (page-based routing combined with React component hierarchies ranging from atoms to organisms).
• Technology Stack:
• Backend uses Express.js, TypeScript, Jest (for testing), and Docker for containerization.
• Frontend uses Next.js, React, TypeScript, and supports both server-side rendering and client signaling.
• PostgreSQL handles data persistence.
Elements
• Clear Labels: Use clear labels to designate each major component (e.g., “Express Backend – Domain, Application, Infrastructure”, “Next.js Frontend – Client Components, API Routes, SSR Services”, “PostgreSQL Database”, etc.).
• Detail Core Services: Highlight key services like JWT authentication, image upload integration (via Supabase in the web backend), and QR generator services.
• CI/CD and DevOps: Optionally, include a smaller section to illustrate the automation (GitHub workflows, Docker Compose) ensuring deployments.