A web platform for browsing, categorizing, and playing hypnosis audio recordings with advanced user management and administrative controls.
- Audio Library: Browse and play hypnosis audio tracks organized by categories
- Responsive Design: Works on desktop, tablet, and mobile devices
- Admin Dashboard: Manage categories, tags, tracks, users, and sharing settings
- User Management: Register and login with secure authentication
- Upload System: Upload new audio tracks with metadata
- Privacy Controls: Control visibility of tracks and share privately with specific users
- Shareable Links: Generate temporary access links to share content
- Playback Controls: Intuitive audio player with progress tracking
- Frontend: React with TypeScript, Tailwind CSS, shadcn/ui
- Backend: Express.js REST API
- Database: PostgreSQL with Drizzle ORM
- State Management: TanStack Query for data fetching and caching
- Routing: Wouter for lightweight client-side routing
- Authentication: Session-based authentication with Passport.js
- Node.js (v16+)
- npm or yarn
- PostgreSQL database (optional - in-memory storage is used by default)
The application features a robust automatic database initialization system:
- Development Mode: Uses in-memory storage by default (no database required)
- Docker/Production Mode: Automatically creates schema and seeds initial data
- Tables are created on first run if they don't exist
- Admin user and demo content are automatically added
- No manual migrations or SQL scripts required
The database initialization process follows these steps:
- Connection Check: Tests PostgreSQL connection with appropriate retry mechanism
- Schema Detection: Checks if database tables already exist
- Schema Creation: Creates tables if they don't exist using raw SQL queries
- Data Seeding:
- Checks if users already exist (to prevent duplicate seeding)
- Seeds admin user, categories, tags, and sample audio tracks
- Sets up proper relationships between entities
- Updates category counts with track counts
The system is designed to be resilient and handle various failure scenarios gracefully:
- Falls back to direct SQL queries if ORM operations fail
- Provides detailed error logging for troubleshooting
- Safely skips seeding if data already exists
This is configured via environment variables:
USE_DATABASE=false- Uses in-memory storage (default in development)USE_DATABASE=true- Uses PostgreSQL (required for Docker/production)DATABASE_URL- Connection string for PostgreSQL (used in Neon serverless)- Individual connection params like
POSTGRES_USER,POSTGRES_PASSWORD, etc. (used in standard PostgreSQL)
-
Clone the repository:
git clone <repository-url> cd hypnosis-audio-platform
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open your browser and navigate to:
http://localhost:5000
This application can be easily deployed using Docker Compose:
-
Clone the repository:
git clone <repository-url> cd hypnosis-audio-platform
-
Start the application stack with Docker Compose:
docker-compose up -d
For manual production deployment:
-
Build the application:
# Check TypeScript types npm run check # Build the client and server code npm run build
-
The database schema is automatically set up on application startup. No manual migration needed!
-
Start the application:
# Run in production mode NODE_ENV=production node dist/index.js -
The application will be available at:
http://localhost:5000 -
To stop the application:
docker-compose down
-
To also remove persistent data volumes:
docker-compose down -v
For environment variables in Docker, you can set them in a .env file and Docker will automatically load them. A sample .env.example file is provided as a template - copy it to .env and modify the values as needed.
The application comes with a default admin account:
- Username: admin
- Password: admin123
Use these credentials to access the admin dashboard at /admin.
├── client/ # Frontend React application
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── lib/ # Utility functions
│ │ ├── pages/ # Page components
│ │ └── App.tsx # Main application component
├── server/ # Backend Express application
│ ├── routes.ts # API routes
│ ├── storage.ts # Data storage implementation
│ ├── vite.ts # Vite server configuration
│ └── index.ts # Server entry point
├── shared/ # Shared code between client and server
│ └── schema.ts # Database schema and types
└── public/ # Static assets
The application provides the following API endpoints:
POST /api/auth/register- Register a new userPOST /api/auth/login- Login with existing credentialsPOST /api/auth/logout- Logout current userGET /api/auth/user- Get current authenticated user
GET /api/categories- Get all categoriesGET /api/categories/:id- Get category by IDGET /api/tags- Get all tagsGET /api/tracks- Get all accessible audio tracksGET /api/tracks/:id- Get audio track by IDGET /api/categories/:id/tracks- Get tracks in a categoryGET /api/search- Search for audio tracks
POST /api/progress- Save user listening progressGET /api/progress- Get user's progress for all tracks
POST /api/uploads/audio- Upload new audio file
GET /api/admin/users- Get all users (admin only)PUT /api/admin/users/:id- Update user (admin only)POST /api/admin/categories- Create category (admin only)PUT /api/admin/categories/:id- Update category (admin only)DELETE /api/admin/categories/:id- Delete category (admin only)POST /api/admin/tags- Create tag (admin only)PUT /api/admin/tags/:id- Update tag (admin only)DELETE /api/admin/tags/:id- Delete tag (admin only)PUT /api/admin/tracks/:id- Update track (admin only)PATCH /api/admin/tracks/:id/visibility- Toggle track visibility (admin only)DELETE /api/admin/tracks/:id- Delete track (admin only)
POST /api/shareable-links- Create a shareable linkGET /api/shareable-links- Get all shareable linksPUT /api/shareable-links/:id- Update shareable linkDELETE /api/shareable-links/:id- Delete shareable linkPOST /api/track-access- Grant user access to track (admin only)DELETE /api/track-access/:userId/:audioTrackId- Revoke user access (admin only)GET /api/track-access/:audioTrackId/users- Get users with access (admin only)
This project is licensed under the MIT License - see the LICENSE file for details.
