File size: 3,359 Bytes
74de430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# SwiftOps Backend - Quick Start Guide

Get up and running in 5 minutes!

## πŸš€ Quick Setup

### 1. Install Dependencies

```bash
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install packages
pip install -r requirements-dev.txt
```

### 2. Configure Environment

```bash
# Copy environment template
cp .env.example .env

# Edit .env and add your credentials:
# - DATABASE_URL (Supabase PostgreSQL URL)
# - SUPABASE_URL
# - SUPABASE_KEY
# - SECRET_KEY (generate with: openssl rand -hex 32)
```

### 3. Start Services

```bash
# Option A: Use Docker (Recommended)
docker-compose up -d

# Option B: Local PostgreSQL and Redis
# Make sure PostgreSQL and Redis are running locally
```

### 4. Initialize Database

```bash
# Create initial migration
alembic revision --autogenerate -m "Initial schema"

# Apply migrations
alembic upgrade head

# (Optional) Seed database with test data
python scripts/seed_database.py
```

### 5. Run the Application

```bash
# Start development server
uvicorn src.app.main:app --reload

# Server will start at http://localhost:8000
# API docs at http://localhost:8000/api/docs
```

## βœ… Verify Installation

Visit these URLs to confirm everything works:

- **API Root**: http://localhost:8000
- **Health Check**: http://localhost:8000/health
- **API Documentation**: http://localhost:8000/api/docs
- **ReDoc**: http://localhost:8000/api/redoc

## πŸ§ͺ Run Tests

```bash
# Run all tests
pytest

# Run with coverage
pytest --cov=src/app

# Run specific test
pytest tests/unit/services/test_auth_service.py
```

## πŸ”§ Development Tools

```bash
# Format code
black src/ tests/

# Sort imports
isort src/ tests/

# Lint code
flake8 src/ tests/

# Type checking
mypy src/
```

## πŸ“¦ Docker Commands

```bash
# Start all services
docker-compose up -d

# View logs
docker-compose logs -f api

# Stop services
docker-compose down

# Rebuild after code changes
docker-compose up -d --build
```

## 🎯 Next Steps

1. **Read the Build Plan**: `docs/agent/COMPREHENSIVE_BUILD_PLAN.md`
2. **Check Project Status**: `PROJECT_STATUS.md`
3. **Start with Phase 1**: Implement core models
4. **Follow the checklist**: Week-by-week implementation

## πŸ†˜ Troubleshooting

### Database Connection Error
```bash
# Check if PostgreSQL is running
docker-compose ps

# Check DATABASE_URL in .env
# Format: postgresql://user:password@host:port/database
```

### Import Errors
```bash
# Make sure you're in the virtual environment
source venv/bin/activate

# Reinstall dependencies
pip install -r requirements-dev.txt
```

### Alembic Migration Issues
```bash
# Reset migrations (CAUTION: Deletes all data)
alembic downgrade base
alembic upgrade head

# Or drop and recreate database
docker-compose down -v
docker-compose up -d
```

## πŸ“š Useful Commands

```bash
# Create new migration
alembic revision --autogenerate -m "Add new table"

# Apply migrations
alembic upgrade head

# Rollback one migration
alembic downgrade -1

# Start Celery worker
celery -A src.app.tasks.celery_app worker --loglevel=info

# Start Celery beat
celery -A src.app.tasks.celery_app beat --loglevel=info

# Monitor Celery with Flower
celery -A src.app.tasks.celery_app flower
```

## πŸŽ‰ You're Ready!

The project is fully scaffolded and ready for development. Start building! πŸš€