refactor: migrate from Next.js to SolidJS and GraphQL

- Converted web application from Next.js to SolidJS with Vite
- Replaced React components with SolidJS components
- Implemented GraphQL client using URQL
- Added authentication, room, and chat components
- Updated project structure and configuration files
- Removed unnecessary Next.js and docs-related files
- Added Docker support for web and API applications
This commit is contained in:
Juan Sebastián Montoya 2025-03-04 01:08:52 -05:00
parent 8f3aa2fc26
commit 16731409df
81 changed files with 13585 additions and 1163 deletions

147
README.md
View file

@ -1,84 +1,109 @@
# Turborepo starter
# Unreal Chat
This Turborepo starter is maintained by the Turborepo core team.
A real-time chat application built with SolidJS, GraphQL, and Prisma.
## Using this example
## Project Structure
Run the following command:
This is a monorepo containing the following packages:
```sh
npx create-turbo@latest
- `apps/api`: GraphQL API server built with Apollo Server, GraphQL, and Prisma
- `apps/web`: Web client built with SolidJS and URQL GraphQL client
## Features
- Real-time chat with GraphQL subscriptions
- User authentication
- Chat room management
- Message sending and receiving
- Public and private chat rooms
## Getting Started
### Prerequisites
- Node.js (v18 or later)
- npm (v10 or later)
- MariaDB or MySQL
### Installation
1. Clone the repository:
```bash
git clone https://github.com/yourusername/unreal-chat.git
cd unreal-chat
```
## What's inside?
2. Install dependencies:
This Turborepo includes the following packages/apps:
### Apps and Packages
- `docs`: a [Next.js](https://nextjs.org/) app
- `web`: another [Next.js](https://nextjs.org/) app
- `@repo/ui`: a stub React component library shared by both `web` and `docs` applications
- `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
- `@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
### Utilities
This Turborepo has some additional tools already setup for you:
- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io) for code formatting
### Build
To build all apps and packages, run the following command:
```
cd my-turborepo
pnpm build
```bash
npm install
```
### Develop
3. Set up environment variables:
To develop all apps and packages, run the following command:
Create a `.env` file in the `apps/api` directory:
```
cd my-turborepo
pnpm dev
DATABASE_URL="mysql://root:password@localhost:3306/unreal_chat"
JWT_SECRET="your-secret-key"
```
### Remote Caching
> [!TIP]
> Vercel Remote Cache is free for all plans. Get started today at [vercel.com](https://vercel.com/signup?/signup?utm_source=remote-cache-sdk&utm_campaign=free_remote_cache).
Turborepo can use a technique known as [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup?utm_source=turborepo-examples), then enter the following commands:
Create a `.env` file in the `apps/web` directory:
```
cd my-turborepo
npx turbo login
VITE_API_URL=http://localhost:4000/graphql
VITE_WS_URL=ws://localhost:4000/graphql
```
This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview).
4. Initialize the database:
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:
```
npx turbo link
```bash
npm run prisma:init
```
## Useful Links
5. Start the development servers:
Learn more about the power of Turborepo:
```bash
# Start both API and web servers
npm run dev
- [Tasks](https://turbo.build/repo/docs/core-concepts/monorepos/running-tasks)
- [Caching](https://turbo.build/repo/docs/core-concepts/caching)
- [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching)
- [Filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering)
- [Configuration Options](https://turbo.build/repo/docs/reference/configuration)
- [CLI Usage](https://turbo.build/repo/docs/reference/command-line-reference)
# Or start them individually
npm run api:dev
npm run web:dev
```
The API will be available at http://localhost:4000/graphql and the web app at http://localhost:5173.
## Available Scripts
- `npm run dev` - Start all development servers
- `npm run api:dev` - Start the API development server
- `npm run web:dev` - Start the web development server
- `npm run build` - Build all packages
- `npm run api:build` - Build the API
- `npm run web:build` - Build the web app
- `npm run prisma:generate` - Generate Prisma client
- `npm run prisma:migrate` - Run Prisma migrations
- `npm run prisma:studio` - Open Prisma Studio
## Technologies
### Backend (API)
- Apollo Server
- GraphQL
- Prisma ORM
- MariaDB
- JSON Web Tokens (JWT)
### Frontend (Web)
- SolidJS
- URQL GraphQL Client
- GraphQL Subscriptions
- CSS
## License
This project is licensed under the MIT License - see the LICENSE file for details.