autosync_backend2 1.2.29 → 1.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +162 -11
  2. package/dist/index.d.ts +1326 -266
  3. package/dist/index.js +278 -11
  4. package/package.json +4 -4
package/README.md CHANGED
@@ -1,25 +1,176 @@
1
- # Elysia with Bun runtime
1
+ # Autosync v2
2
2
 
3
- ## Getting Started
3
+ 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.
4
4
 
5
- To get started with this template, simply paste this command into your terminal:
5
+ ## 🚀 Quick Start
6
+
7
+ ### Prerequisites
8
+
9
+ - [Bun](https://bun.sh) runtime (latest version)
10
+ - PostgreSQL database
11
+ - Redis (for caching and sessions)
12
+ - AWS S3 account (for file storage)
13
+ - SMTP credentials (for email)
14
+
15
+ ### Installation
16
+
17
+ 1. **Clone the repository**
18
+ ```bash
19
+ git clone <repository-url>
20
+ cd autosync-v2
21
+ ```
22
+
23
+ 2. **Install dependencies**
24
+ ```bash
25
+ bun install
26
+ ```
27
+
28
+ 3. **Set up environment variables**
29
+
30
+ Create a `.env` file with the following variables:
31
+ ```env
32
+ NODE_ENV=development
33
+ PORT=3000
34
+ BETTER_AUTH_SECRET=your-secret-key
35
+ DATABASE_URL=postgresql://user:password@localhost:5432/autosync
36
+ UPSTASH_REDIS_REST_URL=your-redis-url
37
+ UPSTASH_REDIS_REST_TOKEN=your-redis-token
38
+ SMTP_USER=your-smtp-user
39
+ SMTP_PASSWORD=your-smtp-password
40
+ ATUT_TOKEN=your-atut-token
41
+ AWS_ACCESS_KEY=your-aws-key
42
+ AWS_SECRET_KEY=your-aws-secret
43
+ ```
44
+
45
+ 4. **Run database migrations**
46
+ ```bash
47
+ bun run db:migrate
48
+ ```
49
+
50
+ 5. **Start the development server**
51
+ ```bash
52
+ bun run dev
53
+ ```
54
+
55
+ 6. **Access the application**
56
+ - API: <http://localhost:3000/api>
57
+ - Health Check: <http://localhost:3000/health>
58
+ - Swagger Documentation: <http://localhost:3000/swagger>
59
+
60
+ ## 📚 Documentation
61
+
62
+ - **[API Documentation](./docs/API.md)** - Complete API reference
63
+ - **[Project Structure](./docs/STRUCTURE.md)** - Architecture and code organization
64
+ - **[Project Index](./PROJECT_INDEX.md)** - High-level overview
65
+ - **[Claude Guide](./CLAUDE.md)** - Development guidelines for AI assistants
66
+
67
+ ## 🛠️ Development
68
+
69
+ ### Available Commands
6
70
 
7
71
  ```bash
8
- bun create elysia ./elysia-example
72
+ # Development
73
+ bun run dev # Start development server with auto-reload
74
+ bun run build # Compile TypeScript and generate declarations
75
+
76
+ # Database
77
+ bun run db:generate # Generate migration files from schema changes
78
+ bun run db:migrate # Apply database migrations
79
+
80
+ # Code Quality
81
+ bun run biome:check # Format and lint with auto-fix
82
+
83
+ # Email Development
84
+ bun run email # Start email template development server
85
+
86
+ # Testing
87
+ bun test # Run test suite
88
+ bun test:watch # Run tests in watch mode
9
89
  ```
10
90
 
11
- ## Development
91
+ ### Code Standards
92
+
93
+ - **Indentation**: Tabs
94
+ - **Quotes**: Double quotes
95
+ - **Validation**: TypeBox (not Zod)
96
+ - **Database Naming**: Snake_case
97
+ - **TypeScript Naming**: camelCase
12
98
 
13
- To start the development server run:
99
+ ## 🏗️ Architecture
100
+
101
+ The application follows a **domain-driven architecture** with the following main domains:
102
+
103
+ - **Company Management** - Multi-tenant company management with branches, employees, and service packages
104
+ - **CRM** - Customer relationship management with orders, payments, and service packages
105
+ - **Fleet Management** - Fleet and machine management with preventive maintenance and inspections
106
+ - **Warehouse Management** - Inventory and warehouse operations
107
+ - **Technical Documentation** - Technical documentation for suppliers and vehicle specifications
108
+ - **User & Permissions** - User authentication and role-based access control
109
+
110
+ Each domain follows a consistent pattern:
111
+ - `index.ts` - Route definitions and middleware
112
+ - `model.ts` - TypeBox validation schemas
113
+ - `logic.ts` - Business logic and database operations
114
+
115
+ ## 🗄️ Database
116
+
117
+ The system uses **PostgreSQL** with **Drizzle ORM** and a multi-schema design:
118
+
119
+ - `public` - Core application tables (auth, permissions)
120
+ - `crm` - Customer relationship management
121
+ - `company` - Organization management
122
+ - `warehouse` - Inventory and warehouse operations
123
+ - `techdoc` - Technical documentation
124
+ - `fleet` - Fleet management
125
+
126
+ ## 🔐 Authentication & Authorization
127
+
128
+ - **Authentication**: Better-auth library
129
+ - **Authorization**: Granular permission system with Redis caching
130
+ - **User Kinds**: ADMIN, COMPANY_ADMIN, CUSTOMER, EMPLOYEE
131
+
132
+ ## 📦 Key Technologies
133
+
134
+ - **Runtime**: Bun
135
+ - **Framework**: Elysia
136
+ - **Database**: PostgreSQL with Drizzle ORM
137
+ - **Authentication**: Better-auth
138
+ - **Validation**: TypeBox
139
+ - **Email**: React Email
140
+ - **Storage**: AWS S3
141
+ - **Caching**: Redis (Upstash)
142
+ - **Code Quality**: Biome
143
+
144
+ ## 🐳 Docker
145
+
146
+ ### Build and Deploy
14
147
 
15
148
  ```bash
16
- bun run dev
149
+ # Build and push to ECR
150
+ make build
151
+
152
+ # Build production image
153
+ make build_prod
17
154
  ```
18
155
 
19
- Open <http://localhost:3000/> with your browser to see the result.
156
+ ## 📝 Баазийн бүтэц
157
+
158
+ - [Байгууллага](./src/lib/db/schema/company.md)
159
+ - [Агуулах](./src/lib/db/schema/warehouse.schema.ts)
160
+
161
+ ## 🤝 Contributing
162
+
163
+ 1. Follow the code standards and patterns
164
+ 2. Update documentation when making changes
165
+ 3. Write tests for new features
166
+ 4. Use TypeBox for validation
167
+ 5. Follow the domain-driven structure
168
+
169
+ ## 📄 License
170
+
171
+ [Add your license information here]
20
172
 
21
- ## Баазийн бүтэц
173
+ ---
22
174
 
23
- - [Байгууллага](./src/lib/db/schema/merchant.md)
24
- - [Агуулах](./src/lib/db/schema/inventory.md)
175
+ For detailed documentation, see the [docs](./docs/) directory.
25
176