https://github.com/shreshthmohan/foresty
https://github.com/shreshthmohan/foresty
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/shreshthmohan/foresty
- Owner: shreshthmohan
- Created: 2025-10-07T08:29:13.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-11-17T17:09:01.000Z (7 months ago)
- Last Synced: 2025-11-30T08:28:32.246Z (7 months ago)
- Language: HTML
- Size: 166 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Roadmap: ROADMAP.md
Awesome Lists containing this project
README
# Welcome to React Router!
A modern, production-ready template for building full-stack React applications using React Router.
## Features
- 🚀 Server-side rendering
- ⚡️ Hot Module Replacement (HMR)
- 📦 Asset bundling and optimization
- 🔄 Data loading and mutations
- 🔒 TypeScript by default
- 🎉 TailwindCSS for styling
- 📖 [React Router docs](https://reactrouter.com/)
## Getting Started
### Installation
Install the dependencies:
```bash
pnpm install
```
### Database Setup
This project uses Cloudflare D1 for the database.
1. Create the D1 database:
```bash
pnpm wrangler d1 create foresty-db
```
2. Add the database binding to `wrangler.jsonc` (already configured):
```jsonc
"d1_databases": [
{
"binding": "DB",
"database_name": "foresty-db",
"database_id": "f7836b69-2a9e-48ac-8bdc-f7be6aa495eb"
}
]
```
3. Apply migrations to local database:
```bash
pnpm wrangler d1 migrations apply foresty-db --local
```
4. Apply migrations to remote database (when ready to deploy):
```bash
pnpm wrangler d1 migrations apply foresty-db --remote
```
### Development
Start the development server with HMR:
```bash
pnpm run dev
```
Your application will be available at `http://localhost:5173`.
## Previewing the Production Build
Preview the production build locally:
```bash
pnpm run preview
```
## Building for Production
Create a production build:
```bash
pnpm run build
```
## Deployment
Deployment is done using the Wrangler CLI.
To build and deploy directly to production:
```sh
pnpm run deploy
```
To deploy a preview URL:
```sh
pnpm wrangler versions upload
```
You can then promote a version to production after verification or roll it out progressively.
```sh
pnpm wrangler versions deploy
```
## Styling
This template comes with [Tailwind CSS](https://tailwindcss.com/) already configured for a simple default starting experience. You can use whatever CSS framework you prefer.
---
Built with ❤️ using React Router.
## Development Workflow
### Local vs Remote Database
- **Local development**: `pnpm dev` (uses local D1 database)
- **Remote development**: `pnpm dev:remote` (uses production D1 database)
### Database Migrations
Apply migrations to local database:
```bash
pnpm wrangler d1 migrations apply foresty-db --local
```
Apply migrations to remote database:
```bash
pnpm wrangler d1 migrations apply foresty-db --remote
```
### Data Population Scripts
The project includes scripts to scrape data from Auroville Herbarium and populate the database.
#### Single Species
Scrape and import a single species:
```bash
./scripts/scrape-and-import.sh [--local|--remote|--both]
```
Examples:
```bash
# Import to local database only
./scripts/scrape-and-import.sh 172 --local
# Import to remote database only
./scripts/scrape-and-import.sh 172 --remote
# Import to both local and remote
./scripts/scrape-and-import.sh 172 --both
```
Or use the individual npm scripts:
```bash
# Generate SQL for single species
pnpm db:generate-single 172
# Populate local database
pnpm wrangler d1 execute foresty-db --local --file=scripts/populate-single.sql
# Populate remote database
pnpm wrangler d1 execute foresty-db --remote --file=scripts/populate-single.sql
```
#### All Species
Scrape all species and populate database:
```bash
# For local database
pnpm db:populate-all
# For remote database
pnpm db:generate-all
pnpm wrangler d1 execute foresty-db --remote --file=scripts/populate-all.sql
```
### Web Scraping
The project uses Scrapy to scrape plant species data. See [spider/README.md](spider/README.md) for detailed documentation.
Quick commands (run from `spider/` directory):
```bash
cd spider
# Get list of all species
uv run scrapy crawl ah-spider -O species_list.json
# Scrape specific species
uv run scrapy crawl species -a species_id=172
```
### Database Queries
For common database queries and examples, see [docs/database.md](docs/database.md).