Production-ready monorepo for mobile, Node.js API, and Python algorithm services.
- Overview
- Project Structure
- Prerequisites
- Getting Started
- Development
- Testing
- Deployment
- Contributing
This monorepo contains:
- Mobile App (
apps/mobile): React Native application for iOS and Android - API Service (
services/api): Node.js/Express REST API with TypeScript - Algorithm Service (
services/algorithms): Python Flask service for data processing - Shared Package (
packages/shared): Common utilities and types
.
├── apps/
│ └── mobile/ # React Native mobile app
│ ├── src/
│ ├── android/
│ ├── ios/
│ └── package.json
├── services/
│ ├── api/ # Node.js API service
│ │ ├── src/
│ │ ├── Dockerfile
│ │ └── package.json
│ └── algorithms/ # Python algorithm service
│ ├── src/
│ ├── Dockerfile
│ └── requirements.txt
├── packages/
│ └── shared/ # Shared utilities and types
│ ├── src/
│ └── package.json
├── infra/
│ ├── terraform/ # Infrastructure as Code
│ └── docs/ # Infrastructure documentation
├── .github/
│ └── workflows/ # CI/CD workflows
├── docker-compose.yml # Local development environment
├── firebase.json # Firebase emulator config
└── package.json # Root package.json with workspaces
- Node.js: >= 18.0.0
- Yarn: >= 3.0.0 (install with
corepack enable) - Python: >= 3.11 (for algorithm service)
- Docker: >= 20.10 (for local development)
- Docker Compose: >= 2.0
- Xcode: Latest version (for iOS development)
- Android Studio: Latest version (for Android development)
- CocoaPods: Latest version (for iOS dependencies)
git clone <repository-url>
cd monorepo# Enable Yarn 3
corepack enable
# Install all workspace dependencies
yarn install# Copy example env files
cp .env.example .env
cp services/api/.env.example services/api/.env
cp services/algorithms/.env.example services/algorithms/.env
cp apps/mobile/.env.example apps/mobile/.env
# Edit .env files with your configuration# Start MongoDB, Redis, and LocalStack
yarn docker:up
# Or with logs
docker-compose up# Install Firebase CLI globally
npm install -g firebase-tools
# Start emulators
yarn emulator# Start API and Algorithm services in development mode
yarn dev# Development mode with hot reload
yarn workspace @monorepo/api dev
# Build
yarn workspace @monorepo/api build
# Start production build
yarn workspace @monorepo/api startcd services/algorithms
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run development server
export FLASK_APP=src.app
export FLASK_ENV=development
flask run --host=0.0.0.0 --port=5000# Start Metro bundler
yarn workspace @monorepo/mobile start
# Run on iOS
yarn workspace @monorepo/mobile ios
# Run on Android
yarn workspace @monorepo/mobile android# Build
yarn workspace @monorepo/shared build
# Watch mode
yarn workspace @monorepo/shared dev# Lint all code
yarn lint
# Fix linting issues
yarn lint:fix
# Format code
yarn format
# Check formatting
yarn format:check
# Type check
yarn typecheckyarn testyarn test --coverage# API tests
yarn workspace @monorepo/api test
# Shared package tests
yarn workspace @monorepo/shared test
# Mobile tests
yarn workspace @monorepo/mobile test
# Python tests
cd services/algorithms
pytestyarn test:watch# Build API service
docker build -t monorepo-api -f services/api/Dockerfile .
# Build Algorithm service
docker build -t monorepo-algorithms -f services/algorithms/Dockerfile .# Start all services
docker-compose up
# Start in detached mode
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose downSee Infrastructure Documentation for detailed deployment instructions.
- AWS CLI configured
- Terraform installed
- Docker installed
- Provision Infrastructure
cd infra/terraform
terraform init
terraform plan -var="environment=production"
terraform apply -var="environment=production"- Deploy via CI/CD
Push to main branch to trigger automated deployment via GitHub Actions.
- Manual Deploy
# Build and push API
docker build -t monorepo-api:latest -f services/api/Dockerfile .
docker tag monorepo-api:latest <ecr-repo>/monorepo-api:latest
docker push <ecr-repo>/monorepo-api:latest
# Build and push Algorithm service
docker build -t monorepo-algorithms:latest -f services/algorithms/Dockerfile .
docker tag monorepo-algorithms:latest <ecr-repo>/monorepo-algorithms:latest
docker push <ecr-repo>/monorepo-algorithms:latest
# Update ECS services
aws ecs update-service --cluster production-cluster --service api-service --force-new-deployment
aws ecs update-service --cluster production-cluster --service algorithms-service --force-new-deploymentGET /health- Health checkGET /api/users- List usersGET /api/users/:id- Get user by ID
GET /health- Health checkPOST /api/algorithms/process- Process dataGET /api/algorithms/status- Service status
See .env.example for all required environment variables.
MONGO_URI: MongoDB connection stringREDIS_HOST,REDIS_PORT: Redis configurationJWT_SECRET: Secret for JWT token generationAWS_*: AWS credentials for S3, etc.FIREBASE_*: Firebase configuration
yarn dev- Start all services in development modeyarn build- Build all workspacesyarn test- Run all testsyarn lint- Lint all codeyarn format- Format all codeyarn typecheck- Type check TypeScript codeyarn clean- Clean all build artifactsyarn docker:up- Start Docker servicesyarn docker:down- Stop Docker services
- Create a feature branch from
develop - Make changes and commit (Husky will run pre-commit hooks)
- Push to remote and create a Pull Request
- CI will run tests and checks
- After approval, merge to
develop - Periodically merge
developtomainfor releases
Husky runs the following checks before each commit:
- ESLint on staged files
- Prettier formatting
- Python black and flake8 (for .py files)
Before pushing, Husky runs:
- TypeScript type checking
- All tests
Follow conventional commits format:
type(scope): subject
body
footer
Types: feat, fix, docs, style, refactor, test, chore
# Clear cache and reinstall
yarn cache clean
rm -rf node_modules
yarn install# Reset Docker environment
docker-compose down -v
docker system prune -a
docker-compose up --buildcd services/algorithms
rm -rf venv
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt# iOS
cd apps/mobile/ios
pod deintegrate
pod install
cd ..
# Android
cd apps/mobile/android
./gradlew clean
cd ..
# Metro cache
yarn workspace @monorepo/mobile start --reset-cacheSee Architecture Documentation for detailed architecture information.
MIT
For issues and questions, please create an issue in the repository.