Skip to content

cryptolandorg/crypto-card-integration-dapp

Repository files navigation

Crypto Card Integration dApp

A full-stack TypeScript tourist booking platform with debit card (Stripe) and cryptocurrency (Solana) payments, admin analytics, customer dashboard, communication hub, and AI support.

Features

  • Tour browsing, booking, and payment (Stripe card + Solana wallet)
  • Jupiter DEX integration for Solana token swaps (frontend)
  • JWT authentication with MFA (TOTP), sessions, and OAuth URL helpers
  • Customer dashboard (account, invoices, analytics, feedback)
  • Admin panel (users, billing, analytics, audit logs, system health)
  • Communication (chat, forums, broadcasts, AI chatbot, calls)
  • AI support assistant with FAQ suggestions
  • Docker Compose deployment for production-like stacks

Tech Stack

Layer Technology
Frontend Next.js 14, React 18, TypeScript, Tailwind CSS
Backend Fastify 4, TypeScript, SQLite (better-sqlite3)
Auth JWT, bcrypt, OTPAuth (MFA)
Payments Stripe API, Solana Web3.js, Jupiter DEX API
Tooling tsx, concurrently, ESLint

Project Structure

crypto-card-integration-dapp/
├── frontend/                 # Next.js TypeScript app
│   ├── app/                  # App Router pages
│   ├── components/           # React components
│   ├── contexts/             # Auth context
│   └── lib/                  # API clients, Solana helpers
├── backend/                  # Fastify TypeScript API
│   └── src/
│       ├── db/               # SQLite schema & seed
│       ├── middleware/       # JWT auth
│       ├── routes/             # API route handlers
│       └── services/         # Business logic
├── aws/                      # Docker Compose deployment
└── package.json              # Root monorepo scripts

Prerequisites

  • Node.js 20+ and npm
  • Optional: Stripe account (card payments), Solana wallet (crypto payments)

Quick Start

1. Install dependencies

npm run install-all

Frontend uses .npmrc with ignore-scripts=true to avoid optional native postinstall failures on Windows.

2. Configure environment

Backend — copy and edit:

cp backend/env.example backend/.env

Frontend — copy and edit:

cp frontend/env.example frontend/.env.local

3. Seed the database

npm run db:seed

This creates sample tours, forum categories, FAQs, and a welcome broadcast.

4. Run development servers

Both frontend and backend together:

npm run dev

Or separately:

npm run dev:backend   # http://localhost:8000
npm run dev:frontend  # http://localhost:3000

Environment Variables

Backend (backend/.env)

Variable Description Default
PORT API port 8000
DATABASE_PATH SQLite file path ./data/tourist.db
JWT_SECRET_KEY JWT signing secret (change in production)
STRIPE_SECRET_KEY Stripe secret key (empty = mock payments)
FRONTEND_URL CORS allowed origin http://localhost:3000
SOLANA_RPC_URL Solana RPC endpoint devnet
GOOGLE_CLIENT_ID OAuth Google (optional)
GITHUB_CLIENT_ID OAuth GitHub (optional)

Frontend (frontend/.env.local)

Variable Description Default
NEXT_PUBLIC_API_URL Backend API base URL http://localhost:8000
NEXT_PUBLIC_SOLANA_NETWORK Solana network devnet
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY Stripe publishable key

API Overview

Endpoint Method Description
/health GET Health check
/tours GET List tours
/auth/register POST Register user
/auth/login POST Login (MFA-aware)
/auth/me GET Current user
/bookings GET List bookings
/payments/stripe POST Process card payment
/payments/solana POST Record Solana payment
/dashboard/* * Customer dashboard
/admin/* * Admin operations
/communication/* * Chat, forums, broadcasts
/support/* * AI support & contact

Full interactive docs: start the backend and visit the route handlers in backend/src/routes/.

Build & Production

# Type-check everything
npm run typecheck

# Production build (backend + frontend)
npm run build

# Start production servers
npm run start

Docker

cd aws
docker compose up --build

See aws/README.md for deployment details.

Scripts Reference

Script Description
npm run dev Run frontend + backend in dev mode
npm run build Build both packages
npm run typecheck TypeScript check (no emit)
npm run db:seed Seed SQLite with sample data
npm run lint ESLint (frontend)

Payment Flow

Stripe (debit/credit card)

  1. User selects a tour and opens the payment modal.
  2. Frontend calls POST /payments/stripe with payment_method_id, amount, and tour_id.
  3. Backend confirms with Stripe (or mock mode without STRIPE_SECRET_KEY).
  4. Booking and payment records are created in SQLite.

Solana

  1. User connects a Solana wallet via @solana/wallet-adapter.
  2. Transaction is signed client-side; signature is sent to POST /payments/solana.
  3. Optional Jupiter DEX swap via frontend/lib/solana.ts.

Admin Access

Register a user, then promote to admin in the database:

UPDATE users SET role = 'admin' WHERE email = 'your@email.com';

Or use SQLite CLI:

cd backend
npx tsx -e "import {getDb} from './src/db/database.js'; getDb().prepare(\"UPDATE users SET role='admin' WHERE email=?\").run('your@email.com');"

Migration Notes (Python → TypeScript)

This project was migrated from a Python FastAPI + PostgreSQL stack to a 100% TypeScript codebase:

  • Backend: FastAPI → Fastify with SQLite (zero external DB for local dev)
  • Frontend: Already TypeScript; configs moved to .ts / .mjs
  • Removed: All .py files, Alembic, requirements.txt, shell deploy scripts

Troubleshooting

Issue Fix
npm install fails on frontend (Stellar SDK) Use npm install --ignore-scripts or rely on frontend/.npmrc
Backend port in use Change PORT in backend/.env
Empty tours list Run npm run db:seed
Stripe payments fail Set STRIPE_SECRET_KEY or use mock mode (no key)
CORS errors Ensure FRONTEND_URL matches your Next.js origin

Contact

For questions, integration support, or custom development:

Telegram: https://t.me/solzen77

License

MIT

About

Crypto Card Integration Dapp booking platform with stipe and solana payments, admin analytics, customer dashboard, communication hub, and AI support

Topics

Resources

Stars

94 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages