Skip to content

Commit f3c6400

Browse files
author
Developer
committed
Add getting started
1 parent 63fd3df commit f3c6400

File tree

1 file changed

+345
-0
lines changed

1 file changed

+345
-0
lines changed

β€ŽGETTING_STARTED.mdβ€Ž

Lines changed: 345 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,345 @@
1+
# πŸš€ Getting Started with StreamSource
2+
3+
This guide will help you set up and run StreamSource locally for development and testing.
4+
5+
## πŸ“‹ Prerequisites
6+
7+
- **Docker Desktop** - [Download here](https://www.docker.com/products/docker-desktop/)
8+
- **Git** - For cloning the repository
9+
- **Modern terminal** - Terminal.app, iTerm2, or similar
10+
11+
## πŸš€ Quick Start (Recommended)
12+
13+
### 1. Initial Setup
14+
15+
```bash
16+
# Navigate to the project directory
17+
cd /Users/sayhiben/dev/streamsource
18+
19+
# One-command setup (handles everything automatically)
20+
make setup
21+
```
22+
23+
This automated setup will:
24+
- βœ… Create `.env` file from template
25+
- βœ… Install Ruby gems and JavaScript dependencies
26+
- βœ… Start PostgreSQL database
27+
- βœ… Run database migrations
28+
- βœ… Seed the database with sample data
29+
30+
### 2. Start Development Environment
31+
32+
```bash
33+
# Start all services in development mode
34+
make dev
35+
```
36+
37+
This starts:
38+
- **Rails API & Admin Interface** on http://localhost:3000
39+
- **PostgreSQL database** container
40+
- **Redis cache/sessions** container
41+
- **Asset watchers** for live code reloading
42+
43+
## πŸ“± Access Points
44+
45+
Once running, you can access:
46+
47+
| Service | URL | Description |
48+
|---------|-----|-------------|
49+
| 🏠 **Main Application** | http://localhost:3000 | Root application |
50+
| πŸ‘¨β€πŸ’Ό **Admin Interface** | http://localhost:3000/admin | Management dashboard |
51+
| πŸ“š **API Documentation** | http://localhost:3000/api-docs | Interactive API docs (Swagger) |
52+
| πŸ₯ **Health Check** | http://localhost:3000/health | System status endpoint |
53+
| πŸŽ›οΈ **Feature Flags** | http://localhost:3000/admin/feature_flags | Feature toggle management |
54+
55+
## πŸ” Default Admin Access
56+
57+
The seeded database includes an admin user:
58+
- **Email**: `[email protected]`
59+
- **Password**: `Password123!`
60+
61+
> **Note**: Check `db/seeds.rb` for exact credentials if these don't work.
62+
63+
## πŸ”§ Alternative Startup Methods
64+
65+
### Background Mode
66+
```bash
67+
make up # Starts services in background
68+
make logs # View logs in follow mode
69+
make status # Check container status
70+
make down # Stop all services
71+
```
72+
73+
### Manual Setup (if automated setup fails)
74+
```bash
75+
# 1. Copy environment template
76+
cp .env.example .env
77+
78+
# 2. Edit configuration (optional for local testing)
79+
nano .env
80+
81+
# 3. Install dependencies
82+
make install
83+
84+
# 4. Start database only
85+
docker compose up -d db
86+
87+
# 5. Setup database
88+
make migrate
89+
make seed
90+
91+
# 6. Start everything
92+
make dev
93+
```
94+
95+
## πŸ§ͺ Testing Your Setup
96+
97+
### Run the Test Suite
98+
```bash
99+
# Full test suite with coverage
100+
make test
101+
102+
# Specific test types
103+
make test-models # Model tests only
104+
make test-requests # API/request tests only
105+
make test-features # Feature/system tests only
106+
make test-parallel # Faster parallel execution
107+
```
108+
109+
### System Health Checks
110+
```bash
111+
# Quick health check
112+
make health
113+
114+
# Comprehensive diagnostics
115+
make doctor
116+
117+
# Check configuration
118+
make env-check
119+
```
120+
121+
### API Testing
122+
```bash
123+
# Test health endpoint
124+
curl http://localhost:3000/health
125+
126+
# Test database connectivity
127+
curl http://localhost:3000/health/db
128+
129+
# Test Redis connectivity
130+
curl http://localhost:3000/health/redis
131+
132+
# Test API endpoints (may require authentication)
133+
curl http://localhost:3000/api/v1/streams
134+
```
135+
136+
## πŸ› οΈ Useful Development Commands
137+
138+
### Core Operations
139+
```bash
140+
make dev # Start in development mode
141+
make up # Start in background
142+
make down # Stop all services
143+
make restart # Restart all services
144+
make logs # Follow application logs
145+
make status # Show container status
146+
```
147+
148+
### Development Tools
149+
```bash
150+
make shell # Open bash shell in web container
151+
make rails # Open Rails console (alias: make c)
152+
make routes # Show all Rails routes
153+
make attach # Attach to container for debugging
154+
```
155+
156+
### Database Management
157+
```bash
158+
make migrate # Run pending migrations
159+
make rollback # Rollback last migration
160+
make seed # Seed database with sample data
161+
make reset # Reset database (⚠️ destroys data!)
162+
make db-shell # Open PostgreSQL shell
163+
make backup # Backup database and config
164+
```
165+
166+
### Code Quality
167+
```bash
168+
make lint # Comprehensive code analysis
169+
make lint-fix # Auto-fix code style issues
170+
make lint-ruby # Ruby style check only
171+
make lint-js # JavaScript style check only
172+
make security # Security audit and scanning
173+
make quality # Full quality check (lint + test)
174+
make pre-commit # Pre-commit validation
175+
```
176+
177+
### Dependencies & Assets
178+
```bash
179+
make install # Install all dependencies
180+
make update # Update all dependencies
181+
make bundle # Install Ruby gems
182+
make yarn # Install JavaScript packages
183+
make assets # Compile assets for production
184+
make assets-dev # Compile assets for development
185+
```
186+
187+
## 🚨 Troubleshooting
188+
189+
### Container Issues
190+
```bash
191+
# Diagnose common problems
192+
make doctor
193+
194+
# Clean up and rebuild
195+
make clean
196+
make rebuild
197+
198+
# Deep clean (removes everything)
199+
make clean-all
200+
```
201+
202+
### Database Problems
203+
```bash
204+
# Access database directly
205+
make db-shell
206+
207+
# Reset database (⚠️ destroys all data)
208+
make reset
209+
210+
# Check database connection
211+
make health
212+
```
213+
214+
### Performance Issues
215+
```bash
216+
# Check system resources
217+
make doctor
218+
219+
# View detailed logs
220+
make logs-all
221+
222+
# Check container status
223+
make ps-all
224+
```
225+
226+
### Common Error Messages
227+
228+
| Error | Solution |
229+
|-------|----------|
230+
| "Docker not found" | Install Docker Desktop and ensure it's running |
231+
| "Port 3000 already in use" | Stop other Rails apps or use `make down` |
232+
| "Database connection failed" | Run `make doctor` and check database container |
233+
| "Permission denied" | Check file permissions with `make security` |
234+
| "Bundle install failed" | Try `make clean` then `make rebuild` |
235+
236+
## πŸ”„ Development Workflow
237+
238+
### Typical Development Session
239+
1. **Start**: `make dev`
240+
2. **Make code changes** (auto-reloads)
241+
3. **Test changes**: `make test`
242+
4. **Check quality**: `make pre-commit`
243+
5. **Stop**: `Ctrl+C` or `make down`
244+
245+
### Before Committing Code
246+
```bash
247+
# Run comprehensive checks
248+
make pre-commit
249+
250+
# This runs:
251+
# - Full test suite
252+
# - Code style checks (Ruby & JavaScript)
253+
# - Security analysis
254+
# - Dependency audit
255+
```
256+
257+
### Adding New Features
258+
```bash
259+
# 1. Create database migration (if needed)
260+
make exec cmd="bin/rails generate migration AddFeatureToModel"
261+
262+
# 2. Run migration
263+
make migrate
264+
265+
# 3. Generate tests
266+
make exec cmd="bin/rails generate rspec:model Feature"
267+
268+
# 4. Run tests frequently
269+
make test-watch
270+
271+
# 5. Check code quality
272+
make quality
273+
```
274+
275+
## πŸ“Š Understanding the Application
276+
277+
### Architecture Overview
278+
- **Rails 8** - Modern Ruby on Rails framework
279+
- **PostgreSQL 17** - Primary database
280+
- **Redis 7** - Caching and session storage
281+
- **Hotwire/Stimulus** - Real-time frontend updates
282+
- **ActionCable** - WebSocket support for real-time features
283+
- **Docker** - Containerized development environment
284+
285+
### Key Features
286+
- **RESTful API** - Comprehensive API for streams, streamers, timestamps
287+
- **Admin Interface** - Real-time collaborative editing
288+
- **Feature Flags** - Flipper-based feature toggles
289+
- **Authentication** - JWT for API, sessions for admin
290+
- **Real-time Updates** - ActionCable WebSocket support
291+
- **Rate Limiting** - Rack::Attack protection
292+
293+
### Data Models
294+
- **User** - Authentication and authorization
295+
- **Streamer** - Content creators
296+
- **StreamerAccount** - Platform-specific accounts
297+
- **Stream** - Individual streaming sessions
298+
- **Timestamp** - Event annotations/incidents
299+
300+
## 🎯 Quick Shortcuts
301+
302+
For faster development, use these shortcut commands:
303+
304+
```bash
305+
make d # dev
306+
make u # up
307+
make l # logs
308+
make r # restart
309+
make s # status
310+
make t # test
311+
make c # rails (console)
312+
```
313+
314+
## πŸ“š Additional Resources
315+
316+
- **[DEPLOYMENT.md](DEPLOYMENT.md)** - Production deployment guide
317+
- **[API Documentation](http://localhost:3000/api-docs)** - Interactive API docs (when running)
318+
- **[LINTING.md](docs/LINTING.md)** - Code quality and linting guide
319+
- **Vendor Documentation** - See `vendor/docs/` for framework references
320+
321+
## πŸ†˜ Getting Help
322+
323+
If you encounter issues:
324+
325+
1. **Run diagnostics**: `make doctor`
326+
2. **Check logs**: `make logs`
327+
3. **Review health**: `make health`
328+
4. **Clean and rebuild**: `make clean && make rebuild`
329+
5. **Check documentation** in the `docs/` directory
330+
331+
## πŸŽ‰ You're Ready!
332+
333+
Once you have StreamSource running locally:
334+
335+
- βœ… **Admin Interface**: http://localhost:3000/admin
336+
- βœ… **API Documentation**: http://localhost:3000/api-docs
337+
- βœ… **Health Monitoring**: http://localhost:3000/health
338+
- βœ… **Real-time Features**: WebSocket support enabled
339+
- βœ… **Development Tools**: Rails console, logs, debugging
340+
341+
Happy coding! πŸš€
342+
343+
---
344+
345+
> **πŸ’‘ Pro Tip**: Use `make help` anytime to see all available commands with descriptions.

0 commit comments

Comments
Β (0)