Skip to content

refactor: split shared into packages #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from

Conversation

tomast1337
Copy link
Member

@tomast1337 tomast1337 commented Jul 25, 2025

This pull request introduces several structural and configuration changes to the whole project, primarily focused on spiting the project server, web and shared packages into separate @nbw/backend, @nbw/frontend, @nbw/database, @nbw/song, @nbw/thumbnail, @nbw/sounds and @nbw/config.

The following diagram shows the new structure of the project:

graph TD
    subgraph "Applications"
        Backend["@nbw/backend<br/>(Backend App)"]
        Frontend["@nbw/frontend<br/>(Frontend App)"]
    end
    
    subgraph "Workspace Packages"
        Config["@nbw/config<br/>(Configuration)"]
        Database["@nbw/database<br/>(Database Entities & DTOs)"]
        Song["@nbw/song<br/>(Song Processing)"]
        Sounds["@nbw/sounds<br/>(Sound Management)"]
        Thumbnail["@nbw/thumbnail<br/>(Thumbnail Generation)"]
    end
    
    %% Workspace package dependencies
    Database --> Config
    Song --> Database
    Thumbnail --> Song
    
    %% Backend dependencies
    Backend --> Database
    Backend --> Song
    Backend --> Thumbnail
    Backend --> Sounds
    
    %% Frontend dependencies (through workspace)
    Frontend -.-> Config
    Frontend -.-> Database
    Frontend -.-> Song
    Frontend -.-> Thumbnail
    
    %% Styling
    classDef appStyle fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    classDef pkgStyle fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
    classDef leafStyle fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
    
    class Backend,Frontend appStyle
    class Database,Song,Thumbnail pkgStyle
    class Config,Sounds leafStyle
Loading

Bun and Testing Improvements

  • Refined test scripts in package.json to run tests specifically on src/**/*.spec.ts and e2e/**/*.spec.ts, improving test targeting and coverage.

  • Added .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc to document and enforce the use of Bun over Node.js, npm, pnpm, or vite, including recommendations for APIs, testing, and frontend workflows.

@tomast1337 tomast1337 self-assigned this Jul 25, 2025
@tomast1337 tomast1337 added enhancement New feature or request help wanted Extra attention is needed labels Jul 25, 2025
Copy link
Member

@Bentroen Bentroen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you for working on these changes =)

Some extra things (besides the review comments) we gotta make sure are working before merging:

  • Update VSCode workspace file, test running etc. to reflect the new project structure
  • Update GitHub Actions to reflect the new project structure

package.json Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had originally decided to leave build.ts in the root of the project, as it was depended upon by both the frontend and the backend. With the new project structure, doesn't it belong in one of the different packages we created?
(Adding @nbw/sounds as the one single global workspace dependency looks a bit weird to me, haha :) )

package.json Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, could we rename the build commands to use frontend and backend too, like the package names?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a result of introducing separate packages, first-party package imports have been grouped with third-party ones (see this file as an example). The @nbw/ group should be added as a local package group in ESLint - I'll look up how we can do this again :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the rest of the project's structure, this file could be moved to the source file's path, and renamed to stats.spec.ts (as we'll likely add test files for the other modules in there)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid all the repetition, would it be possible to use a shared tsconfig.json using extends with these common package configurations?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separate .gitignore files may not be necessary, in case the root's package.json already takes care of them

@Bentroen Bentroen mentioned this pull request Aug 13, 2025
21 tasks
@tomast1337 tomast1337 requested review from Bentroen and Copilot August 14, 2025 13:50
@tomast1337 tomast1337 linked an issue Aug 14, 2025 that may be closed by this pull request
21 tasks
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR restructures the monorepo by splitting the original server, web, and shared packages into focused workspace packages and applications. It creates a more modular architecture with separate packages for configuration, database entities, song processing, thumbnail generation, and sound management, while establishing clear dependency relationships between components.

  • Splits the monolithic structure into focused packages (@nbw/config, @nbw/database, @nbw/song, @nbw/thumbnail, @nbw/sounds)
  • Creates dedicated application packages (@nbw/backend, @nbw/frontend)
  • Updates all import paths throughout the codebase to use the new package structure

Reviewed Changes

Copilot reviewed 124 out of 398 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/configs/ New configuration package with shared constants and types
packages/database/ New database package setup with gitignore and eslint config
apps/frontend/ Updated frontend with new import paths and package structure
apps/backend/ Updated backend with new import paths and dependency references
package.json Root package updated with new workspace structure and exports
build.ts Updated build script to use new package imports

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

tomast1337 and others added 7 commits August 14, 2025 12:23
…s, moving frontend to apps/frontend and adding components package
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Project structure refactor
2 participants