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

https://github.com/shobhit141141/esahayak

Esahayak buyers/leads management platform built on next js
https://github.com/shobhit141141/esahayak

jest mantine next postgresql prisma react redis tailwindcss typescript zod

Last synced: 3 months ago
JSON representation

Esahayak buyers/leads management platform built on next js

Awesome Lists containing this project

README

          

# ๐Ÿš€ Esahayak Leads

## Buyers/leads managemnt platform

## ๐Ÿ“‹ Table of Contents

- [Tech Stack](#-tech-stack)
- [Features](#-features)
- [File Structure](#-file-structure)
- [Prerequisites](#-prerequisites)
- [Quick Start](#-quick-start)
- [Unit test](#-unit-test)

## ๐Ÿงฐ Tech Stack (badges)

![Next.js](https://img.shields.io/badge/Next.js-000000?style=for-the-badge&logo=next.js&logoColor=white) ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white) ![Prisma](https://img.shields.io/badge/Prisma-2D3748?style=for-the-badge&logo=prisma&logoColor=white) ![PostgreSQL](https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white) ![Zod](https://img.shields.io/badge/Zod-000000?style=for-the-badge&logo=zod&logoColor=white) ![Jest](https://img.shields.io/badge/Jest-C21325?style=for-the-badge&logo=jest&logoColor=white) ![Redis](https://img.shields.io/badge/Redis-DC382D?style=for-the-badge&logo=redis&logoColor=white) ![Mantine](https://img.shields.io/badge/Mantine-339AF0?style=for-the-badge&logo=mantine&logoColor=white) ![Tailwind CSS](https://img.shields.io/badge/Tailwind_CSS-06B6D4?style=for-the-badge&logo=tailwind-css&logoColor=white)

## โœจ Features

- **Demo Login with cookies**: Simple authentication using cookies
- **Import/Export by CSV**: data import/export functionality
- **Type Safety**: Fully typed database operations
- **ZOD validation**: Schema validation with Zod
- **Buyers Managementes**: CRUD operations for managing buyers with filters/sorting/pagination
- **Column specific sorting**: sort and filter data in tables for specific columns
- **Buyers history**: Track and view the history of buyer interactions
- **Admin/Agent Roles**: Different access levels for admins and agents
- **Concurrency Handling**: simultaneous data operations are managed
- **Error Boundaries**: Graceful error handling in components/pages.
- **Rate limiting using REDIS+IP**: based on requests by IP per minute.
- **Unit Testing**: Basic unit test setup with Jest.

## ๐Ÿ“‚ File Structure

```plaintext
esahayak/
src/
โ”œโ”€โ”€ app/
โ”‚ โ”œโ”€โ”€ api/ # API route handlers
โ”‚ โ”œโ”€โ”€ buyers/ # Pages or components related to buyers
โ”‚ โ”œโ”€โ”€ error/ # Additional error handling pages/components
โ”‚ โ”œโ”€โ”€ users/ # Pages or components related to users
โ”‚ โ”œโ”€โ”€ error.tsx # Global error boundary
โ”‚ โ”œโ”€โ”€ globals.css # Global stylesheet
โ”‚ โ”œโ”€โ”€ icon.ico # App icon
โ”‚ โ”œโ”€โ”€ layout.tsx # Root layout component
โ”‚ โ”œโ”€โ”€ not-found.tsx # 404 page
โ”‚ โ””โ”€โ”€ page.tsx # Main entry page
โ”œโ”€โ”€ components/ # Reusable UI components
โ”œโ”€โ”€ context/ # React context providers and hooks
โ”œโ”€โ”€ generated/ # Auto-generated prisma client
โ”œโ”€โ”€ lib/ # Utility libraries and services
โ”œโ”€โ”€ types/ # TypeScript type definitions
โ”œโ”€โ”€ utils/ # Helper functions
โ”œโ”€โ”€ middleware.ts # Middleware logic
โ”œโ”€โ”€ public/ # Static assets (images, fonts, etc.)
โ”œโ”€โ”€ styles/ # Additional stylesheets
โ””โ”€โ”€ tests/ # Unit and integration tests
```

## ๐Ÿ›  Prerequisites

Before you begin, ensure you have:

- Node.js 18+ installed
- PostgreSQL database (local or cloud)
- Git installed
- npm or yarn package manager

## ๐Ÿš€ Quick Start

### 1. Clone the Repository

```bash
git clone https://github.com/Shobhit141141/esahayak.git
cd esahayak
```

### 2. Install Dependencies

```bash
npm install
```

### 3. Set Up Environment Variables

Copy a `.env.sample` in `.env` file at the root of your project and configure the following environment variables:

```env
DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE"
UPSTASH_REDIS_REST_URL="your-upstash-redis-url"
UPSTASH_REDIS_REST_TOKEN="your-upstash-redis-token"
```

### 4. Set Up the Database

Run the following commands to set up your database schema and generate the Prisma client:

```bash
npm run db:setup
```

This will:

- Run migrations (prisma migrate dev)
- Generate Prisma client (prisma generate)

### 5.Open prisma studio (Optional)

```bash
npm run prisma:studio
```

### 6. Start the Development Server

```bash
npm run dev
```

Open your browser and navigate to `http://localhost:3000` to see the application in action.

## ๐Ÿงช Unit Test

### 1. Create a Test File

Create a test file in the `utils/__tests__` directory (e.g., `__tests__/example.test.tsx`).

### 2. Write a Test

```tsx
import { render, screen } from "@testing-library/react";
import ExampleComponent from "../components/ExampleComponent";

test("renders example component", () => {
render();
expect(screen.getByText(/example/i)).toBeInTheDocument();
});
```

### 3. Run Tests

```bash
npx jest
```