|
1 | | -# FairShare Monorepo |
| 1 | +# 💸 FairShare |
2 | 2 |
|
3 | | -Production-grade scaffold for Expo mobile + NestJS backend + Next.js web placeholder. |
| 3 | +**A Production-Grade Monorepo for Collaborative Expense Sharing.** |
4 | 4 |
|
| 5 | +FairShare is a high-performance, full-stack solution designed for seamless expense tracking and settlement. Built with a modern TypeScript-first architecture, it provides a unified experience across mobile, web, and backend services. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## 🚀 Overview |
| 10 | + |
| 11 | +FairShare simplifies communal living and shared adventures. Whether you're splitting rent with roommates or tracking costs on a group trip, FairShare provides the tools to handle complex splits, automate settlements via UPI, and maintain real-time visibility into balances. |
| 12 | + |
| 13 | +### Key Highlights |
| 14 | + |
| 15 | +- **Cross-Platform**: Expo-powered mobile app and Next.js web dashboard. |
| 16 | +- **Robust Backend**: Scalable NestJS microservice with Prisma and Supabase. |
| 17 | +- **Financial Integrity**: High-precision BigInt arithmetic for accurate penny-perfect splits. |
| 18 | +- **Production Ready**: Fully Dockerized, Terraform-orchestrated, and CI/CD-integrated. |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## 🛠 Tech Stack |
| 23 | + |
| 24 | +### Backend |
| 25 | + |
| 26 | +- **Framework**: NestJS (TypeScript strict) |
| 27 | +- **Database**: PostgreSQL (Supabase) + Prisma ORM |
| 28 | +- **Caching**: Redis (BullMQ for async jobs) |
| 29 | +- **Storage**: AWS S3 (Receipts & Assets) |
| 30 | +- **Security**: JWT Rotation, Google OAuth, Helmet, CSRF Protection |
| 31 | +- **Observability**: Prometheus metrics + Sentry + OpenTelemetry |
| 32 | + |
| 33 | +### Mobile |
| 34 | + |
| 35 | +- **Framework**: Expo Router (React Native) |
| 36 | +- **Styling**: React Native Paper + Reanimated animations |
| 37 | +- **State/Networking**: Axios + Socket.io + TanStack Query (planned) |
| 38 | +- **Native Hooks**: Haptic feedback, Lottie animations, UPI Deep-linking |
| 39 | + |
| 40 | +### Web |
| 41 | + |
| 42 | +- **Framework**: Next.js |
| 43 | +- **Styling**: TailwindCSS + Framer Motion |
| 44 | +- **SEO**: Dynamic metadata & SSR optimized |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## 📁 Project Structure |
| 49 | + |
| 50 | +This project uses **Turborepo** and **pnpm** for workspace management: |
| 51 | + |
| 52 | +```text |
| 53 | +FairShare/ |
| 54 | +├── apps/ |
| 55 | +│ ├── backend/ # NestJS API Service |
| 56 | +│ ├── mobile/ # Expo / React Native App |
| 57 | +│ └── web/ # Next.js Marketing & Dashboard |
| 58 | +├── packages/ |
| 59 | +│ └── shared-types/ # Shared TS interfaces & Zod schemas |
| 60 | +├── infra/ # Terraform modules (AWS ECS, RDS, S3) |
| 61 | +└── scripts/ # Automation & seeding utilities |
| 62 | +``` |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## 🚦 Getting Started |
| 67 | + |
| 68 | +### Prerequisites |
| 69 | + |
| 70 | +- [Node.js](https://nodejs.org/) (v18+) |
| 71 | +- [pnpm](https://pnpm.io/) (v8+) |
| 72 | +- [Docker](https://www.docker.com/) (for local services) |
| 73 | + |
| 74 | +### Installation |
| 75 | + |
| 76 | +1. **Clone the repository**: |
| 77 | + |
| 78 | + ```bash |
| 79 | + git clone https://github.com/Arun-kushwaha007/FairShare.git |
| 80 | + cd FairShare |
| 81 | + ``` |
| 82 | + |
| 83 | +2. **Install dependencies**: |
| 84 | + |
| 85 | + ```bash |
| 86 | + pnpm install |
| 87 | + ``` |
| 88 | + |
| 89 | +3. **Environment Setup**: |
| 90 | + |
| 91 | + Copy `.env.example` to `.env` in the root and within `apps/backend/`. |
| 92 | + |
| 93 | + ```bash |
| 94 | + cp .env.example .env |
| 95 | + ``` |
| 96 | + |
| 97 | + > [!IMPORTANT] |
| 98 | + > The backend requires several mandatory environment variables to bootstrap successfully. Ensure the following are set in `apps/backend/.env`: |
| 99 | + > - `SUPABASE_DATABASE_URL`: Your PostgreSQL connection string. |
| 100 | + > - `JWT_SECRET` & `JWT_REFRESH_SECRET`: Secure strings for token signing. |
| 101 | + > - `STRIPE_SECRET_KEY`: Required for the payments module (starts with `sk_test_`). |
| 102 | + > - `STRIPE_WEBHOOK_SECRET`: Required for processing payment events (starts with `whsec_`). |
| 103 | + > - `GOOGLE_CLIENT_ID` & `SECRET`: For OAuth integration. |
| 104 | +
|
| 105 | +4. **Start Development Services**: |
| 106 | + |
| 107 | + ```bash |
| 108 | + # Start DB, Redis via Docker |
| 109 | + docker-compose up -d |
| 110 | + |
| 111 | + # Run all apps in dev mode (Turbo) |
| 112 | + pnpm dev |
| 113 | + ``` |
| 114 | + |
| 115 | +### 💻 Developing Locally |
| 116 | + |
| 117 | +You can also start specific services individually using the following commands from the root: |
| 118 | + |
| 119 | +| Service | Command | Description | |
| 120 | +| :--- | :--- | :--- | |
| 121 | +| **All Service** | `pnpm dev` | Starts Backend, Mobile, and Web in parallel via Turbo. | |
| 122 | +| **Backend** | `pnpm dev:backend` | Starts the NestJS API with hot reload. | |
| 123 | +| **Mobile** | `pnpm dev:mobile` | Starts the Expo development server (Expo Go). | |
| 124 | +| **Web** | `pnpm dev:web` | Starts the Next.js development server. | |
| 125 | +| **Seeding** | `pnpm seed` | Populates the database with initial development data. | |
| 126 | +| **Building Mobile** | `pnpm mobile:build` | Triggers EAS build for production AAB/IPA. | |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## 🔋 Core Features |
| 131 | + |
| 132 | +- **Advanced Split Logic**: Supports equal, exact, and percentage-based splits. |
| 133 | +- **Fast Settlements**: Greedy simplification algorithm to minimize total payments. |
| 134 | +- **Real-time Activity**: Live updates via WebSockets for group actions. |
| 135 | +- **Offline Resilience**: Mobile-first architecture with offline queuing for expense entry. |
| 136 | +- **Push Notifications**: Intelligent reminders for pending settlements via Expo. |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +## 🚢 Infrastructure & Deployment |
| 141 | + |
| 142 | +- **CI/CD**: GitHub Actions for automated type-checking, linting, and Playwright E2E testing. |
| 143 | +- **Cloud Hosting**: AWS ECS (Fargate) for backend, Vercel/Netlify for web, and EAS for mobile. |
| 144 | +- **IaC**: Terraform-managed VPC, ECS Cluster, RDS, and S3 buckets. |
| 145 | + |
| 146 | +--- |
| 147 | + |
| 148 | +## 📄 License & Documentation |
| 149 | + |
| 150 | +Refer to [doc.md](doc.md) for detailed technical architecture and production launch notes. |
| 151 | + |
| 152 | +--- |
| 153 | + |
| 154 | +*Developed with ❤️ by the FairShare Team.* |
0 commit comments