autosync_backend2
v1.2.52
Published
A comprehensive business management system built with **Elysia** (TypeScript web framework) and **Bun** runtime. The system provides CRM, inventory management, warehouse operations, fleet management, and company management capabilities.
Readme
Autosync v2
A comprehensive business management system built with Elysia (TypeScript web framework) and Bun runtime. The system provides CRM, inventory management, warehouse operations, fleet management, and company management capabilities.
🚀 Quick Start
Prerequisites
- Bun runtime (latest version)
- PostgreSQL database
- Redis (for caching and sessions)
- AWS S3 account (for file storage)
- SMTP credentials (for email)
Installation
Clone the repository
git clone <repository-url> cd autosync-v2Install dependencies
bun installSet up environment variables
Create a
.envfile with the following variables:NODE_ENV=development PORT=3000 BETTER_AUTH_SECRET=your-secret-key DATABASE_URL=postgresql://user:password@localhost:5432/autosync UPSTASH_REDIS_REST_URL=your-redis-url UPSTASH_REDIS_REST_TOKEN=your-redis-token SMTP_USER=your-smtp-user SMTP_PASSWORD=your-smtp-password ATUT_TOKEN=your-atut-token AWS_ACCESS_KEY=your-aws-key AWS_SECRET_KEY=your-aws-secretRun database migrations
bun run db:migrateStart the development server
bun run devAccess the application
- API: http://localhost:3000/api
- Health Check: http://localhost:3000/health
- Swagger Documentation: http://localhost:3000/swagger
📚 Documentation
- API Documentation - Complete API reference
- Project Structure - Architecture and code organization
- Project Index - High-level overview
- Claude Guide - Development guidelines for AI assistants
🛠️ Development
Available Commands
# Development
bun run dev # Start development server with auto-reload
bun run build # Compile TypeScript and generate declarations
# Database
bun run db:generate # Generate migration files from schema changes
bun run db:migrate # Apply database migrations
# Code Quality
bun run biome:check # Format and lint with auto-fix
# Email Development
bun run email # Start email template development server
# Testing
bun test # Run test suite
bun test:watch # Run tests in watch modeCode Standards
- Indentation: Tabs
- Quotes: Double quotes
- Validation: TypeBox (not Zod)
- Database Naming: Snake_case
- TypeScript Naming: camelCase
🏗️ Architecture
The application follows a domain-driven architecture with the following main domains:
- Company Management - Multi-tenant company management with branches, employees, and service packages
- CRM - Customer relationship management with orders, payments, and service packages
- Fleet Management - Fleet and machine management with preventive maintenance and inspections
- Warehouse Management - Inventory and warehouse operations
- Technical Documentation - Technical documentation for suppliers and vehicle specifications
- User & Permissions - User authentication and role-based access control
Each domain follows a consistent pattern:
index.ts- Route definitions and middlewaremodel.ts- TypeBox validation schemaslogic.ts- Business logic and database operations
🗄️ Database
The system uses PostgreSQL with Drizzle ORM and a multi-schema design:
public- Core application tables (auth, permissions)crm- Customer relationship managementcompany- Organization managementwarehouse- Inventory and warehouse operationstechdoc- Technical documentationfleet- Fleet management
🔐 Authentication & Authorization
- Authentication: Better-auth library
- Authorization: Granular permission system with Redis caching
- User Kinds: ADMIN, COMPANY_ADMIN, CUSTOMER, EMPLOYEE
📦 Key Technologies
- Runtime: Bun
- Framework: Elysia
- Database: PostgreSQL with Drizzle ORM
- Authentication: Better-auth
- Validation: TypeBox
- Email: React Email
- Storage: AWS S3
- Caching: Redis (Upstash)
- Code Quality: Biome
🐳 Docker
Build and Deploy
# Build and push to ECR
make build
# Build production image
make build_prod📝 Баазийн бүтэц
🤝 Contributing
- Follow the code standards and patterns
- Update documentation when making changes
- Write tests for new features
- Use TypeBox for validation
- Follow the domain-driven structure
📄 License
[Add your license information here]
For detailed documentation, see the docs directory.
