An open API service indexing awesome lists of open source software.

https://github.com/gminetoma/full-stack-boilerplate

Full-Stack TypeScript Boilerplate: React SSR + GraphQL API with Bun & Tailwind CSS
https://github.com/gminetoma/full-stack-boilerplate

biome bun cypress graphql react shadcn-ui storybook tailwind tanstack typescript vite yoga-graphql

Last synced: 3 months ago
JSON representation

Full-Stack TypeScript Boilerplate: React SSR + GraphQL API with Bun & Tailwind CSS

Awesome Lists containing this project

README

          

# Full-Stack TypeScript Monorepo

A modern full-stack application built with TypeScript, React, and GraphQL using Bun as the runtime and package manager.

## ๐Ÿ—๏ธ Architecture

This is a monorepo containing:

- **`packages/graphql-api`** - GraphQL API server with subscriptions support
- **`packages/react-app`** - React application with SSR and internationalization
- **`packages/tools/cypress`** - End-to-end testing suite
- **`packages/tools/storybook`** - Component documentation and development

## ๐Ÿš€ Quick Start

### Prerequisites

- [Bun](https://bun.sh) >= 1.0.0

### Installation

```bash
bun install
```

### Development

Run both frontend and backend in separate terminals:

```bash
# Terminal 1 - Start the GraphQL API server
bun api dev

# Terminal 2 - Start the React app
bun app dev
```

The API will be available at `http://localhost:8080/graphql` and the React app at `http://localhost:3000`.

## ๐Ÿ“ฆ Workspace Commands

The monorepo uses workspace-scoped commands for convenience:

```bash
# React App commands
bun app dev # Start development server
bun app build # Build for production
bun app codegen # Generate GraphQL types
bun app lint # Run linter
bun app test # Run tests

# GraphQL API commands
bun api dev # Start development server with hot reload
bun api codegen # Generate resolvers and types
bun api lint # Run linter
bun api test # Run tests
bun api coverage # Run tests with coverage

# Testing tools
bun cypress open # Open Cypress test runner
bun cypress run # Run Cypress tests headlessly

# Storybook
bun storybook dev # Start Storybook dev server
bun storybook build # Build Storybook

# Root-level commands
bun lint # Lint all packages
```

## ๐Ÿ› ๏ธ Tech Stack

### Core Technologies
- **Runtime**: [Bun](https://bun.sh) - Fast all-in-one JavaScript runtime
- **Language**: TypeScript with strict type checking
- **Linting**: [Biome](https://biomejs.dev) - Fast formatter and linter

### Backend (`graphql-api`)
- **Web Server**: [Hono](https://hono.dev) - Lightweight web framework
- **GraphQL**: [GraphQL Yoga](https://the-guild.dev/graphql/yoga-server) - Flexible GraphQL server
- **Subscriptions**: [graphql-ws](https://github.com/enisdenjo/graphql-ws) - WebSocket protocol for GraphQL
- **Configuration**: [Convict](https://github.com/mozilla/node-convict) - Environment configuration management

### Frontend (`react-app`)
- **Framework**: [React 19](https://react.dev) with Server-Side Rendering
- **Routing**: [TanStack Router](https://tanstack.com/router) + [TanStack Start](https://tanstack.com/start)
- **Data Fetching**: [TanStack Query](https://tanstack.com/query)
- **Build Tool**: [Vite](https://vitejs.dev) with TypeScript paths support
- **Styling**: [Tailwind CSS v4](https://tailwindcss.com)
- **UI Components**: [shadcn/ui](https://ui.shadcn.com) + [Radix UI](https://www.radix-ui.com)
- **Animations**: [Motion](https://motion.dev)
- **i18n**: [i18next](https://www.i18next.com) with React integration

### Testing & Development Tools
- **Unit Testing**: [Vitest](https://vitest.dev) with coverage support
- **E2E Testing**: [Cypress](https://www.cypress.io)
- **Component Development**: [Storybook](https://storybook.js.org)

## ๐Ÿ“ Code Generation

Both packages use GraphQL Code Generator to maintain type safety:

```bash
# Generate types for both packages
bun api codegen && bun app codegen
```

This generates:
- **API**: TypeScript resolvers and type definitions from GraphQL schemas
- **App**: Type-safe GraphQL client hooks and operations

## ๐ŸŒ Internationalization

The React app supports multiple languages (English and Portuguese by default). Translations are located in:
- `packages/react-app/public/locales/en/`
- `packages/react-app/public/locales/pt/`

## ๐ŸŽจ Styling

The project uses Tailwind CSS v4 with the shadcn/ui component system. Add new components:

```bash
bun app shadcn add
```

## ๐Ÿงช Testing

```bash
# Unit tests
bun api test # Backend tests
bun app test # Frontend tests

# Coverage reports
bun api coverage
bun app coverage

# E2E tests
bun cypress open # Interactive mode
bun cypress run # CI mode
```

## ๐Ÿ“‚ Project Structure

```
.
โ”œโ”€โ”€ packages/
โ”‚ โ”œโ”€โ”€ graphql-api/ # GraphQL backend
โ”‚ โ”‚ โ”œโ”€โ”€ config/ # Configuration management
โ”‚ โ”‚ โ”œโ”€โ”€ src/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ entry/ # Server entry point
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ graphql/ # Schema and resolvers
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ utils/ # Shared utilities
โ”‚ โ”‚ โ””โ”€โ”€ tests/ # API tests
โ”‚ โ”‚
โ”‚ โ”œโ”€โ”€ react-app/ # React frontend
โ”‚ โ”‚ โ”œโ”€โ”€ config/ # App configuration
โ”‚ โ”‚ โ”œโ”€โ”€ public/ # Static assets and translations
โ”‚ โ”‚ โ”œโ”€โ”€ src/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ components/ # React components
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ graphql/ # Generated GraphQL client
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ layouts/ # Layout components
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ pages/ # Page components
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ routes/ # TanStack Router routes
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ lib/ # Utilities and helpers
โ”‚ โ”‚ โ””โ”€โ”€ tests/ # Frontend tests
โ”‚ โ”‚
โ”‚ โ””โ”€โ”€ tools/
โ”‚ โ”œโ”€โ”€ cypress/ # E2E tests
โ”‚ โ””โ”€โ”€ storybook/ # Component documentation
โ”‚
โ”œโ”€โ”€ biome.json # Biome configuration
โ”œโ”€โ”€ graphql.config.json # GraphQL IDE configuration
โ””โ”€โ”€ package.json # Workspace configuration
```

## ๐Ÿ”ง Configuration

### Environment Variables

Create `.env` files in the respective packages:

**`packages/graphql-api/.env`**:
```env
NODE_ENV=development
PORT=8080
HOST_NAME=localhost
PROTOCOL=http
GRAPHQL_ENDPOINT=/graphql
GRAPHIQL_ENDPOINT=/ws
```

**`packages/react-app/.env`**:
```env
# Add your React app environment variables here
PORT=5173
PROTOCOL=http
HOST_NAME=localhost
NODE_ENV=development
```