A scalable Nx monorepo for crawling and collecting educational resources across multiple platforms.
- Node.js >= 18.0.0
- pnpm >= 8.0.0
- Python >= 3.8
- Git
-
Clone and Install Dependencies
git clone <repository-url> cd free-learn pnpm install
-
Setup Python Environment
# Create virtual environment python -m venv venv source venv/bin/activate # On Linux/macOS # venv\Scripts\activate # On Windows # Install Python dependencies cd apps/data-crawler pip install -r requirements.txt cd ../..
-
Install Development Tools
# Install Python linting and formatting tools pip install black flake8 isort mypy pytest pytest-cov
free-learn/
├── apps/
│ └── data-crawler/ # Python crawler application
│ ├── src/ # Source code
│ ├── output/ # Crawler output
│ ├── main.py # Entry point
│ ├── project.json # Nx project configuration
│ └── requirements.txt # Python dependencies
├── libs/ # Shared libraries (future)
├── .vscode/
│ └── settings.json # VS Code configuration
├── package.json # Node.js dependencies and scripts
├── pnpm-workspace.yaml # pnpm workspace configuration
├── pyproject.toml # Python project configuration
├── .prettierrc # Code formatting rules
├── nx.json # Nx workspace configuration
└── README.md # This file
# Start the crawler with example parameters
pnpm start:crawler:example
# Start the crawler with custom parameters
pnpm start:crawler
# Run linting across all projects
pnpm lint
# Format all code (Python, JSON, YAML, Markdown)
pnpm format
# Type checking across all projects
pnpm type-check
# Run tests across all projects
pnpm test
# Build all projects
pnpm build# Run specific project tasks
nx run data-crawler:run
nx run data-crawler:lint
nx run data-crawler:format
# Run tasks on affected projects only
nx affected --target=lint
nx affected --target=test
nx affected --target=build
# View dependency graph
nx graph
# Reset Nx cache
nx resetcd apps/data-crawler
# Basic usage
python main.py "computer science" --limit 10
# Advanced usage
python main.py "machine learning" --limit 50
python main.py "web development" --limit 25The project uses consistent formatting across all file types:
- Python: Black + isort + Flake8
- JSON/YAML: Prettier
- Markdown: Prettier
Run formatting:
pnpm format# Lint all projects
pnpm lint
# Lint specific project
nx run data-crawler:lint# Type check all Python code
pnpm type-check
# Type check specific project
nx run data-crawler:type-checkThe project includes pre-commit hooks using Husky and lint-staged:
# Install git hooks (run once)
pnpm prepareThis will automatically format and lint staged files before commits.
- Consistent tooling across all projects
- Shared libraries and utilities
- Efficient caching and task orchestration
- Dependency graph visualization
- Affected project detection
The crawler follows Python best practices:
- Modular design with separate concerns
- Type hints for better code quality
- Async support for scalable web crawling
- Configurable logging and output
- Extensible connector architecture
Optimized developer experience with:
- Auto-formatting on save
- Integrated linting and type checking
- Python intellisense and debugging
- Nx task runner integration
- Consistent settings across team members
The monorepo is designed to easily accommodate:
# Future backend structure
apps/
├── data-crawler/ # Current Python crawler
├── api-server/ # FastAPI/Django REST API
├── data-processor/ # Data processing service
├── notification-service/ # Email/webhook notifications
└── web-scraper/ # Additional scraping service# Future frontend structure
apps/
├── web-dashboard/ # React/Next.js dashboard
├── mobile-app/ # React Native mobile app
└── admin-panel/ # Admin interface# Shared code structure
libs/
├── shared-types/ # TypeScript type definitions
├── python-utils/ # Python utility functions
├── api-client/ # API client library
└── ui-components/ # Reusable UI components-
Create new app/library:
# For Python projects mkdir apps/new-python-app # Copy and modify project.json from data-crawler # For Node.js projects nx g @nx/node:app new-node-app
-
Configure project.json:
{ "name": "new-project", "projectType": "application", "targets": { "build": { "executor": "nx:run-commands", ... }, "serve": { "executor": "nx:run-commands", ... }, "lint": { "executor": "nx:run-commands", ... } } } -
Update workspace dependencies:
- Add to
pnpm-workspace.yamlif needed - Configure inter-project dependencies in Nx
- Add to
# View crawler logs
tail -f apps/data-crawler/crawler.log
# Follow real-time output
python apps/data-crawler/main.py "topic" --limit 5# Analyze Nx performance
nx report
# View task execution times
nx run data-crawler:run --verbose# View project dependencies
nx graph
# Check for circular dependencies
nx lint --fix- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes following the established patterns
- Run quality checks:
pnpm lint && pnpm type-check && pnpm format - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
nx.json: Nx workspace configurationproject.json: Individual project configurationspyproject.toml: Python project settings and tool configurations.vscode/settings.json: VS Code workspace settingspackage.json: Node.js dependencies and scripts.prettierrc: Code formatting rules
Create a .env file in the project root:
# Example environment variables
CRAWLER_LOG_LEVEL=INFO
CRAWLER_OUTPUT_DIR=./output
CRAWLER_RATE_LIMIT=1-
Python virtual environment not activated:
source venv/bin/activate -
Missing Python dependencies:
cd apps/data-crawler pip install -r requirements.txt -
Node.js version conflicts:
nvm use 18 # or your preferred version -
Nx cache issues:
nx reset
For issues and questions:
Built with ❤️ using Nx, Python, and modern development practices