@@ -15,13 +15,21 @@ A modular and extensible backend API for the DeployStack CI/CD platform, built w
1515- ** Logging** : Comprehensive request logging with request IDs and timing
1616- ** Developer-friendly** : Pretty logging in development, production-ready in production
1717
18- ## 🚀 Run
18+ ## 🚀 Quick Start with Docker
1919
2020``` bash
21+ # Run with Docker (using docker-compose recommended)
22+ docker-compose up -d
23+
24+ # Or run standalone with volume for data persistence
2125docker run -it -p 3000:3000 \
22- -e FOO=bar22 \
23- -v $( pwd) /data:/app/data \
26+ -e NODE_ENV=production \
27+ -e DEPLOYSTACK_ENCRYPTION_SECRET=your-32-character-secret-key-here \
28+ -v deploystack_data:/app/persistent_data \
2429 deploystack/backend:latest
30+
31+ # Access the setup wizard at http://localhost:3000
32+ # (or http://localhost:8080 if using the full docker-compose stack)
2533```
2634
2735## 📋 Prerequisites
@@ -31,20 +39,44 @@ docker run -it -p 3000:3000 \
3139
3240## 🛠️ Installation
3341
42+ ### Development Setup
43+
3444``` bash
3545# Clone the repository
36- git clone https://github.com/deploystack /deploystack.git
46+ git clone https://github.com/deploystackio /deploystack.git
3747cd deploystack
3848
3949# Navigate to backend directory
4050cd services/backend
4151
4252# Install dependencies
4353npm install
54+
55+ # Create .env file (see Environment Variables section)
56+ cp .env.example .env # Or create manually
57+
58+ # Start development server
59+ npm run dev
60+
61+ # Access at http://localhost:3000
62+ ```
63+
64+ ### Production Setup with Docker
65+
66+ ``` bash
67+ # Using Docker Compose (recommended)
68+ git clone https://github.com/deploystackio/deploystack.git
69+ cd deploystack
70+ docker-compose up -d
71+
72+ # Access frontend at http://localhost:8080
73+ # Backend API at http://localhost:3000
4474```
4575
4676## 🚀 Usage
4777
78+ ### Development Commands
79+
4880``` bash
4981# Run in development mode (with live reloading)
5082npm run dev
@@ -57,94 +89,73 @@ npm run start
5789
5890# Lint and fix TypeScript files
5991npm run lint
60- ```
6192
62- ## 🧱 Project Structure
93+ # Database migrations
94+ npm run db:generate # Generate new migrations
95+ npm run db:up # Apply migrations
6396
64- ``` bash
65- services/backend/
66- ├── src/
67- │ ├── api/ # API route handlers
68- │ ├── db/ # Database configuration and schema
69- │ │ ├── config.ts # Database connection setup
70- │ │ ├── index.ts # Database exports
71- │ │ ├── migrations.ts # Migration management
72- │ │ └── schema.ts # Database schema definitions
73- │ ├── email/ # Email system (NEW)
74- │ │ ├── templates/ # Pug email templates
75- │ │ │ ├── layouts/ # Base layout components
76- │ │ │ │ ├── base.pug # Main email layout
77- │ │ │ │ ├── header.pug # Email header
78- │ │ │ │ └── footer.pug # Email footer
79- │ │ │ ├── welcome.pug # Welcome email template
80- │ │ │ ├── password-reset.pug # Password reset template
81- │ │ │ └── notification.pug # General notification template
82- │ │ ├── emailService.ts # Main email service
83- │ │ ├── templateRenderer.ts # Pug template renderer
84- │ │ ├── types.ts # Email type definitions
85- │ │ ├── example.ts # Usage examples
86- │ │ └── index.ts # Email module exports
87- │ ├── fastify/ # Fastify configuration
88- │ │ ├── config/ # Fastify setup
89- │ │ ├── hooks/ # Request/response hooks
90- │ │ └── plugins/ # Fastify plugins
91- │ ├── global-settings/ # Global configuration system
92- │ │ ├── github-oauth.ts # GitHub OAuth settings
93- │ │ ├── smtp.ts # SMTP email settings
94- │ │ ├── types.ts # Global settings types
95- │ │ └── index.ts # Settings initialization
96- │ ├── hooks/ # Authentication hooks
97- │ ├── lib/ # External library integrations
98- │ │ └── lucia.ts # Lucia authentication setup
99- │ ├── middleware/ # Request middleware
100- │ ├── plugin-system/ # Plugin architecture
101- │ ├── plugins/ # Available plugins
102- │ ├── routes/ # API route definitions
103- │ │ ├── auth/ # Authentication routes
104- │ │ ├── db/ # Database management routes
105- │ │ ├── globalSettings/ # Settings management routes
106- │ │ ├── roles/ # Role management routes
107- │ │ └── users/ # User management routes
108- │ ├── services/ # Business logic services
109- │ │ ├── globalSettingsService.ts # Settings service
110- │ │ ├── roleService.ts # Role management
111- │ │ ├── teamService.ts # Team management
112- │ │ └── userService.ts # User management
113- │ ├── types/ # TypeScript type definitions
114- │ ├── utils/ # Utility functions
115- │ │ ├── banner.ts # Startup banner
116- │ │ └── encryption.ts # Encryption utilities
117- │ ├── server.ts # Server configuration
118- │ └── index.ts # Application entry point
119- ├── drizzle/ # Database migrations
120- ├── persistent_data/ # Persistent application data
121- ├── tests/ # Test files
122- ├── .env # Environment variables (not in version control)
123- ├── DB.md # Database documentation
124- ├── GLOBAL_SETTINGS.md # Global settings documentation
125- ├── Mail.md # Email system documentation (NEW)
126- ├── PLUGINS.md # Plugin system documentation
127- ├── ROLES.md # Role management documentation
128- ├── SECURITY.md # Security documentation
129- ├── package.json # Package dependencies and scripts
130- └── tsconfig.json # TypeScript configuration
97+ # API documentation
98+ npm run api:spec # Generate OpenAPI spec
13199```
132100
101+ ### Initial Setup
102+
103+ 1 . ** First Run** : Navigate to ` /setup ` in your browser
104+ 2 . ** Choose Database** : Select SQLite (default) or Turso
105+ 3 . ** Create Admin** : Set up your administrator account
106+ 4 . ** Configure Settings** : Access Global Settings to configure email, features, etc.
107+
133108## 💾 Persistent Data
134109
135- The ` services/backend/persistent_data/ ` directory is designated for storing all data that needs to persist across application restarts or deployments.
110+ All persistent data is stored in the ` persistent_data/ ` directory, which maintains the same structure across development and production environments.
111+
112+ ### Directory Structure
113+
114+ ```
115+ persistent_data/
116+ ├── database/
117+ │ └── deploystack.db # SQLite database (if using SQLite)
118+ └── db.selection.json # Database type configuration
119+ ```
120+
121+ ### Environment-Specific Locations
122+
123+ ** Development (Local):**
124+ - Location: ` services/backend/persistent_data/ `
125+ - Created automatically when running ` npm run dev `
126+ - Direct file system access
136127
137- ** Purpose:**
128+ ** Production (Docker):**
129+ - Location: ` /app/persistent_data/ ` (inside container)
130+ - Mounted as Docker volume: ` deploystack_backend_persistent `
131+ - Persists data between container restarts
138132
139- - To provide a single, consistent location for all persistent backend data.
140- - When developing backend features that require data persistence (e.g., database files, configuration files that should not be in version control but are generated/modified at runtime), use this directory exclusively.
133+ ### Backup Strategies
141134
142- ** Examples of data stored here:**
135+ ** Docker Volume Backup:**
136+ ``` bash
137+ # Create backup
138+ docker run --rm -v deploystack_backend_persistent:/data \
139+ -v $( pwd) :/backup alpine \
140+ tar czf /backup/deploystack-backup-$( date +%Y%m%d) .tar.gz /data
141+
142+ # Restore backup
143+ docker run --rm -v deploystack_backend_persistent:/data \
144+ -v $( pwd) :/backup alpine \
145+ tar xzf /backup/deploystack-backup-20250108.tar.gz -C /
146+ ```
143147
144- - SQLite database file (e.g., ` persistent_data/database/deploystack.db ` )
145- - Database selection configuration (e.g., ` persistent_data/db.selection.json ` )
148+ ** Local Development Backup:**
149+ ``` bash
150+ # Create backup
151+ tar czf deploystack-backup-$( date +%Y%m%d) .tar.gz \
152+ services/backend/persistent_data/
153+
154+ # Restore backup
155+ tar xzf deploystack-backup-20250108.tar.gz
156+ ```
146157
147- This ensures that persistent data is managed in a predictable way and is not scattered across the project .
158+ ** Important: ** Always backup the entire ` persistent_data/ ` directory/volume, not just the database file, as it contains critical configuration .
148159
149160## 📧 Email System
150161
@@ -192,6 +203,7 @@ NODE_ENV=development
192203PORT=3000
193204HOST=localhost
194205LOG_LEVEL=info
206+ DEPLOYSTACK_FRONTEND_URL=http://localhost:5173 # Frontend URL for CORS and redirects
195207DEPLOYSTACK_ENCRYPTION_SECRET=your-32-character-secret-key-here # Required for global settings encryption
196208```
197209
0 commit comments