Thanks to visit codestin.com
Credit goes to github.com

Skip to content

App to track and locate Coffee Bean Roasters worldwide, starting in the Greater Toronto and Hamilton Area (GTHA)

License

Notifications You must be signed in to change notification settings

thephm/the-beans

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

The Beans - Coffee Roaster Discovery App

A beautiful, modern full-stack web application for discovering and exploring specialty coffee roasters. Built with Next.js 14, Express.js, and PostgreSQL in a Docker-first development environment.

πŸš€ Features

Core Features

  • 🌍 Location-based Discovery: Find coffee roasters near you
  • β˜• Roaster Profiles: Detailed information including contact info, hours, and bean offerings
  • οΏ½ Owner Contact Information: Store roaster owner details (name, email, bio, mobile)
  • οΏ½πŸ‘₯ User Authentication: Secure sign up and login system
  • ⭐ Reviews & Favorites: Rate roasters and save your favorites
  • πŸ“Έ Image Uploads: Upload and share roaster photos
  • πŸ”” Notifications: Stay updated on new roasters and activity

Technical Features

  • πŸ”’ Secure API: RESTful API with comprehensive Swagger documentation
  • 🌐 Internationalization: Full i18n support (English/French)
  • πŸ’œ Beautiful Design: Purple-themed UI with lavender, violet, and orchid colors
  • πŸ”’ Admin Dashboard: Complete user and role management (admin only)
  • οΏ½ Audit Logging: Comprehensive activity tracking with geolocation and change history
  • οΏ½πŸ“± Responsive Design: Works seamlessly on desktop, tablet, and mobile
  • 🐳 Docker-First: Containerized development and deployment

Architecture

  • Frontend: Next.js 14 (App Router) with TypeScript
  • Backend: Express.js API with Prisma ORM
  • Database: PostgreSQL
  • Deployment: Docker-based containerization
  • CDN: Cloudflare for assets and domain management

🐳 Quick Start (Docker - Recommended)

⚠️ Critical: This project requires Docker container restarts for code changes to take effect. Hot reload is unreliable due to Docker volume mounting.

Prerequisites

Setup Steps

  1. Clone the repository

    git clone https://github.com/thephm/the-beans.git
    cd the-beans
  2. Start all services

    docker-compose up --build
  3. Access the applications

πŸ”„ Development Workflow

Essential: Always restart containers after code changes:

# After making frontend changes
docker-compose restart client

# After making backend changes  
docker-compose restart server

# Rebuild everything if needed
docker-compose up --build

# Stop all services
docker-compose down

πŸ‘€ Default Admin Account

πŸ—ƒοΈ Database Management

# Connect to PostgreSQL shell
docker exec -it the-beans-database-1 psql -U beans_user -d the_beans_db

# Check admin users
docker exec -it the-beans-database-1 psql -U beans_user -d the_beans_db -c "SELECT email, username, role FROM users WHERE role = 'admin';"

# Run database migrations
docker-compose exec server npx prisma migrate dev

# Generate Prisma client after schema changes
docker-compose exec server npx prisma generate

# Reset database (careful!)
docker-compose exec server npx prisma migrate reset

πŸ“§ Contact Us Email Setup

To enable the Contact Us form and email notifications, configure the following environment variables in server/.env:

# Email Recipients
CONTACT_US_EMAIL=[email protected]  # Receives Contact Us form submissions
ADMIN_EMAIL=[email protected]                    # Receives admin notifications

# SMTP Server Configuration
SMTP_HOST=smtp.yourprovider.com                  # e.g., smtp.gmail.com, smtp.fastmail.com
SMTP_PORT=587                                    # 587 for TLS, 465 for SSL
SMTP_USER=your-smtp-username                     # Usually your email address
SMTP_PASS=your-smtp-password                     # App-specific password or API key

After updating .env, restart the server container:

docker-compose restart server

For detailed setup instructions including Gmail, Fastmail, SendGrid, and troubleshooting, see the πŸ“§ Email Configuration Guide.


Documentation

Comprehensive documentation is maintained in the docs/ directory following docs-as-code principles.

Core Documentation

Feature Documentation

πŸ—οΈ Project Structure

the-beans/
β”œβ”€β”€ 🌐 client/                    # Next.js 14 Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/                 # App Router pages & layouts
β”‚   β”‚   β”œβ”€β”€ components/          # Reusable React components
β”‚   β”‚   β”œβ”€β”€ contexts/            # React Context providers
β”‚   β”‚   β”œβ”€β”€ lib/                # Utilities & configurations
β”‚   β”‚   └── types/              # TypeScript type definitions
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   β”œβ”€β”€ locales/            # i18n translation files
β”‚   β”‚   └── images/             # Static images & icons
β”‚   └── Dockerfile              # Frontend container config
β”œβ”€β”€ πŸ”§ server/                   # Express.js Backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ routes/             # RESTful API endpoints
β”‚   β”‚   β”œβ”€β”€ middleware/         # Auth & validation middleware
β”‚   β”‚   └── lib/               # Server utilities
β”‚   β”œβ”€β”€ prisma/
β”‚   β”‚   β”œβ”€β”€ schema.prisma      # Database schema
β”‚   β”‚   β”œβ”€β”€ migrations/        # Database migrations
β”‚   β”‚   └── seed.ts           # Database seeding
β”‚   β”œβ”€β”€ uploads/               # File upload storage
β”‚   └── Dockerfile            # Backend container config
β”œβ”€β”€ πŸ“š docs/                    # Documentation (docs-as-code)
β”œβ”€β”€ 🐳 docker-compose.yml       # Multi-service orchestration
└── πŸ“‹ Various config files     # Setup, CI/CD, etc.

πŸ› οΈ Development

🎯 Key Development Patterns

API Routes (server/src/routes/)

  • Authentication: optionalAuth (public), requireAuth (protected)
  • Admin Routes: Check user.role === 'admin'
  • Validation: express-validator for input sanitization
  • Error Handling: Consistent JSON error responses

Frontend API Client (client/src/lib/api.ts)

  • Centralized API client with JWT token management
  • Base URL: http://localhost:5000 (configurable)
  • Automatic token injection and refresh

Database (Prisma)

# After schema changes
docker-compose exec server npx prisma generate
docker-compose exec server npx prisma migrate dev

πŸ”§ Adding New Features

  1. Backend: Add routes in server/src/routes/ with proper middleware
  2. Frontend: Create components in client/src/components/
  3. Database: Update server/prisma/schema.prisma + generate + migrate
  4. i18n: Add translations to client/public/locales/{en,fr}/common.json
  5. Restart: Always restart containers after changes

πŸ§ͺ Testing Strategy

  • Frontend: Jest + React Testing Library
  • Backend: Jest + Supertest for API testing
  • E2E: Playwright for integration tests
  • Manual: Admin dashboard at /admin (requires admin login)

πŸš€ Deployment

For complete deployment documentation, see the Deployment Guide.

🌟 Render.com (Recommended)

The Beans includes a complete render.yaml configuration for one-click deployment on Render.com:

  1. Connect your GitHub repository to Render.com
  2. Create a new Blueprint from your repository (Render will detect render.yaml)
  3. Configure environment variables in Render dashboard:
    # Required for all deployments
    CLOUDINARY_CLOUD_NAME=your_cloud_name
    CLOUDINARY_API_KEY=your_api_key
    CLOUDINARY_API_SECRET=your_secret
    
    # For custom domains (optional)
    CORS_ORIGIN=https://yourdomain.com
    NEXT_PUBLIC_API_URL=https://api.yourdomain.com
    
  4. Deploy - Render will automatically create:
    • PostgreSQL database
    • Backend API service (Express.js)
    • Frontend web service (Next.js)

🐳 Docker-Based Deployment

Alternative deployment using Docker containers with docker-compose.yml.

πŸ—ƒοΈ Database Migration

# Automatic via render.yaml build process
# Or manual via Render shell:
npx prisma migrate deploy
npx prisma generate

🀝 Contributing

Development Process

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Develop using Docker: docker-compose up --build
  4. Restart containers after changes: docker-compose restart client server
  5. Test your changes thoroughly
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to branch: git push origin feature/amazing-feature
  8. Submit a pull request

Code Standards

  • TypeScript: Strict typing required
  • ESLint: Follow configured rules
  • Prettier: Auto-formatting enabled
  • i18n: All user-facing text must be translatable
  • Tests: Include tests for new features
  • Documentation: Update docs for new features

⚠️ Important Development Notes

Docker-First Workflow

  • Always restart containers after code changes: docker-compose restart client server
  • Hot reload is unreliable in the Docker environment
  • Database changes require Prisma generate + migrate
  • New translations require client container restart

Do Not Edit Compiled Files in Containers

  • The project builds TypeScript sources into a dist/ directory during the Docker image build. The files in /app/dist inside a running container are compiled artifacts and are not the authoritative source.
  • Do not edit files inside running containers. Changes made directly inside a container are ephemeral and will be overwritten the next time you rebuild the image or recreate the container.
  • To apply changes, edit the true source files (for the backend server/src/, for the frontend client/src/) and rebuild/restart the appropriate container(s):
# Rebuild server image and start it
docker-compose up -d --build server

# Or restart after code changes
docker-compose restart server

# Inspect compiled output in a running server container
docker exec the-beans-server-1 ls -la /app/dist
  • Recommended CI check: add a job that runs npm run build in the server (and optionally client) package to ensure TypeScript builds succeed on pull requests. This prevents mismatches between src/ and compiled dist/ artifacts.

Common Issues

  • Container won't start: Check Docker Desktop is running
  • Database connection fails: Ensure PostgreSQL container is healthy
  • API calls fail: Verify backend container is running on port 5000
  • Changes not visible: Restart the appropriate container
  • Admin access needed: Use [email protected] / admin123

URLs & Access

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ†˜ Support

About

App to track and locate Coffee Bean Roasters worldwide, starting in the Greater Toronto and Hamilton Area (GTHA)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •