Skip to content

Commit c18b2e8

Browse files
committed
Add API documentation for user authentication, document management, and error responses; enhance landing page with document support information; update version in base template; create results documentation for version 1.0
1 parent 7953ce0 commit c18b2e8

File tree

4 files changed

+334
-4
lines changed

4 files changed

+334
-4
lines changed

document_analysis/app_documentation.md

Lines changed: 206 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,235 @@
11
# Deployment Guide
22

3+
## API Documentation
4+
5+
### Authentication
6+
7+
### Register a new user
8+
9+
```http
10+
POST /auth/register
11+
Content-Type: application/x-www-form-urlencoded
12+
13+
username=example&password=secure_password
14+
```
15+
16+
**Response**: 302 Redirect to login page
17+
18+
### Login
19+
20+
```http
21+
POST /auth/login
22+
Content-Type: application/x-www-form-urlencoded
23+
24+
username=example&password=secure_password
25+
```
26+
27+
**Response**: 302 Redirect to dashboard
28+
29+
### Document Management
30+
31+
### Upload Document
32+
33+
```http
34+
POST /upload
35+
Content-Type: multipart/form-data
36+
37+
file: <document_file>
38+
```
39+
40+
**Response**:
41+
42+
```json
43+
{
44+
"message": "File successfully processed",
45+
"text": "extracted text content",
46+
"document_id": 123
47+
}
48+
```
49+
50+
### Generate Quiz
51+
52+
```http
53+
POST /generate_quiz
54+
Content-Type: application/json
55+
56+
{
57+
"text": "document content",
58+
"document_id": 123
59+
}
60+
```
61+
62+
**Response**:
63+
64+
```json
65+
{
66+
"quiz": {
67+
"multiple_choice": [...],
68+
"fill_in_blank": [...],
69+
"true_false": [...]
70+
}
71+
}
72+
```
73+
74+
### Generate Summary
75+
76+
```http
77+
POST /summarize
78+
Content-Type: application/json
79+
80+
{
81+
"text": "document content",
82+
"length": "medium",
83+
"document_id": 123
84+
}
85+
```
86+
87+
**Response**:
88+
89+
```json
90+
{
91+
"summary": "Generated summary content"
92+
}
93+
```
94+
95+
### Extract Keywords
96+
97+
```http
98+
POST /extract_keywords
99+
Content-Type: application/json
100+
101+
{
102+
"text": "document content",
103+
"document_id": 123
104+
}
105+
```
106+
107+
**Response**:
108+
109+
```json
110+
{
111+
"keywords": ["keyword1", "keyword2", ...]
112+
}
113+
```
114+
115+
### Translate Document
116+
117+
```http
118+
POST /translate
119+
Content-Type: application/json
120+
121+
{
122+
"text": "document content",
123+
"target_language": "Spanish",
124+
"document_id": 123
125+
}
126+
```
127+
128+
**Response**:
129+
130+
```json
131+
{
132+
"translation": "Translated content"
133+
}
134+
```
135+
136+
### Error Responses
137+
138+
### 400 Bad Request
139+
140+
```json
141+
{
142+
"error": "Error message describing the problem"
143+
}
144+
```
145+
146+
### 401 Unauthorized
147+
148+
```json
149+
{
150+
"error": "Login required"
151+
}
152+
```
153+
154+
### 404 Not Found
155+
156+
```json
157+
{
158+
"error": "Requested resource not found"
159+
}
160+
```
161+
162+
### 500 Internal Server Error
163+
164+
```json
165+
{
166+
"error": "Internal server error"
167+
}
168+
```
169+
170+
### Authentication
171+
172+
All endpoints except registration and login require authentication. Include session cookie received after login.
173+
174+
### Testing the API (COMMING SOON...)
175+
176+
Example using curl:
177+
178+
```bash
179+
# Upload document
180+
curl -X POST -F "[email protected]" http://localhost:5000/upload
181+
182+
# Generate quiz
183+
curl -X POST \
184+
-H "Content-Type: application/json" \
185+
-d '{"text":"content", "document_id":123}' \
186+
http://localhost:5000/generate_quiz
187+
```
188+
189+
## Development Notes
190+
191+
1. API version: v1
192+
2. Base URL: `http://localhost:5000` (development)
193+
3194
## Local Development Setup
4195

5196
1. Clone the repository:
197+
6198
```bash
7199
git clone <repository-url>
8200
cd document-analysis
9201
```
10202

11203
2. Create and activate virtual environment:
204+
12205
```bash
13206
python -m venv venv
14207
source venv/bin/activate # On Windows: venv\Scripts\activate
15208
```
16209

17210
3. Install dependencies:
211+
18212
```bash
19213
pip install -r requirements.txt
20214
```
21215

22216
4. Set up environment variables:
23-
Create a `.env` file with the following contents:
217+
Create a `.env` file with the following contents:
218+
24219
```
25220
FLASK_APP=document_analysis
26221
FLASK_ENV=development
27222
GEMINI_API_KEY=your_api_key_here
28223
```
29224

30225
5. Initialize database:
226+
31227
```bash
32228
flask init-db
33229
```
34230

35231
6. Run development server:
232+
36233
```bash
37234
flask run
38235
```
@@ -42,11 +239,13 @@ flask run
42239
### Using Gunicorn and Nginx
43240

44241
1. Install production dependencies:
242+
45243
```bash
46244
pip install gunicorn
47245
```
48246

49247
2. Create systemd service file `/etc/systemd/system/document-analysis.service`:
248+
50249
```ini
51250
[Unit]
52251
Description=Document Analysis Flask App
@@ -66,6 +265,7 @@ WantedBy=multi-user.target
66265
```
67266

68267
3. Configure Nginx `/etc/nginx/sites-available/document-analysis`:
268+
69269
```nginx
70270
server {
71271
listen 80;
@@ -84,7 +284,7 @@ server {
84284
```
85285

86286
4. Enable and start services:
87-
287+
88288
```bash
89289
sudo systemctl enable document-analysis
90290
sudo systemctl start document-analysis
@@ -95,6 +295,7 @@ sudo systemctl restart nginx
95295
### Docker Deployment
96296

97297
Create `Dockerfile`:
298+
98299
```dockerfile
99300
FROM python:3.9-slim
100301

@@ -115,6 +316,7 @@ CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "document_analysis:create_app(
115316
```
116317

117318
Create `docker-compose.yml`:
319+
118320
```yaml
119321
version: '3'
120322
services:
@@ -129,6 +331,7 @@ services:
129331
```
130332
131333
Deploy with Docker:
334+
132335
```bash
133336
docker-compose up -d
134-
```
337+
```

document_analysis/document_analysis/templates/analysis/landing.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ <h3 class="text-xl font-semibold mb-2">Translation</h3>
9595
<h3 class="text-xl font-semibold mb-2">Keyword Analysis</h3>
9696
<p class="text-gray-600">Extract keywords and phrases from your documents</p>
9797
</div>
98+
<!-- document support PDF, TXT DOCX -->
99+
<div class="bg-white p-6 rounded-xl shadow-lg hover:shadow-xl transition">
100+
<div class="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mb-4">
101+
<svg class="w-6 h-6 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
102+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
103+
</svg>
104+
</div>
105+
<h3 class="text-xl font-semibold mb-2">Document Support</h3>
106+
<p class="text-gray-600">Supports PDF, TXT, DOCX file formats</p>
107+
</div>
98108
</div>
99109
</div>
100110
</div>

document_analysis/document_analysis/templates/base.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
<div class="flex-shrink-0">
1818
<a href="{{ url_for('index') }}" class="text-white font-bold text-xl">
1919
Document Analysis
20-
<span class="text-sm text-purple-200">Version Beta</span>
20+
<span class="text-sm text-purple-200">
21+
Version 1.2.0
22+
</span>
2123
</a>
2224
</div>
2325
<div class="hidden md:block">

0 commit comments

Comments
 (0)