Skip to content

mohitravaldev/cortex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Cortex

A production-ready full-stack monorepo β€” NestJS backend with RAG (Retrieval-Augmented Generation) and a Flutter mobile app for notes, POS record management, and AI-powered Q&A.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          Cortex Monorepo                             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  Flutter App    β”‚  HTTPS  β”‚         NestJS Backend           β”‚    β”‚
β”‚  β”‚  (mobile/)      │◄───────►│         (backend/)               β”‚    β”‚
β”‚  β”‚                 β”‚         β”‚                                  β”‚    β”‚
β”‚  β”‚  β€’ Riverpod     β”‚         β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚    β”‚
β”‚  β”‚  β€’ Drift SQLite β”‚         β”‚  β”‚  Auth   β”‚  β”‚    Notes     β”‚   β”‚    β”‚
β”‚  β”‚  β€’ Secure Store β”‚         β”‚  β”‚  Module β”‚  β”‚    Module    β”‚   β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚    β”‚
β”‚                              β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚    β”‚
β”‚                              β”‚  β”‚   POS   β”‚  β”‚  AI / RAG    β”‚   β”‚    β”‚
β”‚                              β”‚  β”‚  Module β”‚  β”‚    Module    β”‚   β”‚    β”‚
β”‚                              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚    β”‚
β”‚                              β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚    β”‚
β”‚                              β”‚  β”‚     Ingestion Worker        β”‚ β”‚    β”‚
β”‚                              β”‚  β”‚  (BullMQ β€” OCR, chunk,      β”‚ β”‚    β”‚
β”‚                              β”‚  β”‚   embed, upsert vectors)    β”‚ β”‚    β”‚
β”‚                              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚    β”‚
β”‚                              β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                                      β”‚                               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚ PostgreSQL β”‚  β”‚  Redis  β”‚  β”‚   MinIO     β”‚  β”‚  OpenAI /     β”‚     β”‚
β”‚  β”‚ + pgvector β”‚  β”‚  Queue  β”‚  β”‚ (S3-compat) β”‚  β”‚  Gemini API   β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚                                                                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Repo Structure

cortex/
β”œβ”€β”€ backend/          # NestJS (TypeScript) β€” REST API + RAG pipeline
β”œβ”€β”€ mobile/           # Flutter (Dart) β€” cross-platform mobile app
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ .env.example
β”œβ”€β”€ .github/workflows/ci.yml
β”œβ”€β”€ docs/
β”‚   └── rag.md
└── README.md

Quick Start

Prerequisites

  • Docker & Docker Compose v2
  • Node 20 + pnpm 9
  • Flutter SDK 3.x

1. Clone & configure

git clone https://github.com/your-org/cortex.git
cd cortex
cp .env.example .env
# Edit .env β€” set OPENAI_API_KEY (or GEMINI_API_KEY), JWT_SECRET, etc.

2. Start infrastructure

docker compose up -d postgres redis minio

3. Run backend

cd backend
pnpm install
pnpm prisma migrate dev --name init
pnpm prisma db seed
pnpm start:dev

API docs available at http://localhost:3000/api/docs

4. Run the worker (separate terminal)

cd backend
pnpm run start:worker

5. Run the Flutter app

cd mobile
flutter pub get
flutter run

Services

Service URL Description
Backend http://localhost:3000 NestJS REST API
Swagger http://localhost:3000/api/docs OpenAPI docs
MinIO http://localhost:9001 Object storage console
Postgres localhost:5432 PostgreSQL + pgvector
Redis localhost:6379 Cache + BullMQ

Privacy-First Architecture

β†’ Because it is self-hostable with a local PostgreSQL/pgvector instance, your "Second Brain" data is never used to train third-party models. You own your data sovereignty.

License

MIT β€” see LICENSE.

About

🧠 AI-powered second brain β€” self-hostable RAG knowledge engine with Flutter + NestJS + pgvector

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors