|
1 | | -# DevBin – The Bin for all your Pasting needs |
| 1 | +# DevBin |
2 | 2 |
|
3 | | -A lightweight and modern pastebin service built with FastAPI (Python) for the backend and Svelte for the frontend. Share |
4 | | -code snippets, text, and more with ease. |
| 3 | +A lightweight pastebin service built with FastAPI and Svelte. |
5 | 4 |
|
6 | | -## Features |
7 | | - |
8 | | -- **Simple and Clean Interface** – Intuitive UI for quick paste creation and sharing |
9 | | -- **Syntax Highlighting** – Support for multiple programming languages |
10 | | -- **Paste Expiration** – Automatic cleanup of expired pastes |
11 | | -- **Rate Limiting** – Built-in protection with configurable limits and bypass tokens |
12 | | -- **Caching Layer** – LRU cache for improved performance |
13 | | -- **Legacy Paste Support** – Backward compatibility with older paste formats |
14 | | -- **Health Monitoring** – Built-in health check endpoint and storage monitoring |
15 | | -- **Docker Ready** – Easy deployment with Docker Compose |
16 | | -- **Configurable Storage** – Customizable file storage and size limits |
17 | | -- **Trusted Hosts** – IP-based access control |
18 | | - |
19 | | -## Tech Stack |
20 | | - |
21 | | -- **Backend**: FastAPI, SQLAlchemy, PostgreSQL, Alembic (migrations) |
22 | | -- **Frontend**: Svelte |
23 | | -- **Deployment**: Docker, Docker Compose |
24 | | -- **Caching**: LRU Memory Cache with configurable TTL |
25 | | - |
26 | | -## Requirements |
27 | | - |
28 | | -- Docker Engine |
29 | | -- Docker Compose (or `docker-compose` for older versions) |
30 | | - |
31 | | -## Installation |
32 | | - |
33 | | -> **Note**: Depending on your Docker version, you may need to use `docker-compose` instead of `docker compose` |
34 | | -
|
35 | | -### Quick Start |
36 | | - |
37 | | -DevBin can be deployed in two ways: |
38 | | - |
39 | | -#### Option 1: Development Setup |
40 | | - |
41 | | -1. **Clone the repository** |
42 | | - ```bash |
43 | | - git clone <repository-url> |
44 | | - cd DevBin |
45 | | - ``` |
46 | | - |
47 | | -2. **Configure environment variables** |
48 | | - ```bash |
49 | | - cp .env.example .env |
50 | | - ``` |
51 | | - Edit `.env` and update the values according to your needs. Key configurations include: |
52 | | - - Database credentials |
53 | | - - API port and host |
54 | | - - Rate limiting settings |
55 | | - - CORS domains |
56 | | - - Storage paths and limits |
57 | | - - Trusted hosts |
58 | | - |
59 | | -3. **Start the services** |
60 | | - ```bash |
61 | | - docker compose up -d |
62 | | - ``` |
63 | | - |
64 | | -4. **Run database migrations** |
65 | | - ```bash |
66 | | - docker compose run --rm app uv run alembic upgrade head |
67 | | - ``` |
68 | | - |
69 | | -5. **Access the application** |
70 | | - - Frontend: http://localhost:3000 |
71 | | - - API Documentation (Swagger): http://localhost:8000/docs |
72 | | - - Health Check: http://localhost:8000/health |
73 | | - |
74 | | -#### Option 2: Production Setup |
75 | | - |
76 | | -For production deployment, you only need the production compose file and environment configuration: |
77 | | - |
78 | | -1. **Clone the repository** |
79 | | - ```bash |
80 | | - git clone <repository-url> |
81 | | - cd DevBin |
82 | | - ``` |
83 | | - |
84 | | -2. **Configure environment variables** |
85 | | - ```bash |
86 | | - cp .env.example .env |
87 | | - ``` |
88 | | - Edit `.env` with production-ready values (strong passwords, proper domains, etc.) |
89 | | - |
90 | | -3. **Start the services** |
91 | | - ```bash |
92 | | - docker compose -f docker-compose.prod.yml up -d |
93 | | - ``` |
94 | | - |
95 | | -4. **Run database migrations** |
96 | | - ```bash |
97 | | - docker compose -f docker-compose.prod.yml run --rm app uv run alembic upgrade head |
98 | | - ``` |
99 | | - |
100 | | -### Stopping the Service |
101 | | - |
102 | | -Development: |
| 5 | +## Quick Start |
103 | 6 |
|
104 | 7 | ```bash |
105 | | -docker compose down |
| 8 | +git clone <repository-url> |
| 9 | +cd DevBin |
| 10 | +cp .env.example .env # Configure as needed |
| 11 | +task dev:up # Start all services |
| 12 | +task db:migrate # Run migrations |
106 | 13 | ``` |
107 | 14 |
|
108 | | -Production: |
109 | | - |
110 | | -```bash |
111 | | -docker compose -f docker-compose.prod.yml down |
112 | | -``` |
113 | | - |
114 | | -## Configuration |
115 | | - |
116 | | -Key environment variables in `.env`: |
117 | | - |
118 | | -| Variable | Description | Default | |
119 | | -|--------------------------|-----------------------------------------|---------------------------| |
120 | | -| `APP_PORT` | Backend API port | 8000 | |
121 | | -| `APP_MAX_CONTENT_LENGTH` | Maximum paste size | 10000 | |
122 | | -| `APP_WORKERS` | Number of worker processes | 1 | |
123 | | -| `APP_BYPASS_TOKEN` | Token to bypass rate limits | - | |
124 | | -| `APP_CACHE_TTL` | Cache time-to-live (seconds) | 300 | |
125 | | -| `APP_MIN_STORAGE_MB` | Minimum required storage (MB) | 1024 | |
126 | | -| `TRUSTED_HOSTS` | Array of trusted IP addresses/hostnames | ["127.0.0.1"] | |
127 | | -| `APP_CORS_DOMAINS` | Allowed CORS origins | ["http://localhost:3000"] | |
128 | | - |
129 | | -See `.env.example` for a complete list of configuration options. |
| 15 | +**Access:** |
| 16 | +- Frontend: http://localhost:3000 |
| 17 | +- API Docs: http://localhost:8000/docs |
| 18 | +- Health: http://localhost:8000/health |
130 | 19 |
|
131 | | -## Development |
| 20 | +## Commands |
132 | 21 |
|
133 | | -### Running in Development Mode |
| 22 | +Run `task --list` for all available commands. |
134 | 23 |
|
135 | | -Set these variables in `.env`: |
| 24 | +| Command | Description | |
| 25 | +|---------|-------------| |
| 26 | +| `task dev:up` | Start all dev services | |
| 27 | +| `task dev:down` | Stop all dev services | |
| 28 | +| `task dev:logs` | Tail logs | |
| 29 | +| `task dev:reset` | Reset with fresh volumes | |
| 30 | +| `task db:migrate` | Run migrations | |
| 31 | +| `task db:shell` | PostgreSQL shell | |
| 32 | +| `task test` | Run all tests | |
| 33 | +| `task prod:up` | Start production | |
| 34 | +| `task prod:down` | Stop production | |
| 35 | +| `task clean` | Remove containers and volumes | |
136 | 36 |
|
137 | | -```env |
138 | | -APP_DEBUG=true |
139 | | -APP_RELOAD=true |
140 | | -APP_SQLALCHEMY_ECHO=true |
141 | | -``` |
142 | | - |
143 | | -### Tests |
144 | | - |
145 | | -### Backend Tests |
146 | | - |
147 | | -Run tests with: |
148 | | - |
149 | | -```bash |
150 | | -cd backend |
151 | | -uv run pytest |
152 | | -``` |
| 37 | +## Configuration |
153 | 38 |
|
154 | | -> If you modified any of the core API endpoints, make sure to run the tests to ensure they still work as expected. Or if |
155 | | -> you are committing breaking changes, please adjust them and add a note why this breaking change is necessary. |
| 39 | +See [`.env.example`](.env.example) for all options. Key settings: |
156 | 40 |
|
157 | | -See [Testing](/backend/TESTING.md) |
| 41 | +| Variable | Description | |
| 42 | +|----------|-------------| |
| 43 | +| `APP_PORT` | API port (default: 8000) | |
| 44 | +| `APP_MAX_CONTENT_LENGTH` | Max paste size | |
| 45 | +| `APP_STORAGE_TYPE` | `local`, `s3`, or `minio` | |
| 46 | +| `APP_CACHE_TYPE` | `memory` or `redis` | |
158 | 47 |
|
159 | | -### API Endpoints |
| 48 | +Full reference: [`docs/configuration.md`](docs/configuration.md) |
160 | 49 |
|
161 | | -- `GET /health` – Health check |
162 | | -- `GET /pastes/{paste_id}` – Retrieve a paste |
163 | | -- `GET /pastes/legacy/{paste_id}` – Retrieve a legacy paste |
164 | | -- `POST /pastes` – Create a new paste |
| 50 | +## API |
165 | 51 |
|
166 | | -Full API documentation available at `/docs` when running. |
| 52 | +| Endpoint | Description | |
| 53 | +|----------|-------------| |
| 54 | +| `GET /health` | Health check | |
| 55 | +| `GET /metrics` | Prometheus metrics | |
| 56 | +| `POST /pastes` | Create paste | |
| 57 | +| `GET /pastes/{id}` | Get paste | |
| 58 | +| `DELETE /pastes/{id}` | Delete paste | |
167 | 59 |
|
168 | | -## Production Deployment |
| 60 | +Interactive docs at `/docs` when running. |
169 | 61 |
|
170 | | -See **[Option 2: Production Setup](#option-2-production-setup)** in the Quick Start section above for deployment |
171 | | -instructions. |
| 62 | +## Documentation |
172 | 63 |
|
173 | | -### Production Checklist |
| 64 | +- [Configuration Reference](docs/configuration.md) |
| 65 | +- [Production Deployment](docs/deployment.md) |
| 66 | +- [Testing Guide](backend/TESTING.md) |
174 | 67 |
|
175 | | -Make sure to configure the following in your `.env` file: |
| 68 | +## Tech Stack |
176 | 69 |
|
177 | | -- ✅ Set strong database credentials (`POSTGRES_USER`, `POSTGRES_PASSWORD`) |
178 | | -- ✅ Configure appropriate rate limits |
179 | | -- ✅ Set `APP_DEBUG=false` and `APP_RELOAD=false` |
180 | | -- ✅ Configure trusted hosts properly (`TRUSTED_HOSTS`) |
181 | | -- ✅ Set up proper CORS domains (`APP_CORS_DOMAINS`) |
182 | | -- ✅ Use a secure bypass token (`APP_BYPASS_TOKEN`) |
183 | | -- ✅ Configure minimum storage requirements (`APP_MIN_STORAGE_MB`) |
184 | | -- ✅ Set appropriate worker count (`APP_WORKERS`) |
| 70 | +- **Backend**: FastAPI, SQLAlchemy, PostgreSQL |
| 71 | +- **Frontend**: Svelte |
| 72 | +- **Deployment**: Docker Compose |
0 commit comments