A modern, full-stack personal library management system
Frontend (Mobile)
- React Native with Expo
- TypeScript for type safety
- Axios for HTTP client
- expo-document-picker for file uploads
Backend (API Server)
- Node.js with Express
- Multer for multipart uploads
- pdf2pic for cover generation
- GraphicsMagick & Ghostscript for PDF processing
my-library-project/
├── backend/ # Node.js API server
│ ├── server.js # Express application
│ ├── Dockerfile # Container configuration
│ ├── docker-compose.yml # Docker orchestration
│ └── books/ # Storage directory
│
└── frontend/ # React Native mobile app
└── mobile/ # Expo project
├── src/
│ ├── core/ # Configuration (config.ts)
│ ├── services/ # API integration (api.ts)
│ ├── types/ # TypeScript definitions
│ ├── components/ # UI components (BookCard, UploadButton)
│ └── screens/ # Application views (HomeScreen)
├── App.tsx # Application entry point
├── package.json # Dependencies
└── app.json # Expo configuration
Library Management
- Browse complete book collection
- Pull-to-refresh synchronization
- Tap-to-open integration with system PDF viewer
- Real-time upload status tracking
File Upload
- Native document picker integration
- Multi-format support (PDF, EPUB, FB2, CBZ, MP3, M4B)
- Progress indicators during upload
- Automatic metadata extraction
PDF Cover Generation
- Automatic first-page extraction
- Server-side rendering at 600x800px
- Cached JPG thumbnails for performance
- Fallback icons for non-PDF formats
Dark Mode Theme
- Background: #121212
- Surface: #1E1E1E
- Accent: #BB86FC
- Optimized for OLED displays
Responsive Design
- Book cover aspect ratio: 1:1.4
- Rounded corners: 8px
- Smooth animations and transitions
- Loading states for async operations
All requests require API key header:
x-api-key: admin
Returns array of books with metadata.
Response:
[
{
"id": "book.pdf",
"name": "My Book",
"url": "/books/book.pdf?key=admin",
"coverUrl": "/books/book-cover.jpg?key=admin"
}
]Upload a new book file.
Request:
- Content-Type: multipart/form-data
- Field name:
book
Response:
{
"message": "Success",
"filename": "uploaded-file.pdf"
}- Node.js 16+
- Docker & Docker Compose (for backend)
- Expo CLI (installed automatically)
- Navigate to backend directory:
cd backend- Build and start Docker container:
docker-compose up -d --build- Verify installation:
docker logs my-library-backend
docker exec my-library-backend gm version- Navigate to frontend directory:
cd frontend/mobile- Install dependencies:
powershell -ExecutionPolicy Bypass -Command "npm install"- Configure API endpoint:
Edit src/core/config.ts:
export const config = {
API_URL: 'http://YOUR_VPS_IP:3000', // Update this
API_KEY: 'admin',
} as const;- Start development server:
powershell -ExecutionPolicy Bypass -Command "npm start"- Run on device:
- Install Expo Go app on iOS/Android
- Scan QR code from terminal
- Or press
afor Android emulator /ifor iOS simulator
Clean Architecture Principles
src/
├── core/ # Application configuration
├── services/ # External service integration
├── types/ # Type definitions
├── components/ # Presentational components
└── screens/ # Container components
Component Structure
BookCard: Displays book with cover or fallback iconUploadButton: File picker with upload progressHomeScreen: Main view with list and refresh control
Cover Generation Flow
- File uploaded via POST /api/upload
- If PDF, trigger background cover generation
- Extract first page using pdf2pic
- Convert to 600x800px JPEG
- Save as
{filename}-cover.jpg - Subsequent API calls include coverUrl
Performance Optimization
- Non-blocking cover generation
- Cached thumbnails
- Quality optimized at 100 DPI
- Average processing: 1-3 seconds per PDF
Dockerfile:
- Base: node:18-alpine
- System deps: graphicsmagick, ghostscript
- Port: 3000
- Volume: ./books
Server Settings:
const PORT = 3000;
const API_KEY = 'admin';
const BOOKS_DIR = path.join(__dirname, 'books');TypeScript:
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}Expo:
{
"expo": {
"userInterfaceStyle": "dark",
"orientation": "portrait"
}
}- Change Default API Key
// backend/server.js
const API_KEY = process.env.API_KEY || 'your-secure-key';- Enable HTTPS
- Use reverse proxy (nginx, Caddy)
- Configure SSL certificates
- Update frontend API_URL to https://
- Rate Limiting
- Implement request throttling
- Add file size limits
- Configure CORS appropriately
Storage:
- Mount external volume for books/
- Consider S3-compatible storage
- Implement periodic backups
Performance:
- Enable gzip compression
- Add CDN for book delivery
- Cache API responses
PowerShell Execution Policy
Error: "running scripts is disabled"
Solution:
powershell -ExecutionPolicy Bypass -Command "your-command"Cover Generation Failed
Check server logs:
docker logs my-library-backendVerify GraphicsMagick:
docker exec my-library-backend gm versionAndroid Emulator Connection
Use special localhost address:
API_URL: 'http://10.0.2.2:3000'TypeScript Errors
Install dependencies first:
cd frontend/mobile
npm installCover Generation:
- Library: pdf2pic v3.1.3
- Format: JPEG
- Server dimensions: 600×800px
- Mobile display: 56×78px
- Aspect ratio: 1:1.4
- Quality: 100 DPI
File Support:
- PDF (with cover generation)
- EPUB, FB2 (icon fallback)
- CBZ (comic books)
- MP3, M4B (audiobooks)
- Upload response: <500ms (excluding cover generation)
- Cover generation: 1-3 seconds (background)
- API list response: <100ms
- Mobile app startup: <2 seconds
MIT License - See LICENSE file for details
This project follows clean architecture and TypeScript strict mode. Pull requests welcome.
- Use TypeScript strict mode
- Follow ESLint configuration
- Document public APIs
- Write self-documenting code
- Use conventional commits format
- Include relevant test coverage
- Update documentation as needed
Built with Clean Architecture principles for maintainability and scalability.