This monorepo contains a shared React package (@repo/app
) that adapts to different environments, powering both a Vite-based web app and an Electron-Vite desktop app. It uses Turborepo for efficient management and development across packages, with UI components powered by shadcn/ui and code formatting handled by Prettier.
- ✅ Shared Codebase:
@repo/app
adapts to web or desktop environments - ✅ TypeScript: Ensures type safety across the entire project
- ✅ Vite & Electron-Vite: Fast development for both web and desktop
- ✅ Bun Backend: High-performance API with Hono and tRPC
- ✅ Turborepo: Efficient monorepo management and task running
- ✅ shadcn/ui: Beautifully designed components that you can copy and paste into your apps
- ✅ Prettier: Consistent code formatting across the entire project
- ✅ S3 Storage: Utilizes Amazon S3 buckets for efficient file storage and retrieval
- ✅ Electron-builder: Automated build and distribution process for the desktop app
- ❌ Electron Updates: Implementing auto-update functionality for the desktop app
/apps
/web
/desktop
/backend
/site
/packages
/app
/ui (shadcn/ui components)
/shared
/typescript-config
@repo/app
: Shared React<App />
component
web
: Vite-powered React web applicationdesktop
: Electron-Vite desktop applicationbackend
: Bun-based backend service with Hono and tRPC
@repo/ui
: Shared UI components (powered by shadcn/ui)@repo/shared
: Reusable components, hooks, and API integrations@repo/typescript-config
: Base TypeScript configuration
- Clone the repository:
git clone https://github.com/JakubGluszek/unified-app-monorepo.git cd unified-app-monorepo
- Install dependencies:
pnpm install
- Set up environment variables
Run all apps:
pnpm dev
Run specific apps:
pnpm dev --filter web
pnpm --filter desktop desktop:dev
pnpm dev --filter backend
Build web & backend apps:
pnpm build
Build desktop app:
pnpm --filter desktop build:linux
pnpm --filter desktop build:win
pnpm --filter desktop build:mac
This project uses Electron-builder to package and distribute the desktop application. The configuration for Electron-builder can be found in the electron-builder.yml
file. Here's what you need to know:
- Build Configuration: The
electron-builder.yml
file defines build settings for Windows, macOS, and Linux platforms. - Automated Builds: GitHub Actions are used to automate the build process for different platforms.
- Auto-updates: The project is set up to support auto-updates, but this feature is not yet implemented. The update server URL in the
electron-builder.yml
file will need to be configured once the Astro site and proxy server are set up.
To ensure secure builds and deployments, you need to set up the following secrets in your GitHub repository:
VITE_API_BASE_URL
: The URL of your deployed API serverAWS_ACCESS_KEY_ID
: Your AWS access key for S3 bucket accessAWS_SECRET_ACCESS_KEY
: Your AWS secret key for S3 bucket accessS3_BUCKET_NAME
: The name of your S3 bucket for storing buildsAWS_REGION
: The region of your S3 bucket, e.geu-north-1
SERVER_SSH_PRIVATE_KEY
: The private key for SSH access to your serverSERVER_IP
: The IP address of your serverSERVER_USER
: The username for SSH access on your serverBACKEND_PORT
: Specify on which port should the backend app run
To add these secrets:
- Go to your GitHub repository
- Navigate to Settings > Secrets and variables > Actions
- Click on "New repository secret" and add each secret
This project uses Amazon S3 buckets for storing application builds. Here's how it's currently utilized:
- Build Storage: Compiled application builds are uploaded to the specified S3 bucket.
- Future Update Distribution: Once implemented, the auto-update feature will fetch updates via the proxy server, which will retrieve files from the S3 bucket.
To add new shadcn/ui components to your project, use the following command:
pnpm ui add <component-name>
This project uses Prettier to ensure consistent code formatting. To format your code, run:
pnpm format
To check if your code is properly formatted without making changes, use:
pnpm format:check
This project uses GitHub Actions for continuous deployment of the web and backend applications to a self-hosted Linux server. Here's an overview of the deployment process:
- The pipeline is triggered on pushes to the
main
branch that affect theweb
,backend
, or sharedpackages
. - It builds the web and backend applications using the project's build scripts.
- Only the compiled
dist
directories are deployed to the server.
- The deployment assumes PM2 is installed globally on the server for process management.
- The web application is served using PM2's serve functionality.
- The backend application is run as a Bun process managed by PM2.
On the server, the applications are structured as follows:
~/app/
└── backend/
├── index.js
└── .env
/var/www/html/web/
├── index.html
├── static/
└── vite.svg
-
Update
pnpm run clean
to usepnpm
scripts instead of a shell script -
Added workflow for deploying the
web
andbackend
apps -
Develop API for downloading releases
-
Create Astro "site" App:
- Set up the
apps/site
directory for the Astro-based website. - Develop the landing page with
/register
and/login
routes.
- Set up the
-
Develop API for Authentication:
- Implement secure user authentication for the API application.
- Ensure integration with the Astro site, web app, and desktop app for login and registration.
-
Enhance API App for Download Management:
- Update
apps/api
to handle download request proxying:- Implement rate limiting.
- Secure proxying of downloads from S3.
- Create endpoints for version info and update checks.
- Update
-
Modify S3 setup to work with the new API proxy
-
Implement Auto-Update Functionality:
- Set up auto-update functionality for the desktop application.
- Configure Electron-builder for the new update mechanism.
- Fork the repository
- Create your feature branch:
git checkout -b feature/AmazingFeature
- Commit your changes:
git commit -m 'Add some AmazingFeature'
- Push to the branch:
git push origin feature/AmazingFeature
- Open a pull request
This project is licensed under the MIT License. See the LICENSE file for details.