Six Expo mobile apps lagged behind their web counterparts and haven't shipped updates. Keeping them in the repo kept CI noisy (the context/ mobile type errors were only unmasked after yesterday's postinstall fix), and they blocked other cleanup (parallel lockfile entries, dead scripts). Removing them since the web surface under mana.how is the active product. Deleted (~175 MB, ~700 files): - apps/cards/apps/mobile - apps/chat/apps/mobile - apps/context/apps/mobile (the one still failing type-check) - apps/mana/apps/mobile - apps/picture/apps/mobile - apps/traces/apps/mobile Kept: apps/memoro/apps/mobile (the only actively-developed mobile app, tied to the audio-recording native module). Cleanup: - Dropped 6 `dev:*:mobile` scripts from root package.json that pointed at the deleted apps. Other `dev:*:mobile` entries (quotes, contacts, calendar, mail, moodlit, finance, figgos) already pointed at non-existent apps before this change — out of scope, a separate dead-script sweep. - Root CLAUDE.md: updated the "per-product mobile apps exist" prose and the repo-layout diagram to reflect the memoro-only reality. - apps/mana/CLAUDE.md: removed the `mobile/` entry from the apps/ layout box, noted the deletion date, and updated the tech-stack table to point at the memoro mobile app as the sole Expo surface. No CI workflow or turbo.json references touched — none existed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| .github/workflows | ||
| apps/landing | ||
| supabase/migrations | ||
| .gitignore | ||
| CI_CD_SETUP_GUIDE.md | ||
| CREDIT_SYSTEM.md | ||
| DEPLOYMENT_CHECKLIST.md | ||
| EDGE_FUNCTION_FIX.md | ||
| MANA_CORE_ARCHITECTURE.md | ||
| MANA_CORE_INTEGRATION_CHECKLIST.md | ||
| MANA_CORE_INTEGRATION_GUIDE.md | ||
| MANA_CORE_README.md | ||
| README.md | ||
| SETUP_GUIDE.md | ||
Cards
A deck management system with Mana authentication and credit system integration.
Features
- 🔐 Mana Authentication - Complete auth system with JWT tokens, device tracking, and automatic token refresh
- ⚡ Credit System - Mana-based billing for operations (10 mana to create a deck, 5 for AI features, etc.)
- 📱 React Native/Expo - Cross-platform mobile app (iOS, Android, Web)
- 🚀 NestJS Backend - Type-safe API with AuthGuard protection
- 💾 Supabase - Database and real-time features
- 🎨 NativeWind - Tailwind CSS for React Native styling
Quick Start
Prerequisites
- Node.js 18+
- npm or yarn
- Expo CLI (
npm install -g expo-cli) - Supabase account
- Mana credentials (APP_ID, SERVICE_KEY)
Backend Setup
-
Navigate to backend directory:
cd backend -
Install dependencies:
npm install -
Configure environment variables:
cp .env.example .envEdit
.envand add your credentials:# Mana MANA_SERVICE_URL=https://mana-middleware-111768794939.europe-west3.run.app APP_ID=your-app-id-from-mana-core SERVICE_KEY=your-service-key-from-mana-core # Required for credits # Supabase SUPABASE_URL=https://your-project.supabase.co SUPABASE_ANON_KEY=your-anon-key SUPABASE_SERVICE_KEY=your-service-key # Server NODE_ENV=development PORT=8080 -
Start the backend:
npm run start:devBackend will be available at
http://localhost:8080
Frontend Setup
-
Navigate to mobile app directory:
cd apps/mobile -
Install dependencies:
npm install -
Configure environment:
cp .env.example .envEdit
.env:# Supabase EXPO_PUBLIC_SUPABASE_URL=https://your-project.supabase.co EXPO_PUBLIC_SUPABASE_ANON_KEY=your-anon-key # Backend API EXPO_PUBLIC_API_URL=http://localhost:8080 # For local development # EXPO_PUBLIC_API_URL=https://your-production-backend.com # For production -
Start Expo:
npm start -
Run on platform:
- Press
ifor iOS simulator - Press
afor Android emulator - Press
wfor web browser
- Press
Architecture
┌─────────────────────┐
│ Mobile App │ React Native + Expo
│ (Frontend) │ - Authentication UI
│ │ - Credit balance display
│ │ - Deck management
└──────────┬──────────┘
│ HTTPS/JSON
│ Bearer Token Auth
▼
┌─────────────────────┐
│ Backend API │ NestJS
│ │ - AuthGuard protection
│ │ - Credit validation
│ │ - Business logic
└──────────┬──────────┘
│
├─────────────────────┐
│ │
▼ ▼
┌─────────────────┐ ┌──────────────────┐
│ Mana │ │ Supabase │
│ - Auth │ │ - Database │
│ - Credits │ │ - Storage │
│ - Transactions │ │ - Real-time │
└─────────────────┘ └──────────────────┘
Credit System
Cards uses Mana as its credit currency. Operations cost credits:
| Operation | Cost |
|---|---|
| Create Deck | 10 mana |
| Create Card | 2 mana |
| AI Card Generation | 5 mana |
| Export Deck | 3 mana |
How it Works
- Pre-flight Validation: Backend checks if user has enough credits
- Operation: Performs the requested operation (create deck, etc.)
- Consumption: Deducts credits only if operation succeeds
- Response: Returns success + credits used
Frontend Integration
The frontend automatically handles insufficient credits with a modal:
import { useInsufficientCredits } from '../hooks/useInsufficientCredits';
import { InsufficientCreditsModal } from '../components/InsufficientCreditsModal';
function MyScreen() {
const insufficientCredits = useInsufficientCredits();
const handleAction = async () => {
try {
await post('/api/decks', data);
} catch (error) {
// Automatically shows modal if insufficient credits
insufficientCredits.handleCreditError(error);
}
};
return (
<>
<Button onPress={handleAction} />
<InsufficientCreditsModal {...insufficientCredits} />
</>
);
}
Full documentation: See CREDIT_SYSTEM.md
API Endpoints
Authentication (via Mana)
POST /v1/auth/signin- Sign inPOST /v1/auth/signup- Sign upPOST /v1/auth/refresh- Refresh tokenPOST /v1/auth/logout- Sign out
Protected Endpoints (require Bearer token)
GET /api/profile- Get user profile + credit balanceGET /api/credits/balance- Get credit balanceGET /api/decks- List user's decksPOST /api/decks- Create deck (costs 10 mana)PUT /api/decks/:id- Update deckDELETE /api/decks/:id- Delete deckGET /api/cards- List cardsPOST /api/cards- Create card (costs 2 mana)
Public Endpoints
GET /public/health- Health checkGET /public/version- API versionGET /public/featured-decks- Featured decks (optional auth)
Project Structure
cards/
├── backend/ # NestJS backend
│ ├── src/
│ │ ├── config/
│ │ │ ├── credit-operations.ts # Credit costs & operation types
│ │ │ └── validation.schema.ts # Environment validation
│ │ ├── controllers/
│ │ │ ├── api.controller.ts # Protected endpoints
│ │ │ ├── public.controller.ts # Public endpoints
│ │ │ └── health.controller.ts # Health checks
│ │ ├── services/
│ │ │ └── supabase.service.ts # Supabase integration
│ │ ├── app.module.ts # Main module (Mana config)
│ │ └── main.ts # Entry point
│ ├── .env # Environment variables
│ └── package.json
│
├── apps/
│ ├── mobile/ # React Native/Expo app
│ ├── web/ # Web app
│ └── landing/ # Landing page
│ ├── app/ # Expo Router screens
│ │ ├── (tabs)/ # Tab navigation
│ │ └── _layout.tsx # Root layout
│ ├── components/
│ │ └── InsufficientCreditsModal.tsx # Credit error modal
│ ├── services/
│ │ ├── authService.ts # Authentication
│ │ ├── tokenManager.ts # Token refresh & management
│ │ └── creditService.ts # Credit operations
│ ├── hooks/
│ │ └── useInsufficientCredits.ts # Credit error handling
│ ├── types/
│ │ ├── auth.ts # Auth types
│ │ └── credits.ts # Credit types
│ ├── utils/
│ │ ├── apiClient.ts # Authenticated API client
│ │ └── deviceManager.ts # Device info
│ ├── examples/
│ │ └── DeckCreationExample.tsx # Usage example
│ ├── .env # Environment variables
│ └── package.json
│
├── CREDIT_SYSTEM.md # Credit system documentation
├── MANA_CORE_INTEGRATION_GUIDE.md
├── MANA_CORE_INTEGRATION_CHECKLIST.md
├── MANA_CORE_ARCHITECTURE.md
├── MANA_CORE_README.md
└── README.md # This file
Development
Backend
cd backend
# Development with hot reload
npm run start:dev
# Build for production
npm run build
# Run production build
npm run start:prod
# Linting
npm run lint
# Tests
npm run test
Frontend
cd apps/mobile
# Start Expo dev server
npm start
# Run on iOS
npm run ios
# Run on Android
npm run android
# Run on web
npm run web
# Linting & formatting
npm run lint
npm run format
# Build with EAS
npm run build:dev # Development build
npm run build:preview # Preview build
npm run build:prod # Production build
Environment Variables
Backend Required Variables
| Variable | Description | Example |
|---|---|---|
MANA_SERVICE_URL |
Mana service URL | https://mana-middleware-*.run.app |
APP_ID |
Your app ID from Mana | cea4bfc6-a4de-4e17-91e2-54275940156e |
SERVICE_KEY |
Service key for credit operations | Get from Mana |
SUPABASE_URL |
Supabase project URL | https://abc.supabase.co |
SUPABASE_ANON_KEY |
Supabase anonymous key | Your anon key |
PORT |
Backend port | 8080 |
Frontend Required Variables
| Variable | Description | Example |
|---|---|---|
EXPO_PUBLIC_SUPABASE_URL |
Supabase project URL | https://abc.supabase.co |
EXPO_PUBLIC_SUPABASE_ANON_KEY |
Supabase anonymous key | Your anon key |
EXPO_PUBLIC_API_URL |
Backend API URL | http://localhost:8080 |
Testing
Backend Testing
The backend includes example tests in backend/src/app.controller.spec.ts. To add credit system tests:
import { CreditClientService } from '@mana-core/nestjs-integration/services';
// Mock in test setup
{
provide: CreditClientService,
useValue: {
validateCredits: jest.fn().mockResolvedValue({
hasCredits: true,
availableCredits: 100,
}),
consumeCredits: jest.fn(),
},
}
Manual Testing
-
Test authentication:
# Sign up curl -X POST http://localhost:8080/v1/auth/signup \ -H "Content-Type: application/json" \ -d '{"email":"test@example.com","password":"password123","username":"testuser"}' # Sign in curl -X POST http://localhost:8080/v1/auth/signin \ -H "Content-Type: application/json" \ -d '{"email":"test@example.com","password":"password123"}' -
Test protected endpoint:
export TOKEN="your-jwt-token-from-signin" curl -H "Authorization: Bearer $TOKEN" \ http://localhost:8080/api/profile -
Test credit system:
# Check balance curl -H "Authorization: Bearer $TOKEN" \ http://localhost:8080/api/credits/balance # Create deck (costs 10 mana) curl -X POST http://localhost:8080/api/decks \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"name":"My Deck","description":"Test deck"}'
Troubleshooting
Backend won't start
- Check all environment variables are set
- Verify Mana credentials are correct
- Check if port 8080 is available
Credits not working
- Ensure
SERVICE_KEYis set in backend.env - Check backend logs for credit validation errors
- Verify user has credits in Mana dashboard
Frontend can't connect to backend
- Check
EXPO_PUBLIC_API_URLis correct - For Android emulator, use
http://10.0.2.2:8080instead oflocalhost - Verify backend is running
Token refresh fails
- Check device info is being sent with refresh requests
- Verify refresh token is stored correctly
- Check network connectivity
Documentation
- Credit System - Complete credit system documentation
- Mana Integration Guide - Step-by-step integration
- Integration Checklist - Checkboxes for tracking
- Architecture Guide - System architecture and flows
- Mana README - Quick reference
- Example Implementation - Working code example
Resources
- Mana Documentation
- Mana NestJS Package
- Expo Documentation
- NestJS Documentation
- Supabase Documentation
License
Private project - All rights reserved
Support
For issues related to:
- Mana: https://github.com/Memo-2023/mana-core-nestjs-package/issues
- This project: Contact the development team