Files
2025-10-06 18:11:03 +02:00

164 lines
4.0 KiB
Markdown

# RFID-CP - RFID Card Management System
A modern web application for managing RFID cards and member access control built with Svelte 5, PostgreSQL, and Drizzle ORM.
## Features
- 🔐 **Admin Authentication**: Secure login system for administrators
- 👥 **Member Management**: Create and manage member profiles
- 🆔 **RFID Card Management**: Track and assign RFID cards to members
- 📱 **Web NFC Integration**: Scan RFID cards directly from browsers that support Web NFC
- 🎨 **Modern UI**: Built with Shadcn/ui components and Tailwind CSS
- 🌍 **Internationalization**: Multi-language support with Paraglide JS
- 📊 **Dashboard**: Overview of system statistics and recent activity
## Quick Start
### Prerequisites
- Node.js 18+
- PostgreSQL database
- npm or yarn
### Installation
1. Clone the repository:
```bash
git clone <repository-url>
cd rfid-cp
```
2. Install dependencies:
```bash
npm install
```
3. Set up environment variables:
```bash
cp .env.example .env
```
Edit `.env` and configure your database connection:
```env
DATABASE_URL="postgresql://username:password@localhost:5432/rfid_cp"
```
4. Set up the database:
```bash
# Push schema to database
npm run db:push
# Run migrations (if needed)
npm run db:migrate
```
5. Seed the database with initial data:
```bash
npm run db:seed
```
This will create:
- An admin user with credentials: `admin` / `admin123`
- Sample members, RFID cards, and assignments
- Sample devices
6. Start the development server:
```bash
npm run dev
```
The application will be available at `http://localhost:5173`.
## Database Seeding
The seeder script creates initial data for development and testing:
```bash
npm run db:seed
```
### What gets seeded:
- **Admin User**: `admin` / `admin123`
- **Sample Members**: Max Mustermann, Anna Schmidt, Peter Müller
- **RFID Cards**: Various cards with different statuses (NEW, ENGRAVED)
- **Assignments**: Cards assigned to members
- **Devices**: RFID scanner and lock system devices
## Available Scripts
- `npm run dev` - Start development server
- `npm run build` - Build for production
- `npm run preview` - Preview production build
- `npm run check` - Type checking
- `npm run lint` - Lint code
- `npm run format` - Format code
- `npm run db:push` - Push schema to database
- `npm run db:migrate` - Run migrations
- `npm run db:studio` - Open Drizzle Studio
- `npm run db:seed` - Seed database with initial data
## Project Structure
```
src/
├── lib/
│ ├── components/ # Reusable UI components
│ ├── server/ # Server-side utilities
│ └── utils/ # Utility functions
├── routes/ # SvelteKit routes
│ ├── admin/ # Admin panel routes
│ └── api/ # API routes
├── schemas/ # Database schemas and validation
└── rpc-routes/ # RPC route handlers
scripts/
└── seed.ts # Database seeding script
drizzle/ # Database migrations
```
## Technology Stack
- **Frontend**: Svelte 5, SvelteKit
- **Styling**: Tailwind CSS, Shadcn/ui
- **Database**: PostgreSQL with Drizzle ORM
- **Authentication**: Argon2 password hashing
- **Internationalization**: Paraglide JS
- **Forms**: SvelteKit Superforms
- **Icons**: Lucide Svelte
## Development
### Database Schema
The database schema is defined in `src/schemas/database/schema.ts` using Drizzle ORM. Key entities:
- `managementUsers` - Admin users
- `members` - System members
- `rfidCards` - RFID card inventory
- `memberRfidCards` - Card-to-member assignments
- `devices` - RFID scanners and lock systems
- `accessLogs` - Access event logging
- `systemLogs` - System event logging
### Web NFC Support
The application includes Web NFC integration for scanning RFID cards directly in supported browsers. The feature gracefully degrades when Web NFC is not available.
### Internationalization
The app supports multiple languages using Paraglide JS. Translation files are located in the `messages/` directory.
## License
[Add your license here]