How athachai29/chordhub works
Main Components
• Frontend Client:
• Built with the Nuxt3 framework (app.vue, nuxt.config.ts, pages, layouts, and components directories).
• Contains UI elements, views (e.g., artist, editor, login, register, profile, song pages), and styling (assets with Tailwind CSS).
• Dedicated to rendering the chord and lyric displays according to the ChordPro standard.
• Backend/API Server:
• Located in the “server” directory.
• Provides API routes for authentication (login, register, check email, session), songs (fetching details, updating, submitting, searching), user management (favorites), and sitemap generation.
• Uses middleware for authorization and models (in server/models) to represent data constructs such as accounts, artists, logs, requests, and songs.
• Includes plugins like the database connection (server/plugins/db.ts).
• Utilities and Helpers:
• “utils/sheet-formatter”: Contains logic for formatting chord sheets which adapts the chords/lyrics display.
• “utils/validators.ts”: Likely used on both sides for input validations.
• Language Support:
• “lang” directory with language files (en-US.ts, th-TH.ts) to support localization.
Relationships and Interactions
• The Frontend interacts with the Backend through API calls:
• For authentication flows (login, register).
• For song-related interactions: searching for songs, retrieving song details including chords/lyrics, and managing favorites.
• The API Layer organizes routes in modules (auth, songs, users) and uses middleware (e.g., auth.ts) to secure endpoints.
• The database is accessed via the db plugin to store and retrieve data represented by models.
• Utilities such as the sheet formatter integrate with the frontend display to ensure that ChordPro formatted content is rendered correctly.
• Localization support is provided to adapt UI text based on user language preferences.
Architectural Patterns and Design Principles
• Separation of Concerns:
• Clear separation between frontend (UI, client-side routing) and backend (RESTful API endpoints, business logic, data models).
• Modularization:
• Directory structures like “components” and “pages” in the frontend and “api”, “models”, “middleware” in the backend help to logically segment functionality.
• API-First Design:
• The backend API is structured using file-based routing which is strongly associated with Nuxt3 capabilities, making it easier to add new endpoints.
• Extensibility:
• The inclusion of utilities and language modules facilitates adding new features or supporting additional languages.