86 lines
2.6 KiB
Markdown
86 lines
2.6 KiB
Markdown
# Silos Backend
|
|
|
|
FastAPI backend with PostgreSQL/SQLite (users/auth) and MongoDB (workspace documents).
|
|
|
|
## Setup
|
|
|
|
### 1. Start databases
|
|
|
|
From the project root:
|
|
|
|
```bash
|
|
docker compose up mongo -d
|
|
```
|
|
|
|
Optional (PostgreSQL instead of SQLite):
|
|
|
|
```bash
|
|
docker compose up mongo postgres -d
|
|
```
|
|
|
|
Then confirm the API: `GET http://localhost:8000/api/v1/health` should report `"mongodb": "connected"`.
|
|
|
|
MongoDB is required for Silo pages, Sketch whiteboards, Stead spaces, and Shed docs.
|
|
SQLite is the default for user authentication (`DATABASE_URL` in `.env`).
|
|
|
|
### 2. Configure environment
|
|
|
|
```bash
|
|
cd backend
|
|
copy .env.example .env
|
|
```
|
|
|
|
### 3. Create virtual environment & install dependencies
|
|
|
|
```bash
|
|
python -m venv venv
|
|
venv\Scripts\activate
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
### 4. Run the API
|
|
|
|
```bash
|
|
uvicorn app.main:app --reload --port 8000
|
|
```
|
|
|
|
API docs: [http://localhost:8000/docs](http://localhost:8000/docs)
|
|
|
|
## API Endpoints
|
|
|
|
| Method | Endpoint | Description |
|
|
|--------|----------|-------------|
|
|
| GET | `/api/v1/health` | Health check |
|
|
| POST | `/api/v1/auth/register` | Create new user |
|
|
| POST | `/api/v1/auth/login` | Login & get JWT tokens |
|
|
| GET | `/api/v1/auth/me` | Get current user (requires auth) |
|
|
| PATCH | `/api/v1/auth/me` | Update user profile |
|
|
| POST | `/api/v1/auth/forgot-password` | Request password reset |
|
|
| POST | `/api/v1/auth/reset-password` | Reset password with token |
|
|
| GET | `/api/v1/documents` | List documents (optional `?type=` or `?stead_id=`) |
|
|
| GET | `/api/v1/documents/search?q=` | Search documents by title, type, author, body |
|
|
| GET | `/api/v1/documents/{id}` | Get a document |
|
|
| POST | `/api/v1/documents` | Create a document |
|
|
| PATCH | `/api/v1/documents/{id}` | Update title/content |
|
|
| POST | `/api/v1/documents/{id}/share` | Invite a user by email/username |
|
|
| DELETE | `/api/v1/documents/{id}/share/{user_id}` | Remove a member |
|
|
| DELETE | `/api/v1/documents/{id}` | Delete a document |
|
|
| WS | `/api/v1/ws/collab/{id}` | Live collab for Shed meeting notes |
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
backend/
|
|
├── app/
|
|
│ ├── main.py # FastAPI app entry
|
|
│ ├── config.py # Settings from .env
|
|
│ ├── database.py # PostgreSQL (SQLAlchemy)
|
|
│ ├── mongo.py # MongoDB connection
|
|
│ ├── models/ # SQLAlchemy models
|
|
│ ├── schemas/ # Pydantic schemas
|
|
│ ├── routers/ # API routes
|
|
│ ├── services/ # Business logic
|
|
│ └── utils/ # Security helpers
|
|
├── requirements.txt
|
|
└── .env.example
|
|
```
|