Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Quick Start Guide - Step-by-step instructions | |
| """ | |
| QUICK_START = """ | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| β AI Scientific Co-Investigator - QUICK START β | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| π OPTION 1: Docker Compose (Recommended - 5 minutes) | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| 1. Prerequisites: | |
| β Install Docker: https://www.docker.com/products/docker-desktop | |
| β Install Docker Compose (included with Docker Desktop) | |
| 2. Setup: | |
| $ cp .env.example .env | |
| $ # Edit .env - add your API keys | |
| 3. Start services: | |
| $ chmod +x deploy.sh | |
| $ ./deploy.sh up | |
| β API: http://localhost:8000 | |
| β Docs: http://localhost:8000/docs | |
| β Qdrant: http://localhost:6333 | |
| β PostgreSQL: localhost:5432 | |
| 4. Verify health: | |
| $ curl http://localhost:8000/health/ready | |
| β Should return: {"ready": true, ...} | |
| 5. Stop: | |
| $ ./deploy.sh down | |
| π οΈ OPTION 2: Local Python Development | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| 1. Prerequisites: | |
| β Python 3.10+ | |
| β PostgreSQL 13+ | |
| β Redis | |
| β Qdrant | |
| 2. Setup environment: | |
| $ python -m venv .venv | |
| $ source .venv/bin/activate # or .venv\\Scripts\\activate on Windows | |
| 3. Install dependencies: | |
| $ pip install -r requirements.txt | |
| 4. Configure: | |
| $ cp .env.example .env | |
| $ # Edit .env with your local DB credentials | |
| 5. Start services (in separate terminals): | |
| Terminal 1 - PostgreSQL: | |
| $ psql -U user -d scoinvestigator | |
| Terminal 2 - Redis: | |
| $ redis-server | |
| Terminal 3 - Qdrant: | |
| $ docker run -p 6333:6333 qdrant/qdrant | |
| Terminal 4 - API: | |
| $ uvicorn app.main:app --reload | |
| β http://localhost:8000 | |
| π COMMON OPERATIONS | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| Health Check: | |
| $ curl http://localhost:8000/health/ready | |
| View API Docs: | |
| β Open browser: http://localhost:8000/docs | |
| View Logs: | |
| $ ./deploy.sh logs | |
| Run Tests: | |
| $ ./deploy.sh test | |
| Database: psql connection | |
| $ psql -U user -d scoinvestigator -h localhost | |
| Stop Everything: | |
| $ ./deploy.sh down | |
| π FIRST API CALL | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| Run an analysis: | |
| $ curl -X POST http://localhost:8000/api/v1/analysis/run \\ | |
| -H "Content-Type: application/json" \\ | |
| -d '{ | |
| "documents": ["Document text here..."], | |
| "analysis_type": "comprehensive" | |
| }' | |
| View results: | |
| $ curl http://localhost:8000/api/v1/analysis/{analysis_id}/results | |
| π DATABASE SETUP | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| Create database (first time): | |
| $ psql -U postgres | |
| postgres=# CREATE DATABASE scoinvestigator; | |
| postgres=# CREATE USER user WITH PASSWORD 'onion123'; | |
| postgres=# GRANT ALL PRIVILEGES ON DATABASE scoinvestigator TO user; | |
| Tables are created automatically by SQLAlchemy on first run. | |
| π TROUBLESHOOTING | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| Problem: Import errors | |
| Solution: pip install --upgrade -r requirements.txt | |
| Problem: Database connection failed | |
| Solution: Check DATABASE_URL in .env | |
| Check PostgreSQL is running | |
| psql -U user -d scoinvestigator | |
| Problem: Qdrant not responding | |
| Solution: docker run -p 6333:6333 qdrant/qdrant | |
| curl http://localhost:6333/health | |
| Problem: Ports already in use | |
| Solution: Check what's using the port: | |
| lsof -i :8000 # for API | |
| lsof -i :5432 # for DB | |
| Kill the process: kill -9 <PID> | |
| Or change ports in docker-compose.yml | |
| π STRUCTURE OVERVIEW | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| /app | |
| /api β API routes | |
| /db β Database models & sessions | |
| /services β Business logic | |
| /reasoning β AI orchestration (LangGraph) | |
| /rag β Document processing | |
| /modules β Analysis modules | |
| /core β Configuration & utilities | |
| main.py β FastAPI app | |
| π― NEXT STEPS | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| 1. Verify all services running: | |
| $ curl http://localhost:8000/health/ready | |
| 2. Try the API with sample data: | |
| β Visit http://localhost:8000/docs | |
| β Try POST /api/v1/analysis/run | |
| 3. Check logs for errors: | |
| $ ./deploy.sh logs | |
| 4. Monitor resources: | |
| $ docker stats | |
| 5. Setup frontend (separate project): | |
| β See FRONTEND_SCAFFOLD.md | |
| π NEED HELP? | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| 1. Read the docs: | |
| - README.md (project overview) | |
| - DEPLOYMENT.md (deployment guide) | |
| - STACK_ANALYSIS.md (tech stack details) | |
| - FRONTEND_SCAFFOLD.md (frontend setup) | |
| 2. Check logs: | |
| - Docker: docker-compose logs | |
| - API: ./deploy.sh logs | |
| - Database: psql logs | |
| 3. API Docs: | |
| - Swagger: http://localhost:8000/docs | |
| - ReDoc: http://localhost:8000/redoc | |
| 4. Health checks: | |
| - All services: http://localhost:8000/health/ready | |
| - API only: http://localhost:8000/health/ | |
| π¨βπ» DEVELOPMENT WORKFLOW | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| Edit code β Changes auto-reload (with --reload flag) | |
| Run tests β ./deploy.sh test | |
| View logs β ./deploy.sh logs | |
| Debug β Add print statements β Check logs | |
| π YOU'RE ALL SET! | |
| βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| Next: Start making requests to the API! | |
| Happy coding! π | |
| """ | |
| if __name__ == "__main__": | |
| print(QUICK_START) | |
| # Additional interactive help | |
| import sys | |
| print(\"\\n\" + \"=\"*80) | |
| print(\"INTERACTIVE QUICK START\") | |
| print(\"=\"*80) | |
| choice = input(\"\\nHow do you want to run the app?\\n1. Docker Compose (recommended)\\n2. Local Python\\n> \").strip() | |
| if choice == '1': | |
| print(\"\\n\" + \"=\"*80) | |
| print(\"DOCKER COMPOSE SETUP\") | |
| print(\"=\"*80) | |
| print(\"\\nSteps:\") | |
| print(\"1. cp .env.example .env\") | |
| print(\"2. Edit .env with your API keys\") | |
| print(\"3. chmod +x deploy.sh\") | |
| print(\"4. ./deploy.sh up\") | |
| print(\"\\nThen visit: http://localhost:8000/docs\") | |
| elif choice == '2': | |
| print(\"\\n\" + \"=\"*80) | |
| print(\"LOCAL PYTHON SETUP\") | |
| print(\"=\"*80) | |
| print(\"\\nSteps:\") | |
| print(\"1. python -m venv .venv\") | |
| print(\"2. source .venv/bin/activate\") | |
| print(\"3. pip install -r requirements.txt\") | |
| print(\"4. Start PostgreSQL, Redis, Qdrant\") | |
| print(\"5. uvicorn app.main:app --reload\") | |
| print(\"\\nThen visit: http://localhost:8000/docs\") | |
| print(\"\\n\" + \"=\"*80) | |
| print(\"Questions? Check: README.md | DEPLOYMENT.md | STACK_ANALYSIS.md\") | |
| print(\"=\"*80 + \"\\n\") | |