From ef21c52ce86dc78fab65e7f0a93ed9ef718bea04 Mon Sep 17 00:00:00 2001 From: Matheus Thibau Date: Wed, 8 Apr 2026 13:36:26 -0300 Subject: [PATCH 01/11] feat: add hooks and providers for message sending, locale, and theme management - Introduced `useSendMessage` hook for handling message sending with file upload support. - Added `useStationAlias` hook to manage station aliases. - Created `LocaleProvider` and `ThemeProvider` for managing application localization and theme settings. - Implemented Tailwind CSS configuration for styling. - Established TypeScript configuration for apps and packages. - Added ESLint configuration for Next.js projects. - Created utility functions for conversation and message handling in the `@platform/utils` package. - Developed UI components including dialogs, banners, and input fields in the `@platform/ui` package. - Set up workspace management with pnpm and Turbo for efficient development. --- .github/workflows/ci.yml | 24 +++ .github/workflows/deploy-hermes-chat.yml | 32 ++++ .gitignore | 14 +- README.md | 36 ---- .env.example => apps/hermes-chat/.env.example | 0 apps/hermes-chat/README.md | 122 +++++++++++++ .../hermes-chat/eslint.config.mjs | 4 +- .../hermes-chat/messages}/en.json | 0 .../hermes-chat/messages}/pt.json | 0 .../hermes-chat/next.config.ts | 2 +- apps/hermes-chat/package.json | 31 ++++ .../hermes-chat/postcss.config.mjs | 0 .../public}/logo-hermes-500-wings.png | Bin .../hermes-chat/public}/logo-hermes-500.png | Bin .../hermes-chat/src}/app/api/caller/route.ts | 0 .../src}/app/api/file/[fileid]/route.ts | 0 .../src}/app/api/files/[fileid]/route.ts | 0 .../hermes-chat/src}/app/api/login/route.ts | 0 .../src}/app/api/messages/[type]/route.ts | 0 .../src}/app/api/messages/file/route.ts | 0 .../src}/app/api/messages/route.ts | 2 +- .../app/api/messages/uncrypt/[id]/route.ts | 0 .../src}/app/api/schedule/route.ts | 0 .../src}/app/api/stations/route.ts | 0 .../hermes-chat/src}/app/api/sys/route.ts | 0 .../src}/app/api/sys/uuls/route.ts | 0 .../hermes-chat/src}/app/api/ufile/route.ts | 0 {src => apps/hermes-chat/src}/app/favicon.ico | Bin {src => apps/hermes-chat/src}/app/globals.css | 0 .../src}/app/home/chat/[station]/page.tsx | 2 +- .../src}/app/home/new-chat/page.tsx | 8 +- .../hermes-chat/src}/app/home/page.tsx | 8 +- .../src}/app/home/radio-info/page.tsx | 2 +- {src => apps/hermes-chat/src}/app/layout.tsx | 0 {src => apps/hermes-chat/src}/app/page.tsx | 2 +- .../src}/components/DeleteMessageButton.tsx | 2 +- .../src}/components/DoubleCheck.tsx | 0 .../hermes-chat/src}/components/Navbar.tsx | 2 +- .../src}/components/NewChatFab.tsx | 0 .../src}/components/NextSyncBadge.tsx | 0 .../components/chat/AttachmentPreview.tsx | 0 .../src}/components/chat/ChatHeader.tsx | 0 .../src}/components/chat/DateDivider.tsx | 2 +- .../src}/components/chat/FileAttachment.tsx | 0 .../src}/components/chat/MessageBubble.tsx | 10 +- .../src}/components/chat/MessageInput.tsx | 0 .../src}/components/chat/MessageList.tsx | 6 +- .../src}/components/home/ConversationItem.tsx | 4 +- .../src}/components/radio/CallerList.tsx | 0 .../src}/components/radio/InfoList.tsx | 0 .../src}/components/radio/SysInfo.tsx | 0 .../hermes-chat/src}/hooks/useAuthGuard.ts | 2 +- .../hermes-chat/src}/hooks/useChatData.ts | 4 +- .../hermes-chat/src}/hooks/useNodeInfo.ts | 0 .../hermes-chat/src}/hooks/useScrollPager.ts | 0 .../hermes-chat/src}/hooks/useSendMessage.ts | 0 .../hermes-chat/src}/hooks/useStationAlias.ts | 2 +- .../hermes-chat/src}/lib/hermesApi.ts | 0 .../src}/providers/LocaleProvider.tsx | 0 .../src}/providers/ThemeProvider.tsx | 0 .../hermes-chat/tailwind.config.ts | 13 +- apps/hermes-chat/tsconfig.json | 17 ++ package-lock.json | 162 +++++++++++++++++- package.json | 36 ++-- packages/config/eslint/next.mjs | 15 ++ packages/config/package.json | 10 ++ packages/config/tailwind/base.ts | 16 ++ .../config/typescript/base.json | 17 +- packages/ui/package.json | 19 ++ .../ui/src/components}/ConfirmDialog.tsx | 0 .../ui/src/components}/ErrorBanner.tsx | 0 .../ui/src/components}/LoadingSpinner.tsx | 0 .../ui/src/components}/PasswordDialog.tsx | 0 .../ui/src/components}/SearchInput.tsx | 0 packages/ui/src/index.ts | 5 + packages/ui/tsconfig.json | 8 + packages/utils/package.json | 11 ++ .../utils/src}/conversation.ts | 0 {src/lib => packages/utils/src}/formatting.ts | 0 packages/utils/src/index.ts | 11 ++ {src/lib => packages/utils/src}/message.ts | 0 {src/lib => packages/utils/src}/types.ts | 0 {src/lib => packages/utils/src}/user.ts | 0 packages/utils/tsconfig.json | 8 + pnpm-workspace.yaml | 3 + turbo.json | 17 ++ 86 files changed, 571 insertions(+), 120 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/deploy-hermes-chat.yml delete mode 100755 README.md rename .env.example => apps/hermes-chat/.env.example (100%) create mode 100755 apps/hermes-chat/README.md rename eslint.config.mjs => apps/hermes-chat/eslint.config.mjs (83%) rename {messages => apps/hermes-chat/messages}/en.json (100%) rename {messages => apps/hermes-chat/messages}/pt.json (100%) rename next.config.ts => apps/hermes-chat/next.config.ts (64%) create mode 100644 apps/hermes-chat/package.json rename postcss.config.mjs => apps/hermes-chat/postcss.config.mjs (100%) rename {public => apps/hermes-chat/public}/logo-hermes-500-wings.png (100%) rename {public => apps/hermes-chat/public}/logo-hermes-500.png (100%) rename {src => apps/hermes-chat/src}/app/api/caller/route.ts (100%) rename {src => apps/hermes-chat/src}/app/api/file/[fileid]/route.ts (100%) rename {src => apps/hermes-chat/src}/app/api/files/[fileid]/route.ts (100%) rename {src => apps/hermes-chat/src}/app/api/login/route.ts (100%) rename {src => apps/hermes-chat/src}/app/api/messages/[type]/route.ts (100%) rename {src => apps/hermes-chat/src}/app/api/messages/file/route.ts (100%) rename {src => apps/hermes-chat/src}/app/api/messages/route.ts (98%) rename {src => apps/hermes-chat/src}/app/api/messages/uncrypt/[id]/route.ts (100%) rename {src => apps/hermes-chat/src}/app/api/schedule/route.ts (100%) rename {src => apps/hermes-chat/src}/app/api/stations/route.ts (100%) rename {src => apps/hermes-chat/src}/app/api/sys/route.ts (100%) rename {src => apps/hermes-chat/src}/app/api/sys/uuls/route.ts (100%) rename {src => apps/hermes-chat/src}/app/api/ufile/route.ts (100%) rename {src => apps/hermes-chat/src}/app/favicon.ico (100%) rename {src => apps/hermes-chat/src}/app/globals.css (100%) rename {src => apps/hermes-chat/src}/app/home/chat/[station]/page.tsx (98%) rename {src => apps/hermes-chat/src}/app/home/new-chat/page.tsx (94%) rename {src => apps/hermes-chat/src}/app/home/page.tsx (93%) rename {src => apps/hermes-chat/src}/app/home/radio-info/page.tsx (96%) rename {src => apps/hermes-chat/src}/app/layout.tsx (100%) rename {src => apps/hermes-chat/src}/app/page.tsx (98%) rename {src => apps/hermes-chat/src}/components/DeleteMessageButton.tsx (96%) rename {src => apps/hermes-chat/src}/components/DoubleCheck.tsx (100%) rename {src => apps/hermes-chat/src}/components/Navbar.tsx (99%) rename {src => apps/hermes-chat/src}/components/NewChatFab.tsx (100%) rename {src => apps/hermes-chat/src}/components/NextSyncBadge.tsx (100%) rename {src => apps/hermes-chat/src}/components/chat/AttachmentPreview.tsx (100%) rename {src => apps/hermes-chat/src}/components/chat/ChatHeader.tsx (100%) rename {src => apps/hermes-chat/src}/components/chat/DateDivider.tsx (90%) rename {src => apps/hermes-chat/src}/components/chat/FileAttachment.tsx (100%) rename {src => apps/hermes-chat/src}/components/chat/MessageBubble.tsx (95%) rename {src => apps/hermes-chat/src}/components/chat/MessageInput.tsx (100%) rename {src => apps/hermes-chat/src}/components/chat/MessageList.tsx (94%) rename {src => apps/hermes-chat/src}/components/home/ConversationItem.tsx (94%) rename {src => apps/hermes-chat/src}/components/radio/CallerList.tsx (100%) rename {src => apps/hermes-chat/src}/components/radio/InfoList.tsx (100%) rename {src => apps/hermes-chat/src}/components/radio/SysInfo.tsx (100%) rename {src => apps/hermes-chat/src}/hooks/useAuthGuard.ts (91%) rename {src => apps/hermes-chat/src}/hooks/useChatData.ts (96%) rename {src => apps/hermes-chat/src}/hooks/useNodeInfo.ts (100%) rename {src => apps/hermes-chat/src}/hooks/useScrollPager.ts (100%) rename {src => apps/hermes-chat/src}/hooks/useSendMessage.ts (100%) rename {src => apps/hermes-chat/src}/hooks/useStationAlias.ts (94%) rename {src => apps/hermes-chat/src}/lib/hermesApi.ts (100%) rename {src => apps/hermes-chat/src}/providers/LocaleProvider.tsx (100%) rename {src => apps/hermes-chat/src}/providers/ThemeProvider.tsx (100%) rename tailwind.config.ts => apps/hermes-chat/tailwind.config.ts (56%) create mode 100644 apps/hermes-chat/tsconfig.json create mode 100644 packages/config/eslint/next.mjs create mode 100644 packages/config/package.json create mode 100644 packages/config/tailwind/base.ts rename tsconfig.json => packages/config/typescript/base.json (51%) mode change 100755 => 100644 create mode 100644 packages/ui/package.json rename {src/components/ui => packages/ui/src/components}/ConfirmDialog.tsx (100%) rename {src/components/ui => packages/ui/src/components}/ErrorBanner.tsx (100%) rename {src/components/ui => packages/ui/src/components}/LoadingSpinner.tsx (100%) rename {src/components/ui => packages/ui/src/components}/PasswordDialog.tsx (100%) rename {src/components/ui => packages/ui/src/components}/SearchInput.tsx (100%) create mode 100644 packages/ui/src/index.ts create mode 100644 packages/ui/tsconfig.json create mode 100644 packages/utils/package.json rename {src/lib => packages/utils/src}/conversation.ts (100%) rename {src/lib => packages/utils/src}/formatting.ts (100%) create mode 100644 packages/utils/src/index.ts rename {src/lib => packages/utils/src}/message.ts (100%) rename {src/lib => packages/utils/src}/types.ts (100%) rename {src/lib => packages/utils/src}/user.ts (100%) create mode 100644 packages/utils/tsconfig.json create mode 100644 pnpm-workspace.yaml create mode 100644 turbo.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1271ffb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - run: npm ci + + - name: Build & Lint (affected only) + run: npx turbo run build lint --filter='[HEAD^1]' diff --git a/.github/workflows/deploy-hermes-chat.yml b/.github/workflows/deploy-hermes-chat.yml new file mode 100644 index 0000000..2033fcf --- /dev/null +++ b/.github/workflows/deploy-hermes-chat.yml @@ -0,0 +1,32 @@ +name: Deploy hermes-chat + +on: + push: + branches: [main] + paths: + - 'apps/hermes-chat/**' + - 'packages/**' + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - run: npm ci + + - name: Build hermes-chat and its dependencies + run: npx turbo run build --filter=hermes-chat... + + # Replace the step below with your actual deploy command + # e.g. Vercel, Docker, SSH, etc. + - name: Deploy + run: echo "Add your deploy command here" + env: + # Pass any secrets your deploy needs + HERMES_API_URL: ${{ secrets.HERMES_API_URL }} diff --git a/.gitignore b/.gitignore index 22fa957..52c2315 100755 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies -/node_modules +node_modules /.pnp .pnp.* .yarn/* @@ -11,14 +11,18 @@ !.yarn/versions # testing -/coverage +coverage/ # next.js -/.next/ -/out/ +.next/ +out/ # production -/build +build/ +dist/ + +# turborepo +.turbo/ # misc .DS_Store diff --git a/README.md b/README.md deleted file mode 100755 index e215bc4..0000000 --- a/README.md +++ /dev/null @@ -1,36 +0,0 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). - -## Getting Started - -First, run the development server: - -```bash -npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev -``` - -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. - -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. - -## Learn More - -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! - -## Deploy on Vercel - -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. - -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. diff --git a/.env.example b/apps/hermes-chat/.env.example similarity index 100% rename from .env.example rename to apps/hermes-chat/.env.example diff --git a/apps/hermes-chat/README.md b/apps/hermes-chat/README.md new file mode 100755 index 0000000..849098c --- /dev/null +++ b/apps/hermes-chat/README.md @@ -0,0 +1,122 @@ +# Hermes Chat + +A [Next.js 15](https://nextjs.org) application inside a **monorepo** managed with [npm workspaces](https://docs.npmjs.com/cli/using-npm/workspaces) and [Turborepo](https://turbo.build). + +--- + +## Monorepo structure + +``` +hermes-chat/ ← root (orchestration only) +├── apps/ +│ └── hermes-chat/ ← this Next.js app +└── packages/ + ├── ui/ ← @platform/ui (shared React components) + ├── utils/ ← @platform/utils (shared utilities & types) + └── config/ ← shared ESLint, Tailwind, TypeScript configs +``` + +Packages are linked locally via workspaces, so `@platform/ui` and `@platform/utils` are available as regular imports without publishing to npm. + +--- + +## Requirements + +- Node.js >= 20 +- npm >= 11 + +--- + +## Getting started + +Install all dependencies from the **root** of the repository: + +```bash +npm install +``` + +--- + +## Development + +Run **all** apps and packages in watch mode simultaneously from the root: + +```bash +npm run dev +``` + +Run **only this app**: + +```bash +npx turbo run dev --filter=hermes-chat +``` + +Open [http://localhost:3000](http://localhost:3000) in your browser. The page hot-reloads as you edit files. Turbopack is enabled by default for faster builds during development. + +--- + +## Building + +Build **everything** (shared packages first, then this app) from the root: + +```bash +npm run build +``` + +Turborepo respects the dependency graph — `@platform/ui` and `@platform/utils` are always built before `hermes-chat`. + +Build **only this app** (and its local dependencies): + +```bash +npx turbo run build --filter=hermes-chat +``` + +Build a **specific package** in isolation: + +```bash +npx turbo run build --filter=@platform/ui +``` + +--- + +## Running in production + +After a successful build, start the Next.js production server from inside this app's folder: + +```bash +cd apps/hermes-chat +npm run start +``` + +Or directly: + +```bash +node apps/hermes-chat/.next/standalone/server.js +``` + +--- + +## Other scripts + +| Command | Description | +|---|---| +| `npm run lint` | Lint all packages | +| `npm run test` | Run tests across all packages | +| `npx turbo run