Skip to content

Commit 9e889b0

Browse files
committed
Versión inicial: Cortex Knowledge Assistant v0.1.0-beta
Sistema RAG empresarial con seguridad de nivel bancario para asistentes de conocimiento corporativo. Características: - API REST completa con FastAPI y autenticación JWT - Motor RAG con Qdrant + embeddings locales (sin APIs externas) - Detección y sanitización de PII (compatible GDPR/LGPD) - Streaming SSE para respuestas en tiempo real - Multi-tenancy con aislamiento por client_id - Rate limiting configurable por rol - Métricas Prometheus y health checks - CI/CD con GitHub Actions (lint, test, seguridad, docker) - 53 tests unitarios e integración (~85% cobertura) - Documentación completa en español Stack: Python 3.11, FastAPI, Qdrant, Redis, PostgreSQL, Docker Licencia: AGPL-3.0 (open source) / Comercial
0 parents  commit 9e889b0

File tree

160 files changed

+42437
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+42437
-0
lines changed

.dockerignore

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Cortex Docker Ignore
2+
# Optimizes build context for faster Docker builds
3+
4+
# ===================
5+
# Version Control
6+
# ===================
7+
.git
8+
.gitignore
9+
.gitattributes
10+
11+
# ===================
12+
# IDE & Editor
13+
# ===================
14+
.idea/
15+
.vscode/
16+
*.swp
17+
*.swo
18+
*~
19+
.DS_Store
20+
21+
# ===================
22+
# Python
23+
# ===================
24+
__pycache__/
25+
*.py[cod]
26+
*$py.class
27+
*.so
28+
.Python
29+
build/
30+
develop-eggs/
31+
dist/
32+
downloads/
33+
eggs/
34+
.eggs/
35+
lib/
36+
lib64/
37+
parts/
38+
sdist/
39+
var/
40+
wheels/
41+
*.egg-info/
42+
.installed.cfg
43+
*.egg
44+
MANIFEST
45+
46+
# Virtual environments
47+
.venv/
48+
venv/
49+
ENV/
50+
env/
51+
.env.local
52+
.env.*.local
53+
54+
# Type checking
55+
.mypy_cache/
56+
.dmypy.json
57+
dmypy.json
58+
.pytype/
59+
60+
# Testing
61+
.pytest_cache/
62+
.coverage
63+
coverage.xml
64+
htmlcov/
65+
.tox/
66+
.nox/
67+
.hypothesis/
68+
69+
# ===================
70+
# Documentation
71+
# ===================
72+
docs/_build/
73+
*.md
74+
!README.md
75+
76+
# ===================
77+
# Node.js (UI)
78+
# ===================
79+
ui/node_modules/
80+
ui/.next/
81+
ui/out/
82+
ui/coverage/
83+
ui/.npm
84+
ui/*.log
85+
86+
# ===================
87+
# Project Specific
88+
# ===================
89+
# Analysis and temp files
90+
analisis_cortex/
91+
*.log
92+
*.tmp
93+
*.temp
94+
95+
# Local data (use volumes instead)
96+
data/
97+
*.db
98+
*.sqlite3
99+
!tests/fixtures/*.db
100+
101+
# Qdrant storage (use volumes)
102+
qdrant_storage/
103+
storage/
104+
105+
# ===================
106+
# CI/CD
107+
# ===================
108+
.github/
109+
.circleci/
110+
.travis.yml
111+
Jenkinsfile
112+
azure-pipelines.yml
113+
114+
# ===================
115+
# Development
116+
# ===================
117+
Makefile
118+
docker-compose*.yml
119+
!docker-compose.yml
120+
*.sh
121+
scripts/
122+
tests/
123+
k8s/
124+
docker/
125+
126+
# ===================
127+
# Misc
128+
# ===================
129+
*.tar
130+
*.tar.gz
131+
*.zip
132+
Thumbs.db
133+
134+
# ===================
135+
# Secrets (NEVER include)
136+
# ===================
137+
.env
138+
.env.*
139+
!.env.example
140+
secrets/
141+
*.pem
142+
*.key
143+
*.crt
144+
backups/

.env.example

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# ═══════════════════════════════════════════════════════════════════
2+
# Cortex Knowledge Assistant - Environment Variables Template
3+
# ═══════════════════════════════════════════════════════════════════
4+
# Copy this file to .env and fill in your values:
5+
# cp .env.example .env
6+
# ═══════════════════════════════════════════════════════════════════
7+
8+
# ─── LLM Provider ─────────────────────────────────────────────────
9+
# Options: HF (HuggingFace), Fake (for testing)
10+
CKA_LLM_PROVIDER=HF
11+
12+
# HuggingFace API Key (get yours at https://huggingface.co/settings/tokens)
13+
HF_API_KEY=your_huggingface_api_key_here
14+
15+
# HuggingFace Model (recommended: meta-llama/Llama-3.1-8B-Instruct)
16+
CKA_HF_MODEL=meta-llama/Llama-3.1-8B-Instruct
17+
18+
# ─── Embeddings ───────────────────────────────────────────────────
19+
CKA_EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
20+
21+
# ─── Qdrant Vector Database ───────────────────────────────────────
22+
CKA_USE_QDRANT=true
23+
CKA_QDRANT_URL=http://localhost:6333
24+
CKA_QDRANT_COLLECTION_DOCS=corporate_docs
25+
CKA_QDRANT_TOP_K=5
26+
27+
# ─── PostgreSQL Database ──────────────────────────────────────────
28+
# Used for authentication, user management, and audit logs
29+
# IMPORTANT: Change the password in production!
30+
POSTGRES_USER=cortex
31+
POSTGRES_PASSWORD=change-this-password-in-production
32+
POSTGRES_DB=cortex
33+
# DATABASE_URL is auto-configured in docker-compose.yml
34+
35+
# ─── JWT Authentication ───────────────────────────────────────────
36+
# IMPORTANT: Change this secret in production!
37+
CKA_JWT_SECRET=change-this-secret-in-production
38+
CKA_JWT_ISS=cortex-ka
39+
CKA_JWT_AUD=cortex-client
40+
41+
# ─── CORS (Frontend URLs) ─────────────────────────────────────────
42+
CKA_CORS_ORIGINS=http://localhost:3000,http://localhost:5173
43+
44+
# ─── Features ─────────────────────────────────────────────────────
45+
CKA_ENABLE_STREAMING=true
46+
CKA_DLP_ENABLED=true
47+
48+
# ─── Rate Limiting ────────────────────────────────────────────────
49+
CKA_RATE_LIMIT_QPM=120
50+
CKA_RATE_LIMIT_BURST=0
51+
CKA_RATE_LIMIT_WINDOW_SECONDS=60
52+
53+
# ─── Token Budgets ────────────────────────────────────────────────
54+
CKA_MAX_INPUT_TOKENS=2048
55+
CKA_MAX_OUTPUT_TOKENS=256
56+
CKA_CONVERSATION_MAX_TURNS=5
57+
58+
# ─── Logging ──────────────────────────────────────────────────────
59+
CKA_LOG_LEVEL=INFO
60+
61+
# ─── Redis (Optional) ─────────────────────────────────────────────
62+
CKA_USE_REDIS=false
63+
CKA_REDIS_HOST=localhost
64+
CKA_REDIS_PORT=6379
65+
66+
# ─── Security Headers ─────────────────────────────────────────────
67+
CKA_HTTPS_ENABLED=false

.flake8

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[flake8]
2+
max-line-length = 120
3+
extend-ignore = E203, E501, E704, E731, W503, C901
4+
max-complexity = 25
5+
exclude =
6+
.git,
7+
__pycache__,
8+
.venv,
9+
build,
10+
dist,
11+
*.egg-info
12+
per-file-ignores =
13+
# Re-exports in __init__.py
14+
**/__init__.py: F401
15+
# FastAPI endpoint discovery imports
16+
src/cortex_ka/api/main.py: F401, F811, F841
17+
# Application layer - some imports for type hints or future use
18+
src/cortex_ka/application/*.py: F401
19+
# Demo/seed files - unused vars acceptable in data generation
20+
src/cortex_ka/demos/*.py: F401, F841
21+
# System utilities
22+
src/cortex_ka/system/*.py: F401
23+
# Infrastructure - complex retrieval logic
24+
src/cortex_ka/infrastructure/*.py: F401
25+
# Scripts
26+
src/cortex_ka/scripts/*.py: F401

.github/CODEOWNERS

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# ══════════════════════════════════════════════════════════════════════════════
2+
# Cortex Knowledge Assistant - Code Owners
3+
# ══════════════════════════════════════════════════════════════════════════════
4+
# This file defines who is responsible for code review in different areas.
5+
# When a PR modifies files matching a pattern, the listed owners are
6+
# automatically requested for review.
7+
#
8+
# Docs: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
9+
# ══════════════════════════════════════════════════════════════════════════════
10+
11+
# ─────────────────────────────────────────────────────────────────────────────
12+
# Default Owner - All files unless overridden below
13+
# ─────────────────────────────────────────────────────────────────────────────
14+
* @DeepRatAI
15+
16+
# ─────────────────────────────────────────────────────────────────────────────
17+
# Core Application
18+
# ─────────────────────────────────────────────────────────────────────────────
19+
/src/cortex_ka/ @DeepRatAI
20+
/src/cortex_ka/api/ @DeepRatAI
21+
/src/cortex_ka/core/ @DeepRatAI
22+
/src/cortex_ka/services/ @DeepRatAI
23+
24+
# ─────────────────────────────────────────────────────────────────────────────
25+
# Security-Sensitive Areas (require explicit review)
26+
# ─────────────────────────────────────────────────────────────────────────────
27+
/src/cortex_ka/auth/ @DeepRatAI
28+
/src/cortex_ka/security/ @DeepRatAI
29+
SECURITY.md @DeepRatAI
30+
31+
# ─────────────────────────────────────────────────────────────────────────────
32+
# Infrastructure & DevOps
33+
# ─────────────────────────────────────────────────────────────────────────────
34+
/docker/ @DeepRatAI
35+
docker-compose*.yml @DeepRatAI
36+
/k8s/ @DeepRatAI
37+
/.github/workflows/ @DeepRatAI
38+
39+
# ─────────────────────────────────────────────────────────────────────────────
40+
# Documentation
41+
# ─────────────────────────────────────────────────────────────────────────────
42+
/docs/ @DeepRatAI
43+
README.md @DeepRatAI
44+
45+
# ─────────────────────────────────────────────────────────────────────────────
46+
# Configuration & Dependencies
47+
# ─────────────────────────────────────────────────────────────────────────────
48+
pyproject.toml @DeepRatAI
49+
requirements*.txt @DeepRatAI
50+
/.github/dependabot.yml @DeepRatAI

.github/FUNDING.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# ══════════════════════════════════════════════════════════════════════════════
2+
# Cortex Knowledge Assistant - Funding Configuration
3+
# ══════════════════════════════════════════════════════════════════════════════
4+
# This file enables the "Sponsor" button on the GitHub repository
5+
# Uncomment the platforms you want to use for receiving sponsorships
6+
# ══════════════════════════════════════════════════════════════════════════════
7+
8+
# GitHub Sponsors username
9+
# github: [your-github-username]
10+
11+
# Patreon username
12+
# patreon: your-patreon-username
13+
14+
# Open Collective username
15+
# open_collective: your-opencollective-username
16+
17+
# Ko-fi username
18+
# ko_fi: your-kofi-username
19+
20+
# Buy Me a Coffee username
21+
# buy_me_a_coffee: your-buymeacoffee-username
22+
23+
# Liberapay username
24+
# liberapay: your-liberapay-username
25+
26+
# Custom sponsorship URLs (up to 4)
27+
# custom: ["https://your-custom-link.com"]
28+
29+
# ──────────────────────────────────────────────────────────────────────────────
30+
# Instructions:
31+
# 1. Uncomment the platform(s) you want to use
32+
# 2. Replace the placeholder with your actual username
33+
# 3. Commit and push to see the "Sponsor" button on your repo
34+
# ──────────────────────────────────────────────────────────────────────────────
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
name: Bug Report
3+
about: Create a report to help us improve Cortex
4+
title: "[BUG] "
5+
labels: "bug, triage"
6+
assignees: ""
7+
---
8+
9+
## Bug Description
10+
11+
A clear and concise description of what the bug is.
12+
13+
## Steps to Reproduce
14+
15+
1. Go to '...'
16+
2. Click on '...'
17+
3. Scroll down to '...'
18+
4. See error
19+
20+
## Expected Behavior
21+
22+
A clear and concise description of what you expected to happen.
23+
24+
## Actual Behavior
25+
26+
A clear and concise description of what actually happened.
27+
28+
## Screenshots
29+
30+
If applicable, add screenshots to help explain your problem.
31+
32+
## Environment
33+
34+
- **OS**: [e.g., Ubuntu 22.04, macOS 14, Windows 11]
35+
- **Docker version**: [e.g., 24.0.7]
36+
- **Docker Compose version**: [e.g., 2.23.0]
37+
- **Cortex version**: [e.g., 1.0.0]
38+
- **Browser** (if UI issue): [e.g., Chrome 120, Firefox 121]
39+
40+
## Logs
41+
42+
<details>
43+
<summary>Click to expand logs</summary>
44+
45+
```
46+
Paste relevant logs here
47+
```
48+
49+
</details>
50+
51+
## Additional Context
52+
53+
Add any other context about the problem here.
54+
55+
## Checklist
56+
57+
- [ ] I have searched existing issues to ensure this is not a duplicate
58+
- [ ] I have included all relevant information above
59+
- [ ] I have checked the [documentation](../README.md)
60+
- [ ] I am using the latest version of Cortex

0 commit comments

Comments
 (0)