Mental health admissions research platform built with React, FastAPI, and Oracle Autonomous Database 23ai.
Brain is the II Malackathon 2025 project focused on mental health hospital admissions. It combines secure Oracle data access, exploratory analytics, interactive visualization, and an AI assistant designed for clinical research support.
Mental health admission data is often difficult to explore consistently across technical and non-technical teams. Brain provides one entry point to query, analyze, and visualize the dataset while preserving privacy controls and reproducible workflows.
- FastAPI API Gateway with microservice-style routers for health, insights, visualization, categories, and AI.
- Oracle Autonomous Database 23ai integration via wallet-based secure connectivity and connection pooling.
- React + TypeScript frontend for interactive filtering, chart-based exploration, and a research-focused UX.
- Multi-agent AI assistant for natural-language analysis, streaming responses, SQL-backed insights, and diagram generation.
- Dockerized local and production setups with Nginx reverse proxy and automated deployment workflow.
- R-based EDA and feature engineering outputs for analytical traceability.
flowchart LR
UI[Frontend - React/Vite] --> NG[Nginx Reverse Proxy]
NG --> GW[FastAPI API Gateway :8000]
GW --> HS[Health Service]
GW --> IS[Insights Service]
GW --> VS[Visualization Service]
GW --> CS[Categories Service]
GW --> AIS[AI Service - Multi Agent]
HS --> ORACLE[(Oracle Autonomous Database 23ai)]
IS --> ORACLE
VS --> ORACLE
CS --> ORACLE
AIS --> ORACLE
AIS --> XAI[xAI API]
AIS --> TAVILY[Tavily Search API]
| Service | Port | Responsibility |
|---|---|---|
frontend |
5173 | Research UI, filters, charts, AI chat interface |
backend |
8000 | API Gateway, business services orchestration |
nginx |
80/443 | Reverse proxy, TLS termination, routing |
oracle-adb |
managed | Clinical dataset storage, views, secure query access |
| Layer | Technologies |
|---|---|
| Frontend | React 19, TypeScript, Vite, Recharts |
| Backend | FastAPI, Python 3.12, Pydantic v2, LangGraph |
| Data | Oracle Autonomous Database 23ai, python-oracledb |
| AI | xAI-compatible LLM API, Tavily search |
| Data science | R (Quarto), PDF reporting |
| Infra | Docker, Docker Compose, Nginx, GitHub Actions |
- Docker + Docker Compose
- Oracle wallet files available in
app/oracle_wallet/ - A root
.envfile with Oracle credentials - Node.js 20+ (only if running frontend outside Docker)
- Python 3.12 (only if running backend outside Docker)
git clone https://github.com/arrozet/malackathon25.git
cd malackathon25Use this as a baseline:
ORACLE_DSN=fagfefcg84y83s1a_medium
ORACLE_USER=DAJER_ADMIN
ORACLE_PASSWORD=<your_oracle_password>
TNS_ADMIN=/app/oracle_wallet
ORACLE_WALLET_PASSWORD=<your_wallet_password>
APP_ENV=prod
DEBUG=false
CORS_ORIGINS=http://localhost:5173,http://127.0.0.1:5173
# AI (required for /api/ai endpoints)
XAI_API_KEY=<your_xai_api_key>
TAVILY_API_KEY=<optional_tavily_key>docker compose up --build- App (through Nginx):
http://localhost - API docs (FastAPI):
http://localhost/docs - API health:
http://localhost/api/health
Main routes exposed by the backend:
GET /- API Gateway status and service listGET /api/health- health check with database statusGET /api/db/pool-status- Oracle connection pool statusGET /api/insights- summary metrics for the landing pageGET /api/data/visualization- filtered chart-ready aggregationsGET /api/data/categories- available diagnostic categoriesPOST /api/ai/chat- non-streaming AI assistant responsePOST /api/ai/chat/stream- streaming AI assistant events (SSE)POST /api/ai/analyze- analysis-focused AI routePOST /api/ai/visualize- Mermaid diagram generation routeGET /api/ai/health- AI subsystem health status
python -m venv .venv
# Windows PowerShell
.\.venv\Scripts\activate
# Linux/macOS
# source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
uvicorn app.back.main:app --reload --host 0.0.0.0 --port 8000cd app/front
npm install
npm run devDatabase schema creation, normalization workflow, data loading, anonymization, and read-only user guidance are documented in:
database/README.md
Important scripts include:
database/create.sqldatabase/load_data.sqldatabase/normalizacion_schema.sql
Production deployment is automated with GitHub Actions and shell scripts:
- Workflow:
.github/workflows/deploy.yml - Manual deploy script:
deploy.sh - Non-interactive CI/CD deploy script:
deploy_auto.sh - Setup guide:
.github/DEPLOY_SETUP.md
Current production style targets an Oracle Cloud VM with Nginx + Docker Compose.
.
├── .github/
│ ├── workflows/
│ │ └── deploy.yml
│ └── DEPLOY_SETUP.md
├── app/
│ ├── back/
│ │ ├── main.py
│ │ ├── db.py
│ │ ├── config.py
│ │ ├── routers/
│ │ └── services/
│ ├── front/
│ │ ├── src/
│ │ ├── public/
│ │ └── package.json
│ ├── oracle_wallet/
│ └── RUN.md
├── database/
├── data/
│ └── R/
├── docs/
├── nginx/
├── scripts/
├── docker-compose.yml
├── docker-compose.prod.yml
├── deploy.sh
├── deploy_auto.sh
├── requirements.txt
├── LICENSE
└── README.md
- Expand automated test coverage (backend integration and frontend behavior).
- Introduce stronger auth/authorization controls for sensitive endpoints.
- Improve observability (metrics and dashboards) for API and database usage.
- Continue refining AI assistant reliability and source-grounded responses.
Contributions are welcome. For substantial changes, open an issue first to align on scope.
Typical flow:
- Fork the repository.
- Create a branch (
feature/...orfix/...). - Keep changes focused and documented.
- Run relevant checks/tests.
- Open a pull request with clear context.
This project is licensed under GPL-3.0. See LICENSE for details.
Malackathon 2025 - Dr. Artificial / DAJER Team