# ๐Ÿ“š Bookmann A self-hosted ebook management system built with Go, PostgreSQL, HTMX, and Tailwind CSS (fully integrated into a single service) featuring multiple beautiful dark themes with Tokyo Night as default. ## โœจ Features - **๐Ÿ”’ Multi-User Authentication**: Complete user system with registration/login, JWT-based sessions, and bcrypt password hashing - **โœ… Server-Side Validation**: Comprehensive input validation with detailed error messages - **๐ŸŒ™ Multiple Themes**: 7 popular dark themes (Tokyo Night, Dracula, Nord, Solarized Dark, Monokai, One Dark Pro, Material Dark) with user preferences saved to database - **๐ŸŽจ Theme Persistence**: User theme choices sync between browser and server - **๐Ÿ“– Reading Progress**: User-specific reading progress tracking - **๐Ÿ”ง RESTful API**: Clean API endpoints with JWT authentication - **๐Ÿณ Docker Ready**: Single-container deployment with PostgreSQL - **๐Ÿงช API Testing**: Complete Bruno collection for testing all endpoints - **๐Ÿ“ฑ Responsive Design**: Mobile-first responsive interface using Tailwind CSS - **โšก HTMX Integration**: Dynamic interactions without JavaScript frameworks - **๐ŸŽฏ TypeScript Support**: Client-side scripting with TypeScript compilation ## Quick Start ### Prerequisites - Docker and Docker Compose ### Running the Application 1. Clone the repository 2. Run the application: ```bash docker-compose up --build ``` 3. Access the application at http://localhost:8765 ### Database PostgreSQL runs on port 5432 with default credentials: - Database: ebookdb - User: postgres - Password: password ## Development ### Backend ```bash cd backend go mod tidy go run github.com/sqlc-dev/sqlc/cmd/sqlc@latest generate go run cmd/server/main.go ``` The application uses Go HTML templates for server-side rendering with HTMX for dynamic interactions. Templates are located in `backend/templates/`. **โœจ Enhanced Features:** - **Authentication**: Login/Register forms with multiple theme support at `/login` and `/register` - **JWT Management**: Secure token storage with localStorage and session persistence - **Theme Switching**: 7 popular dark themes with dropdown selector and database persistence - **HTMX Integration**: Form submissions and dynamic updates without page reloads - **Input Validation**: Server-side validation with detailed error messages - **Multiple Themes**: Beautiful dark themes with smooth transitions - **Responsive Design**: Mobile-first approach with optimized layouts for all screen sizes **Note**: The frontend is fully integrated into the Go backend using HTML templates and HTMX. ## API Endpoints ### Auth (Public) - `POST /api/auth/register` - Register new user - `POST /api/auth/login` - Login user (email or username) - `GET /api/auth/profile` - Get user profile (requires JWT) - `PUT /api/auth/theme` - Update user theme preference (requires JWT) ### Ebooks (Protected) - `GET /api/ebooks` - List ebooks - `GET /api/ebooks/:id` - Get specific ebook - `POST /api/ebooks` - Create new ebook - `PUT /api/ebooks/:id` - Update ebook - `DELETE /api/ebooks/:id` - Delete ebook ### Reading Progress (Protected) - `GET /api/ebooks/:id/progress` - Get reading progress - `PUT /api/ebooks/:id/progress` - Update reading progress ## API Testing Use the included Bruno collection in the `bruno/` directory for testing the API: 1. Install [Bruno](https://www.usebruno.com/) 2. Import the `bruno/` folder as a collection 3. Select the "localhost" environment 4. Run the application and test the endpoints ## Project Structure ``` . โ”œโ”€โ”€ backend/ โ”‚ โ”œโ”€โ”€ cmd/server/ # Application entry point โ”‚ โ”œโ”€โ”€ internal/ โ”‚ โ”‚ โ”œโ”€โ”€ config/ # Configuration management โ”‚ โ”‚ โ”œโ”€โ”€ database/ # Database connection and queries โ”‚ โ”‚ โ””โ”€โ”€ handlers/ # HTTP handlers (auth + ebooks) โ”‚ โ”œโ”€โ”€ migrations/ # Database migrations โ”‚ โ”œโ”€โ”€ templates/ # Go HTML templates with HTMX โ”‚ โ””โ”€โ”€ sqlc.yaml # sqlc configuration โ”œโ”€โ”€ bruno/ # Bruno API testing collection โ”œโ”€โ”€ docker-compose.yml โ””โ”€โ”€ README.md ``` ## ๐ŸŽจ Recent Enhancements ### Backend Improvements - **Server-Side Rendering**: Replaced static frontend with Go HTML templates - **Theme System**: Database-backed user theme preferences with 7 popular dark themes - **HTMX Integration**: Dynamic interactions using HTMX for modern UX - **Enhanced Security**: JWT authentication with theme persistence ### Frontend Redesign - **Multiple Themes**: 7 beautiful dark themes (Tokyo Night default) with CSS variables - **HTMX Forms**: Real-time form submissions and updates without JavaScript frameworks - **Theme Switcher**: Dropdown selector that saves preferences to database - **Responsive Design**: Tailwind CSS for mobile-first responsive layouts ### Technical Updates - **Go Templates**: Server-side rendering with template inheritance - **Tailwind CSS**: Utility-first CSS framework via CDN - **TypeScript Support**: Client-side scripting with TypeScript compilation - **Database Schema**: Added theme column to users table - **API Expansion**: New theme update endpoint ## License GPL-3.0