done ver1.0.0

This commit is contained in:
2026-04-02 11:16:18 +07:00
parent 58dbefa155
commit d09ba3d2ad
21 changed files with 3271 additions and 668 deletions

284
README.md
View File

@@ -1,166 +1,196 @@
# 🎯 AccManager - SQL Server Backend Setup Complete
# 🔐 AccManager
## ✅ Database Configuration Complete
Hệ thống quản lý tài khoản và ứng dụng tập trung, cho phép quản lý người dùng, danh mục ứng dụng, và gán tài khoản truy cập.
SQL Server database **AccManager** has been successfully configured with all necessary tables and initial data.
## ✨ Tính năng
### 📊 Database Information
- ✅ Xác thực người dùng (login/register)
- ✅ Quản lý người dùng và vai trò (admin/guest)
- ✅ Quản lý danh mục ứng dụng
- ✅ Gán tài khoản cho mỗi người dùng/ứng dụng
- ✅ Mã hóa mật khẩu bằng bcrypt (bcrypt hashing)
- ✅ Migration tự động: plain text → bcrypt
- ✅ Audit log truy cập
```
Server IP: 172.20.235.176
Database: AccManager
User: sa
Password: robotics@2020
Port: 1433 (default)
```
## 🛠️ Công nghệ
### 👤 Default Admin Account
| Thành phần | Công nghệ |
|-----------|----------|
| Backend | Node.js 20 + Express.js |
| Database | SQL Server 2022 |
| Frontend | HTML5 + Tailwind CSS + Vanilla JS |
| Container | Docker + Docker Compose |
| Reverse Proxy | Nginx Proxy Manager |
| Password Hashing | bcrypt |
```
Username: admin
Password: admin
Role: admin
Status: Active
```
## 📦 Cấu trúc dự án
## 📋 Database Tables Created
\\\
├── backend/
│ └── server.js # Main server (Express + mssql)
├── public/ # Static files (HTML, CSS, JS)
│ ├── index.html
│ ├── pages/ # Login, dashboard, etc.
│ ├── js/
│ │ └── app.js # Frontend logic
│ └── css/
│ ├── main.css # Tailwind compiled
│ └── tailwind.css # Tailwind source
├── database/
│ └── setup.sql # Database schema
├── Dockerfile # Docker image config
├── docker-compose.yml # Local development
├── docker-compose.image.yml # Production deployment
├── .env # Environment variables
├── deploy-dev.ps1 # Build & push script
├── deploy-server.sh # Pull & deploy script
└── DEPLOYMENT_GUIDE.md # Detailed deployment guide (Vietnamese)
\\\
### 1. **Users** - User Management
- Stores login credentials and user roles
- Default admin user: admin/admin
## 🚀 Khởi động nhanh
### 2. **Applications** - Service Management
- 4 sample applications pre-loaded:
- AWS (Cloud) - online
- GitHub (VCS) - online
- Google Workspace (Collaboration) - online
- Nginx Proxy (Infra) - offline
### Phát triển local
### 3. **Accounts** - Credential Storage
- Stores credentials for each user-application combination
- Linked to Users and Applications tables
### 4. **AuditLog** - Activity Tracking
- Logs all INSERT, UPDATE, DELETE operations
- User actions tracked for security
## 🚀 Backend Server Options
### Option 1⃣: Node.js + Express (Recommended)
**Files:**
- `server.js` - Main server file
- `package.json` - Dependencies
**Quick Start:**
```bash
# 1. Install Node.js from https://nodejs.org/
# 2. Install dependencies
\\\ash
npm install
# 3. Run server
npm start
\\\
# Server runs on: http://localhost:3000
```
Truy cập: http://localhost:3000
### Option 2⃣: Python + Flask
### Chạy bằng Docker
**Files:**
- `server_python.py` - Main server file
- `requirements.txt` - Dependencies
\\\ash
docker compose build
docker compose up -d
\\\
**Quick Start:**
```bash
# 1. Install Python 3.8+ from https://www.python.org/
# 2. Install dependencies
pip install -r requirements.txt
## 🐳 Triển khai với Docker
# 3. Run server
python server_python.py
### Máy DEV: Build & Push
# Server runs on: http://localhost:5000
```
\\\powershell
cd D:\RoboticsSource\AccManager
.\deploy-dev.ps1 -Tag "1.0.1"
\\\
## 📡 API Endpoints
### Máy Server: Deploy
### Health Check
```http
GET /api/health
```
\\\ash
ssh robotics@172.20.235.176
cd ~/accmanager
bash deploy-server.sh
\\\
**Xem chi tiết**: [DEPLOYMENT_GUIDE.md](DEPLOYMENT_GUIDE.md) (Tiếng Việt)
## 🔐 Bảo mật
- Mật khẩu được mã hóa bằng bcrypt (12 rounds)
- Migration tự động từ plain text sang bcrypt
- Không lưu credential trong source control
- Sử dụng .env để cấu hình biến sensitive
- SQL Server connection sử dụng SSL/TLS tùy chọn
**Lưu ý:**
- Thay đổi mật khẩu admin mặc định (\dmin\/\dmin\) ngay sau khi đăng nhập lần đầu
- Không commit \.env\ thực tế lên git
## 📚 API Endpoints
### Authentication
```http
POST /api/auth/login
```
- POST \/api/auth/login\ - Đăng nhập
- POST \/api/auth/register\ - Đăng ký
### Users Management
```http
GET /api/users
GET /api/users/:id
POST /api/users
```
### Users (Admin)
- GET \/api/users\ - Lấy danh sách người dùng
- GET \/api/users/:id\ - Lấy thông tin người dùng
- POST \/api/users\ - Tạo người dùng mới
- PUT \/api/users/:id\ - Cập nhật người dùng
- DELETE \/api/users/:id\ - Xóa người dùng
### Applications
```http
GET /api/applications
POST /api/applications
```
- GET \/api/applications\ - Danh sách ứng dụng
- POST \/api/applications\ - Tạo ứng dụng
### Accounts
```http
GET /api/accounts/user/:userId
POST /api/accounts
```
- GET \/api/accounts/user/:userId\ - Tài khoản của người dùng
- POST \/api/accounts\ - Tạo tài khoản
### Database Info
```http
GET /api/database/info
```
## 🔧 Cấu hình
## 📚 Documentation Files
### .env (Development)
- **README.md** (this file) - Overview
- **SETUP_GUIDE.md** - Detailed installation steps
- **DATABASE_SETUP.md** - Schema and API documentation
- **server.js** - Node.js backend source
- **server_python.py** - Python backend source
\\\env
NODE_ENV=production
APP_PORT=3000
DOCKER_IMAGE=toiiiiday/accmanager:1.0.1
## 🔐 Default Credentials
# Container
PORT=3000
```
Username: admin
Password: admin
Role: admin
```
# Database
DB_SERVER=172.20.235.176
DB_USER=sa
DB_PASSWORD=robotics@2022
DB_NAME=AccManager
DB_ENCRYPT=false
DB_TRUST_CERTIFICATE=true
DB_CONNECT_TIMEOUT=30000
## 🔧 Project Files
# Security
BCRYPT_ROUNDS=12
\\\
```
d:\RoboticsSource\AccManager\
├── server.js (Node.js backend)
├── server_python.py (Python backend)
├── package.json (Node.js dependencies)
├── requirements.txt (Python dependencies)
├── .env (Configuration)
├── database/
│ └── setup.sql (SQL setup script)
├── SETUP_GUIDE.md (Installation guide)
├── DATABASE_SETUP.md (Database documentation)
└── README.md (This file)
```
## 🌐 Triển khai Public với Domain
## ✅ Status
Xem: [DEPLOYMENT_GUIDE.md](DEPLOYMENT_GUIDE.md) - Mục "Public Domain qua Nginx Proxy Manager"
- ✓ Database created (AccManager)
- ✓ 4 tables created (Users, Applications, Accounts, AuditLog)
- ✓ Admin user created (admin/admin)
- ✓ Sample applications added
- ✓ Backend servers ready (Node.js + Python options)
- ✓ API endpoints documented
**Tóm tắt:**
1. Trỏ DNS A record về IP Nginx Proxy Manager
2. Tạo Proxy Host trong NPM: forward 3000 → domain
3. Enable Let's Encrypt SSL + Force SSL
## 📝 Tài liệu
- [DEPLOYMENT_GUIDE.md](DEPLOYMENT_GUIDE.md) - Hướng dẫn triển khai (Tiếng Việt)
- [package.json](package.json) - Dependencies
- [docker-compose.yml](docker-compose.yml) - Dev config
- [docker-compose.image.yml](docker-compose.image.yml) - Prod config
## 📦 Build & Run Scripts
**Windows PowerShell (DEV):**
\\\powershell
.\deploy-dev.ps1 -Tag "1.0.1"
\\\
**Linux/Mac (SERVER):**
\\\ash
bash deploy-server.sh
\\\
## 🆘 Troubleshoot
**Container không start?**
\\\ash
docker compose -f docker-compose.image.yml logs --tail=100 accmanager
\\\
**Image pull fail?**
- Kiểm tra Docker Hub credentials
- Kiểm tra image đã push: https://hub.docker.com/r/toiiiiday/accmanager
**Database connection fail?**
- Kiểm tra .env (DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME)
- Ping server: \ping 172.20.235.176\
## 📄 License
MIT
---
**Version:** 2.0.0 (Backend Ready)
**Database:** SQL Server / AccManager
**Last Updated:** March 27, 2026
**Phiên bản:** 2.0.0
**Cập nhật:** Tháng 4 năm 2026
**Trạng thái:** Production-ready ✅