# Stones Database A web application for managing contacts and their blockchain-related information, including NFT holdings, DAO memberships, and token holdings. ## Development Setup ### Prerequisites - Node.js (v16 or higher) - PostgreSQL database - Git ### Setup Instructions 1. Clone the repository ```bash git clone git@git.boilerhaus.org:boiler/stones.git cd stones ``` 2. Install dependencies ```bash npm install ``` 3. Set up the database - Create a PostgreSQL database named `stones` - Update the `.env.local` file with your database connection string: ``` DATABASE_URL="postgresql://username:password@localhost:5432/stones" ``` 4. Run database migrations ```bash npx prisma migrate dev npx prisma generate ``` 5. Start the development server ```bash npm run dev # or ./run-dev.sh ``` This will start the application at http://localhost:3000. ## Utility Scripts This project includes several utility scripts to streamline the development and deployment process: - `run-dev.sh`: Starts the development server with all necessary checks - `check-db.sh`: Tests database connectivity and displays database statistics - `push-to-gitea.sh`: Pushes changes to the Gitea repository - `deploy.sh`: Deploys the application to a production server - `backup-db.sh`: Creates a backup of the PostgreSQL database ### Using the Development Server To run the development server with automatic checks for dependencies and database setup: ```bash ./run-dev.sh ``` This script will: - Check for Node.js and npm - Create a `.env.local` file if it doesn't exist - Install dependencies if needed - Run database migrations - Start the development server ### Checking Database Connectivity To test your database connection and view statistics: ```bash ./check-db.sh ``` This script will connect to your database and display the number of contacts, NFT holdings, DAO memberships, and token holdings. ## Authentication The application uses a simple authentication system with a hardcoded admin user: - Username: `admin` - Password: `stones1234` For security in production, this should be replaced with a proper authentication system. ## Deployment For detailed deployment instructions, see [DEPLOYMENT.md](DEPLOYMENT.md). To deploy to a server: 1. Push changes to Gitea: ```bash ./push-to-gitea.sh ``` 2. Connect to your server and clone the repository: ```bash ssh your-server-user@your-server-ip git clone git@git.boilerhaus.org:boiler/stones.git cd stones ``` 3. Run the deployment script: ```bash ./deploy.sh ``` 4. Update the `.env.production` file with your production settings: ```bash nano .env.production ``` 5. Access your application at https://contact.boilerhaus.org (or your configured domain). ## Database Backups To back up your database: ```bash ./backup-db.sh ``` This creates a compressed SQL backup in `/var/backups/stones-database/` with a timestamp. ## Project Structure - `src/app`: Next.js App Router pages and API routes - `src/components`: React components - `src/lib`: Utility functions and libraries - `prisma`: Database schema and migrations - `scripts`: Data collection and processing scripts