A modern, high-performance postal code autocomplete API service built with Nuxt.js, DrizzleORM, and SQLite. ZiPost provides fast and accurate postal code suggestions with comprehensive analytics and rate limiting.
- π Fast Autocomplete: Lightning-fast postal code suggestions
- π Authentication: JWT-based user authentication and API key management
- π Analytics: Comprehensive usage analytics and monitoring
- β‘ Rate Limiting: Flexible rate limiting based on subscription plans
- π Multi-Country Support: Extensible for multiple countries (currently supports Japan)
- π± Modern UI: Beautiful, responsive web interface
- π§ Developer-Friendly: RESTful API with comprehensive documentation
- Frontend: Nuxt.js 3, Vue 3, TypeScript, Tailwind CSS
- Backend: Nuxt.js Server API, Node.js
- Database: MySQL with Drizzle ORM
- Authentication: JWT tokens, bcrypt password hashing
- Rate Limiting: Database-backed rate limiting
- Testing: Vitest
- Deployment: Vercel-ready
- Node.js 18+ or Bun
- Git
- Install dependencies:
bun install-
Install and start MySQL server
-
Create a database named
zipost -
Copy environment variables:
cp .env.example .env- Update
.envwith your MySQL credentials:
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=zipost
JWT_SECRET=your-super-secret-jwt-key-here- Generate and run migrations:
bun run db:generate
bun run db:migrate- Import postal data:
bun run import:postal- Start the development server:
bun run devThe application will be available at http://localhost:3000.
POST /api/auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "securepassword"
}POST /api/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "securepassword"
}POST /api/keys/generate
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"name": "My App Key"
}GET /api/keys
Authorization: Bearer <jwt_token>POST /api/keys/{keyId}/revoke
Authorization: Bearer <jwt_token>GET /api/autocomplete?query=100&country=JP&limit=10
Authorization: Bearer <jwt_token>
# OR
X-API-Key: <api_key>Response:
{
"success": true,
"data": [
{
"postalCode": "1000001",
"prefecture": "Tokyo",
"city": "Chiyoda",
"town": "Chiyoda",
"prefectureKana": "γγ¦γγ§γ¦γ",
"cityKana": "γγ¨γγ―",
"townKana": "γγ¨γ"
}
],
"count": 1
}GET /api/analytics?days=30
Authorization: Bearer <jwt_token>The application uses MySQL with Drizzle ORM. Key tables:
- users: User accounts with email, password, subscription plans
- apiKeys: API key management with usage tracking
- postalData: Postal code information with multi-language support (Japanese/English)
- logs: Request logging for analytics and monitoring
- rateLimits: Rate limiting counters per user
- subscriptions: User subscription plans and limits
ZiPost implements flexible rate limiting based on subscription plans:
- Free Plan: 10 requests/minute, 100 requests/day
- Basic Plan: 100 requests/minute, 5,000 requests/day
- Pro Plan: 1,000 requests/minute, 50,000 requests/day
# Development
bun run dev # Start development server
bun run build # Build for production
bun run preview # Preview production build
# Database
bun run db:generate # Generate migrations
bun run db:migrate # Run migrations
bun run db:studio # Open Drizzle Studio
bun run import:postal # Import postal data
# Testing
bun run test # Run tests
bun run test:ui # Run tests with UIzipost/
βββ api/ # API route handlers
βββ components/ # Vue components
βββ models/ # Database schema and connection
β βββ db.ts # Database connection
β βββ schema.ts # DrizzleORM schema
βββ pages/ # Nuxt.js pages
βββ scripts/ # Utility scripts
βββ server/ # Server-side API routes
β βββ api/ # API endpoints
βββ services/ # Business logic services
β βββ auth.ts # Authentication service
β βββ postal.ts # Postal code service
β βββ rateLimit.ts # Rate limiting service
β βββ logging.ts # Logging service
βββ tests/ # Test files
Run the test suite:
bun run testThe tests cover:
- Authentication service functionality
- Postal code service operations
- Rate limiting logic
- Logging and analytics
- Integration scenarios
- Use a CDN for static assets
- Implement proper error monitoring
- Set up database backups
- Configure rate limiting based on your infrastructure
- Use environment-specific configurations
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request