| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A modern, type-safe fullstack chat application built with Effect, featuring real-time messaging, room-based conversations, and user authentication. This monorepo showcases functional programming patterns with Effect while delivering a complete chat experience.
This monorepo contains the following applications and packages:
# Clone the repository
git clone <your-repo-url>
cd fullstack-effect-hive
# Install dependencies
pnpm install
# Set up environment variables
cp .env.example .env.localCreate a .env.local file in the root directory:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/hive_db"
# Server
PORT=3001
JWT_SECRET="your-super-secret-jwt-key-change-this-in-production"
# Frontend (optional, for production builds)
NEXT_PUBLIC_API_URL="http://localhost:3001"# Run database migrations
pnpm --filter @hive/server db:migrate# Start both server and web apps in development mode
pnpm dev
# Or run them separately:
pnpm --filter @hive/server dev # Start the Effect server on port 3001
pnpm --filter @hive/web dev # Start the Next.js app on port 3000
# Build all apps
pnpm build
# Lint all code
pnpm lint
# Type checking
pnpm check-typesThe application follows a clean architecture with Effect-based services:
The server exposes RESTful endpoints for:
The Next.js frontend connects to the Effect server via:
HTTP requests for data operations
WebSocket connections for real-time updates
JWT-based authentication
if (Effect.isSuccess(result)) { // Login successful, user redirected to dashboard } else { // Handle login error console.error("Login failed:", result.error); } };
### Password Reset
```typescript
import { forgotPasswordRoute } from "@repo/auth/forgot-password-route";
import { resetPasswordRoute } from "@repo/auth/reset-password-route";
// Use in your API routes
export const POST = forgotPasswordRoute;
export const PUT = resetPasswordRoute;
The application uses Effect for functional error handling and side effects throughout:
import { Effect } from "effect";
// All operations are wrapped in Effect for predictable error handling
const userResult = yield * findUserByEmail(email);
// HTTP API with Effect Platform
const api = HttpApi.make("ChatAPI").add(
HttpApiGroup.make("users").add(
HttpApiEndpoint.post("register")`/users`.addSuccess(UserSchema),
),
);
// WebSocket real-time messaging
const realtimeBus = yield * RealtimeBus;
yield * realtimeBus.broadcast(roomId, message);Business logic is organized in service layers with Effect:
// User service with Effect
export const UserService = Effect.gen(function* () {
const db = yield* DatabaseService;
const auth = yield* AuthService;
return {
createUser: (data: UserCreate) =>
Effect.gen(function* () {
// Implementation with proper error handling
}),
authenticateUser: (credentials: LoginCredentials) =>
Effect.gen(function* () {
// JWT token generation and validation
}),
};
});apps/
├── server/ # Effect-based backend
│ ├── src/
│ │ ├── api/routes/ # HTTP API routes
│ │ ├── auth/ # Authentication services
│ │ ├── config/ # Configuration management
│ │ ├── invitation/ # Invitation system
│ │ ├── message/ # Message handling
│ │ ├── realtime/ # WebSocket real-time features
│ │ ├── room/ # Room management
│ │ ├── user/ # User services
│ │ ├── index.ts # Server entry point
│ │ └── migrate.ts # Database migrations
│ └── package.json
└── web/ # Next.js frontend
├── app/ # Next.js app router
├── public/ # Static assets
└── package.json
packages/
├── eslint-config/ # Shared ESLint configs
└── typescript-config/ # Shared TypeScript configs
This project is licensed under the MIT License.
| Back | FazBrowse Home | New Git URL |