Skip to content

Commit e61bb3a

Browse files
Move SQLite data to data/ directory, update README quick start
Default DB path is now data/codehive.db. Auto-creates data/ directory. Added data/ to .gitignore. README rewritten with SQLite-first quick start, optional PostgreSQL section, and terminal-only mode.
1 parent 7e9c951 commit e61bb3a

5 files changed

Lines changed: 47 additions & 15 deletions

File tree

README.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,66 @@ web/ React 19, Vite, TypeScript, Tailwind CSS
2626
mobile/ (planned)
2727
```
2828

29-
Infrastructure (PostgreSQL, Redis) is defined in `docker-compose.yml` at the repo root.
30-
3129
## Prerequisites
3230

33-
- Python 3.13+
31+
- Python 3.12+
3432
- Node.js 20+
35-
- Docker and Docker Compose
3633
- [uv](https://docs.astral.sh/uv/) (Python package manager)
3734
- Git
3835

39-
## Quick Start
36+
## Quick Start (SQLite — zero infrastructure)
37+
38+
No Docker, no PostgreSQL, no Redis needed. Just Python and Node.
4039

4140
```bash
4241
# 1. Clone and enter the repo
4342
git clone <repo-url> && cd codehive
4443

45-
# 2. Copy environment config
46-
cp .env.example .env
47-
# Edit .env with your values (see Environment Variables below)
44+
# 2. Set your API key
45+
echo "CODEHIVE_ANTHROPIC_API_KEY=your-key-here" > .env
46+
# Or for Z.ai:
47+
# echo "CODEHIVE_ANTHROPIC_API_KEY=your-zai-key" > .env
48+
# echo "CODEHIVE_ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic" >> .env
4849

49-
# 3. Start infrastructure (PostgreSQL + Redis)
50-
docker compose up -d
51-
52-
# 4. Install backend dependencies and start the API server
50+
# 3. Start the backend (uses SQLite by default)
5351
cd backend
5452
uv sync --dev
5553
uv run codehive serve
5654

57-
# 5. In another terminal, start the web dev server
55+
# 4. In another terminal, start the web dev server
5856
cd web
5957
npm install
6058
npm run dev
6159
```
6260

6361
The API server runs at `http://127.0.0.1:7433` and the web app at `http://localhost:5173`.
62+
Data is stored in `backend/data/codehive.db` (SQLite, auto-created on first run).
63+
64+
### Quick Start with PostgreSQL + Redis (optional)
65+
66+
For production or multi-process deployments:
67+
68+
```bash
69+
# Start infrastructure
70+
docker compose up -d
71+
72+
# Set database URL in .env
73+
echo "CODEHIVE_DATABASE_URL=postgresql+asyncpg://codehive:codehive@localhost:5432/codehive" >> .env
74+
echo "CODEHIVE_REDIS_URL=redis://localhost:6379/0" >> .env
75+
76+
# Start the backend
77+
cd backend && uv sync --dev && uv run codehive serve
78+
```
79+
80+
### Terminal-only mode (no web server needed)
81+
82+
```bash
83+
cd backend
84+
uv run codehive code # start agent in current directory
85+
uv run codehive code ~/myapp # start agent in a specific directory
86+
```
87+
88+
This launches a Textual TUI with streaming, markdown rendering, and tool approval prompts. If the backend is running, sessions are shared with the web UI. If not, it runs standalone with a local engine.
6489

6590
### Default Login
6691

backend/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
data/
12
*.db
23
*.db-shm
34
*.db-wal

backend/alembic.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ path_separator = os
8686
# database URL. This is consumed by the user-maintained env.py script only.
8787
# other means of configuring database URLs may be customized within the env.py
8888
# file.
89-
sqlalchemy.url = sqlite+aiosqlite:///codehive.db
89+
sqlalchemy.url = sqlite+aiosqlite:///data/codehive.db
9090

9191

9292
[post_write_hooks]

backend/codehive/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Settings(BaseSettings):
3636

3737
cors_origins: list[str] = ["http://localhost:5173"]
3838

39-
database_url: str = "sqlite+aiosqlite:///codehive.db"
39+
database_url: str = "sqlite+aiosqlite:///data/codehive.db"
4040
redis_url: str = ""
4141

4242
anthropic_api_key: str = ""

backend/codehive/db/session.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Async database session factory."""
22

3+
from pathlib import Path
4+
35
from sqlalchemy import event
46
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
57

@@ -21,6 +23,10 @@ def create_async_engine_from_settings(
2123
url = database_url or Settings().database_url
2224
if url.startswith("sqlite"):
2325
engine_kwargs.setdefault("connect_args", {"check_same_thread": False})
26+
# Auto-create parent directory for SQLite DB file
27+
db_path = url.split("///", 1)[-1] if "///" in url else None
28+
if db_path:
29+
Path(db_path).parent.mkdir(parents=True, exist_ok=True)
2430
engine = create_async_engine(url, **engine_kwargs)
2531
if url.startswith("sqlite"):
2632

0 commit comments

Comments
 (0)