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.
npm install autosync_backend2A 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.
- Bun runtime (latest version)
- PostgreSQL database
- Redis (for caching and sessions)
- AWS S3 account (for file storage)
- SMTP credentials (for email)
1. Clone the repository
``bash`
git clone
cd autosync-v2
2. Install dependencies
`bash`
bun install
3. Set up environment variables
Create a .env file with the following variables:`
env`
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-secret
4. Run database migrations
`bash`
bun run db:migrate
5. Start the development server
`bash`
bun run dev
6. Access the application
- API:
- Health Check:
- 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
`bashDevelopment
bun run dev # Start development server with auto-reload
bun run build # Compile TypeScript and generate declarations
$3
- 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 middleware
- model.ts - TypeBox validation schemas
- logic.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 management
- company - Organization management
- warehouse - Inventory and warehouse operations
- techdoc - Technical documentation
- fleet - 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
$3
`bash
Build and push to ECR
make buildBuild production image
make build_prod
``1. Follow the code standards and patterns
2. Update documentation when making changes
3. Write tests for new features
4. Use TypeBox for validation
5. Follow the domain-driven structure
[Add your license information here]
---
For detailed documentation, see the docs directory.