A modern library management application with barcode scanning, automated notifications, and role-based access control.
graph TB
subgraph "Frontend (React + TypeScript)"
UI[User Interface]
Scanner[Barcode Scanner]
Auth[Auth Components]
Router[React Router]
State[State Management]
UI --> Scanner
UI --> Auth
Router --> UI
State --> UI
end
subgraph "API Layer"
tRPC[tRPC Client/Server]
Validation[Zod Schemas]
tRPC --> Validation
end
subgraph "Backend Services (Rust + Axum)"
API[REST API Handlers]
Auth_Service[Auth Service]
Book_Service[Book Service]
Checkout_Service[Checkout Service]
Email_Service[Email Service]
Middleware[Auth/CORS Middleware]
API --> Auth_Service
API --> Book_Service
API --> Checkout_Service
Middleware --> API
end
subgraph "Data Layer"
DB[(PostgreSQL/Supabase)]
Prisma[Prisma ORM]
SQLx[SQLx Queries]
Supabase_Client[Supabase Client]
Realtime[Real-time Subscriptions]
Prisma --> DB
SQLx --> DB
Supabase_Client --> DB
Realtime --> DB
end
subgraph "External Services"
OpenLibrary[Open Library API]
Resend[Resend Email API]
OAuth_Providers[GitHub/Google OAuth]
Camera[Device Camera]
Supabase_API[Supabase API]
end
subgraph "Background Jobs"
Cron[Tokio Cron Scheduler]
Overdue_Job[Overdue Email Job]
Cron --> Overdue_Job
Overdue_Job --> Email_Service
end
subgraph "Infrastructure"
Docker[Docker Containers]
Nginx[Reverse Proxy]
SSL[SSL/TLS]
Nginx --> SSL
Docker --> Nginx
end
%% Frontend connections
Router --> tRPC
Scanner --> Camera
Auth --> OAuth_Providers
UI --> Supabase_Client
State --> Realtime
%% API connections
tRPC --> API
%% Backend connections
Book_Service --> OpenLibrary
Book_Service --> Prisma
Checkout_Service --> SQLx
Auth_Service --> SQLx
Email_Service --> Resend
Supabase_Client --> Supabase_API
Realtime --> Supabase_API
%% Styling
classDef frontend stroke:#000,color:#fff
classDef backend stroke:#666,color:#fff
classDef database stroke:#333,color:#fff
classDef external stroke:#999,color:#fff
classDef infra stroke:#000,color:#fff
class UI,Scanner,Auth,Router,State frontend
class API,Auth_Service,Book_Service,Checkout_Service,Email_Service,Middleware,Cron,Overdue_Job backend
class DB,Prisma,SQLx,Supabase_Client,Realtime database
class OpenLibrary,Resend,OAuth_Providers,Camera,Supabase_API external
class Docker,Nginx,SSL infra
| Layer | Technology | Purpose |
|---|---|---|
| Frontend UI | React + TypeScript + Vite | Component-based SPA with hot reload |
| Routing | React Router | Client-side navigation |
| State Management | React Context/Zustand | Global state management |
| Styling | Tailwind CSS | Utility-first CSS framework |
| Barcode Scanning | @zxing/browser | Client-side ISBN recognition |
| Form Validation | Zod + React Hook Form | Type-safe form handling |
| API Layer | tRPC | End-to-end type safety |
| Backend Framework | Rust + Axum | High-performance async web framework |
| Database ORM | Prisma + SQLx | Type-safe database queries |
| Database | PostgreSQL/Supabase | ACID-compliant relational database |
| Real-time | Supabase Real-time | Live data synchronization and subscriptions |
| Authentication | Better Auth | Session management + OAuth |
| Background Jobs | Tokio Cron | Scheduled task execution |
| Email Service | Resend API | Transactional email delivery |
| External APIs | Open Library API | Book metadata retrieval |
| Runtime | Bun Workspace | Fast package management |
| Containerization | Docker + Docker Compose | Development and deployment |
| Reverse Proxy | Nginx | Load balancing and SSL termination |
| SSL/TLS | Let's Encrypt | HTTPS certificate management |
- User Interaction → React components handle UI events
- Form Submission → Zod validation → tRPC client call
- API Request → Axum middleware → Service layer → Database
- Background Jobs → Tokio cron → Email notifications
- External APIs → ISBN lookup → Book metadata enrichment
Prerequisites: Bun, Rust, PostgreSQL
# 1. Clone and install
git clone <your-repo-url> && cd library-management-app
cp .env.example .env
bun install
# 2. Setup database
createdb library_db
bun run db:migrate && bun run db:generate
# 3. Start development
bun run devFrontend: http://localhost:3000 | Backend: http://localhost:8080
Supabase provides managed PostgreSQL with additional features like real-time subscriptions, built-in auth, and automatic backups.
Setup:
- Create a Supabase project at https://supabase.com
- Follow the guide:
scripts/setup-supabase.md - Configure environment variables with Supabase credentials
Benefits:
- Managed PostgreSQL database
- Built-in real-time subscriptions
- Automatic backups and scaling
- Global CDN and edge functions
- Row-level security (RLS)
For local development or custom deployments.
Setup:
# Install PostgreSQL
createdb library_db
cp .env.example .env
# Update DATABASE_URL in .env
bun run db:migrateUsing the included Docker Compose setup.
Setup:
docker-compose --profile local-db up -d postgres
bun run db:migrateCreate .env from .env.example:
For Supabase:
DATABASE_URL="postgresql://postgres.[PROJECT-REF]:[PASSWORD]@aws-0-[REGION].pooler.supabase.com:6543/postgres"
DIRECT_URL="postgresql://postgres:[PASSWORD]@db.[PROJECT-REF].supabase.co:5432/postgres"
SUPABASE_URL="https://your-project-ref.supabase.co"
SUPABASE_ANON_KEY="your-supabase-anon-key"
BETTER_AUTH_SECRET="your-secure-secret-here"
RESEND_API_KEY="your-resend-api-key"For Local PostgreSQL:
DATABASE_URL="postgresql://postgres:password@localhost:5432/library_db"
BETTER_AUTH_SECRET="your-secure-secret-here"
RESEND_API_KEY="your-resend-api-key"bun run dev # Start development servers
bun run build # Build for production
bun run test # Run tests
bun run lint # Lint code
bun run db:migrate # Run database migrations- Book Management - Add, edit, delete books with ISBN integration and Open Library API metadata
- User Management - Role-based access control with administrative privileges
- Barcode Scanning - Camera-based ISBN scanning with real-time operation feedback
- Checkout System - Track loans, renewals, and returns with live status updates
- Real-time Updates - Live book availability and checkout status synchronization across all clients
- Email Notifications - Automated overdue alerts via Resend API
- Authentication - Session management with OAuth support (GitHub, Google)
- Live Dashboard - Real-time statistics and system connectivity monitoring
- Connection Status - Visual indicators for real-time data synchronization status