How towa1204/nhk-plus-board works
Main components
• Frontend Presentation Layer:
• "routes" directory: This includes pages, middleware ( _middleware.ts ), error pages (_404.tsx, _500.tsx ), and layout definitions (_layout.tsx & _app.tsx).
• "components" directory: Basic UI components like Button, HomeButton, ProgramCard, etc.
• "islands" directory: Interactive parts of the UI that provide client-side interactivity, such as ProgramForm and ProgramInput.
• "static" files: Styling resources (styles.css) and configuration for Tailwind.
• Backend / Business Logic Layer:
• "backend" directory: Contains domain logic split into several layers:
▪ "client": Handles external API integrations (e.g., LineClient, NhkPlusClient, relevant tests, and API type declarations).
▪ "common": Utility functions, custom exceptions, and common types that support the whole backend.
▪ "repository": Data persistence or storage related logic (e.g., AppSettingRepository, WatchProgramKeysRepository) likely simulating a persistence layer.
▪ "service": Business logic encapsulating application flows (e.g., AppSettingService, MainFlowService, NhkPlusProgramService) with corresponding tests.
• "backend/testdata": Sample JSON files for testing configurations and search result outputs.
• Infrastructure and Configuration:
• Deployment and environment: Files such as .env.example, GitHub workflows, and config files (deno.json, fresh.config.ts, tailwind.config.ts) that manage deployment, environment variables, and project configurations.
• Main entry points like dev.ts, main.ts, and cron.ts represent scheduled tasks and bootstrapping of the server.
Relationships and interactions
• The Fresh framework serves as the glue for the UI and server, using the "routes" and "islands" directories to inject dynamic content into the HTML.
• The routes (controller layer) are responsible for interacting with the backend services. When a route is triggered, it can call a service from the "backend/service" layer to perform application logic.
• The service layer communicates with repository classes to fetch or update data, while also potentially interacting with external APIs via clients in "backend/client".
• Utility and common functions in "backend/common" are accessed by multiple parts of the backend (service, repository, etc.) to manage shared concerns like date formatting, exception handling, or key-value utilities.
• The infrastructure components (GitHub workflows, config files) support continuous integration/deployment, environment configuration, and static asset management.
Architectural patterns in use
• MVC-like pattern: The routes act as controllers and views, while the backend organizes business logic (models, services, repositories).
• Separation of concerns: Clear boundaries among presentation (routes, islands, components), business logic (services), data access (repositories) and infrastructure (external client integrations).
• Testing layers: Test files exist for client, common utilities, and services, highlighting a test-driven development approach.
• From user request at the Frontend (routes) flowing into the Backend.
• From the service layer to the repository and vice versa.
• UI components (e.g., rectangles for routes, circles for interactive islands).
• Additionally, include any supporting tools or configurations (like GitHub actions as part of CI/CD) in an “Infrastructure” section.