Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Financial RAG Platform

Production-ready AI Retrieval-Augmented Generation (RAG) platform built with FastAPI, React, ChromaDB, Google Gemini, Docker, AWS EC2, Prometheus, Grafana and GitHub Actions CI/CD.

Python FastAPI React Docker AWS GitHub Actions Prometheus Grafana ChromaDB Gemini


πŸ“Œ Project Overview

Financial RAG Platform is an end-to-end Generative AI application that demonstrates how modern LLM-powered systems can be engineered, containerized, monitored and deployed using production-inspired software engineering practices.

Instead of relying only on a Large Language Model, the platform implements Retrieval-Augmented Generation (RAG) to provide grounded responses from uploaded financial documents. Users can upload PDF reports, annual statements or investment documents, build a semantic vector database and interact with them through natural language.

Beyond the AI workflow, this project focuses heavily on Cloud Engineering, DevOps, Backend Engineering and Observability by implementing automated CI/CD pipelines, Dockerized services, AWS deployment, monitoring dashboards and production health checks.


🎯 Project Objectives

The primary objective of this project was to understand how production AI systems are built rather than simply calling an LLM API.

The project explores multiple engineering domains simultaneously:

  • Artificial Intelligence Engineering
  • Retrieval-Augmented Generation (RAG)
  • Backend API Development
  • Cloud Computing
  • DevOps Engineering
  • Infrastructure Automation
  • Monitoring & Observability
  • Containerized Deployments
  • Continuous Integration & Continuous Deployment (CI/CD)
  • Production Debugging

Rather than treating AI as a standalone component, the application demonstrates how intelligent systems are integrated into reliable production environments.


⭐ Key Highlights

πŸ€– AI Engineering

  • Retrieval-Augmented Generation (RAG)
  • Financial Document Question Answering
  • Sentence Transformer Embeddings
  • ChromaDB Vector Database
  • Semantic Similarity Search
  • Context-aware Prompt Construction
  • Source Grounded Gemini Responses
  • Multi-document Knowledge Base
  • Intelligent Document Chunking
  • Retrieval-only fallback mode

☁ Cloud & DevOps Engineering

  • Dockerized Microservice Architecture
  • Docker Compose Orchestration
  • AWS EC2 Deployment
  • Nginx Reverse Proxy
  • GitHub Actions CI/CD
  • Automated Docker Hub Publishing
  • Health Checks
  • Persistent Volumes
  • Prometheus Monitoring
  • Grafana Dashboards
  • Automated Deployment Verification
  • Container Lifecycle Management

🧠 Why Retrieval-Augmented Generation?

Large Language Models are extremely capable but cannot reliably answer questions about private documents they have never seen.

Retrieval-Augmented Generation solves this problem by retrieving relevant document chunks before generating a response.

Instead of asking Gemini to hallucinate an answer, the application performs semantic retrieval against a vector database and supplies the retrieved context to the model.

Benefits include:

  • Higher factual accuracy
  • Reduced hallucinations
  • Source-grounded responses
  • Support for private datasets
  • Domain-specific knowledge
  • Explainable AI outputs

πŸ— High Level System Architecture

                           GitHub Repository
                                  β”‚
                                  β–Ό
                        GitHub Actions Workflow
                                  β”‚
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β–Ό                                     β–Ό
      Backend Docker Image                 Frontend Docker Image
               β”‚                                     β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β–Ό
                             Docker Hub
                                  β”‚
                                  β–Ό
                           AWS EC2 Instance
                                  β”‚
                           Docker Compose
                                  β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β–Ό             β–Ό               β–Ό               β–Ό
     Nginx        React UI       FastAPI API     Prometheus
                                        β”‚               β”‚
                                        β–Ό               β–Ό
                                  RAG Pipeline      Grafana
                                        β”‚
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β–Ό                                    β–Ό
                ChromaDB                         Google Gemini
                     β”‚
                     β–Ό
         Sentence Transformer Embeddings

🧠 Retrieval-Augmented Generation Pipeline

                    Upload Financial PDF
                             β”‚
                             β–Ό
                    Extract PDF Content
                             β”‚
                             β–Ό
                   Intelligent Text Chunking
                             β”‚
                             β–Ό
          Generate Sentence Transformer Embeddings
                             β”‚
                             β–Ό
                    Store in ChromaDB
                             β”‚
                             β–Ό
                  User asks a Question
                             β”‚
                             β–Ό
                  Semantic Similarity Search
                             β”‚
                             β–Ό
              Retrieve Most Relevant Chunks
                             β”‚
                             β–Ό
      Build Prompt using Retrieved Context
                             β”‚
                             β–Ό
                  Google Gemini LLM
                             β”‚
                             β–Ό
         Source Grounded Financial Response

☁ Production Deployment Architecture

                     Developer
                          β”‚
                          β–Ό
                  Push to GitHub
                          β”‚
                          β–Ό
                 GitHub Actions CI/CD
                          β”‚
                          β–Ό
               Build Docker Images
                          β”‚
                          β–Ό
                 Push to Docker Hub
                          β”‚
                          β–Ό
              Connect to AWS EC2 via SSH
                          β”‚
                          β–Ό
                Pull Latest Docker Images
                          β”‚
                          β–Ό
                Docker Compose Deployment
                          β”‚
                          β–Ό
                 Health Check Verification
                          β”‚
                          β–Ό
               Production Application Live

πŸ“Š Monitoring Architecture

                  FastAPI Application
                           β”‚
                           β–Ό
              Prometheus Instrumentation
                           β”‚
                           β–Ό
                    /metrics Endpoint
                           β”‚
                           β–Ό
                  Prometheus Scraping
                           β”‚
                           β–Ό
                  Time Series Database
                           β”‚
                           β–Ό
                  Grafana Dashboards
                           β”‚
                           β–Ό
              Performance Visualization

βš™ Technology Stack

Category Technologies
Programming Language Python, JavaScript
Backend Framework FastAPI
Frontend React + Vite
AI Model Google Gemini
Embedding Model Sentence Transformers
Vector Database ChromaDB
PDF Processing PyPDF
API Server Uvicorn
Monitoring Prometheus
Visualization Grafana
Containerization Docker
Orchestration Docker Compose
Reverse Proxy Nginx
CI/CD GitHub Actions
Container Registry Docker Hub
Cloud Platform AWS EC2
Version Control Git & GitHub

πŸ“ Repository Structure

financial-rag-platform/

β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py
β”‚   β”‚   β”œβ”€β”€ rag_pipeline.py
β”‚   β”‚   β”œβ”€β”€ vector_store.py
β”‚   β”‚   β”œβ”€β”€ pdf_loader.py
β”‚   β”‚   β”œβ”€β”€ text_splitter.py
β”‚   β”‚   β”œβ”€β”€ config.py
β”‚   β”‚   └── schemas.py
β”‚   β”‚
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── requirements.txt
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ public/
β”‚   └── Dockerfile
β”‚
β”œβ”€β”€ monitoring/
β”‚   β”œβ”€β”€ prometheus.yml
β”‚   └── grafana/
β”‚
β”œβ”€β”€ nginx/
β”‚   β”œβ”€β”€ nginx.conf
β”‚   └── default.conf
β”‚
β”œβ”€β”€ screenshots/
β”‚
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── deployment.yml
β”‚
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ docker-compose.prod.yml
└── README.md

πŸ“Έ Project Walkthrough

The following screenshots showcase the complete lifecycle of the applicationβ€”from uploading financial documents and generating AI-powered responses to production deployment, monitoring, and cloud infrastructure.


1️⃣ Live Application Running on AWS EC2

Demonstrates the production application successfully deployed on an AWS EC2 instance.

Live Application


2️⃣ Upload Financial Document

Upload a financial PDF to build the knowledge base for Retrieval-Augmented Generation (RAG).

Upload Success


3️⃣ AI Generated Response with Retrieved Source Chunks

Question answering powered by semantic search with source-grounded responses generated using Google Gemini.

AI Response


4️⃣ Reset Vector Database

Clear all uploaded documents and vector embeddings to start with a fresh knowledge base.

Vector Database Reset


5️⃣ Production Docker Containers

Docker Compose running the complete production stack, including the frontend, backend, Nginx, Prometheus, and Grafana services.

Docker Containers


6️⃣ Production Health Endpoint

Production health endpoint used by Docker health checks and the CI/CD deployment pipeline.

Production Health Endpoint


7️⃣ GitHub Actions CI/CD Pipeline

Successful automated pipeline for validation, testing, Docker image publishing, and deployment to AWS.

GitHub Actions Pipeline


8️⃣ Docker Hub Published Images

Automatically published production Docker images for deployment and version management.

Docker Hub Images


9️⃣ Prometheus Monitoring

Prometheus continuously collecting metrics from the FastAPI backend for monitoring and observability.

Prometheus Targets


πŸ”Ÿ Grafana Dashboard

Grafana dashboard visualizing application performance, request metrics, and service health.

Grafana Dashboard


1️⃣1️⃣ AWS EC2 Production Infrastructure

AWS EC2 instance hosting the production deployment of the application.

AWS EC2 Instance


1️⃣2️⃣ AWS Security Group Configuration

Inbound security rules configured to securely expose HTTP, HTTPS, and SSH access for the production environment.

AWS Security Group


πŸ’‘ Skills Demonstrated

This project demonstrates practical experience in:

  • Artificial Intelligence Engineering
  • LLM Application Development
  • Retrieval-Augmented Generation
  • Semantic Search
  • Vector Databases
  • Backend API Development
  • REST API Design
  • Cloud Deployment
  • DevOps Engineering
  • Docker
  • Docker Compose
  • GitHub Actions
  • CI/CD
  • AWS EC2
  • Monitoring
  • Observability
  • Infrastructure Automation
  • Production Debugging

πŸš€ Running the Project Locally

Prerequisites

Before running the application, ensure the following software is installed:

Software Version
Python 3.10+
Docker Latest
Docker Compose Latest
Git Latest

You will also require a valid Google Gemini API Key.


Clone Repository

git clone https://github.com/aadi090204/financial-rag-platform.git

cd financial-rag-platform

Configure Environment Variables

Create an environment file.

cp .env.example .env

Add your Gemini API Key.

GEMINI_API_KEY=YOUR_API_KEY

Build Docker Images

docker compose build

Start the Complete Application

docker compose up -d

Verify Running Containers

docker ps

Expected services:

  • Frontend
  • Backend
  • Nginx
  • Prometheus
  • Grafana

🌐 Application Services

Service URL
Frontend http://localhost
Backend API http://localhost:8000
Swagger UI http://localhost:8000/docs
Health Endpoint http://localhost/health
Metrics http://localhost:8000/metrics
Prometheus http://localhost:9090
Grafana http://localhost:3001

πŸ”Œ REST API

Upload Document

POST /upload

Uploads financial PDF documents.


Ask Question

POST /ask

Queries uploaded financial documents using semantic search and Gemini.


Reset Vector Database

DELETE /documents/reset

Deletes all stored embeddings and uploaded documents.


Health Check

GET /health

Used by Docker health checks and deployment verification.


Metrics Endpoint

GET /metrics

Exports Prometheus metrics.


πŸ”„ GitHub Actions CI/CD Pipeline

The deployment pipeline follows a production-inspired workflow.

Developer Push
      β”‚
      β–Ό
GitHub Repository
      β”‚
      β–Ό
GitHub Actions
      β”‚
      β–Ό
Validate Docker Compose
      β”‚
      β–Ό
Integration Tests
      β”‚
      β–Ό
Build Backend Image
      β”‚
      β–Ό
Build Frontend Image
      β”‚
      β–Ό
Publish Docker Images
      β”‚
      β–Ό
Sync Production Configuration
      β”‚
      β–Ό
Deploy to AWS EC2
      β”‚
      β–Ό
Health Verification
      β”‚
      β–Ό
Docker Image Cleanup

The workflow performs:

  • Docker Compose validation
  • Integration testing
  • Docker image creation
  • Docker Hub publishing
  • Automated AWS deployment
  • Health verification
  • Automatic cleanup of dangling images

☁ AWS Deployment

The production environment runs on an AWS EC2 instance.

Deployment stack:

  • Amazon EC2
  • Docker Compose
  • Nginx Reverse Proxy
  • Docker Hub
  • GitHub Actions
  • Prometheus
  • Grafana

The deployment process is fully automated.

Each push to the main branch triggers a deployment pipeline that:

  1. Builds Docker images.
  2. Publishes them to Docker Hub.
  3. Connects securely to EC2.
  4. Pulls updated images.
  5. Restarts containers.
  6. Verifies service health.
  7. Cleans unused Docker images.

🐳 Docker Architecture

Each application component runs as an isolated container.

Docker Compose

β”œβ”€β”€ Nginx
β”‚
β”œβ”€β”€ React Frontend
β”‚
β”œβ”€β”€ FastAPI Backend
β”‚      β”‚
β”‚      β–Ό
β”‚   ChromaDB
β”‚
β”œβ”€β”€ Prometheus
β”‚
└── Grafana

Benefits:

  • Service isolation
  • Easy scaling
  • Reproducible environments
  • Simplified deployment
  • Independent updates

πŸ“ˆ Monitoring & Observability

Monitoring was integrated from the beginning to simulate a production environment.

Prometheus periodically scrapes metrics exposed by the FastAPI application.

Grafana visualizes these metrics using dashboards.

Collected metrics include:

  • Request count
  • Request duration
  • API latency
  • Endpoint availability
  • Container health
  • Service uptime

This enables proactive monitoring and easier debugging.


❀️ Health Checks

The application implements health checks at multiple levels.

Backend

Docker Healthcheck

GET /health

Deployment

GitHub Actions verifies application readiness after deployment.

Infrastructure

Prometheus continuously monitors application availability.


πŸ“‚ Persistent Storage

Application data persists between deployments.

Persistent directories include:

uploads/

Stores uploaded PDF files.

chroma_db/

Stores vector embeddings.

This prevents data loss during container recreation.


πŸ” Security Considerations

The project follows several production-oriented security practices.

  • Environment variables stored outside source code
  • Sensitive API keys excluded from Git
  • Reverse proxy through Nginx
  • Automated health verification
  • Isolated Docker network
  • Persistent storage mounted through Docker volumes

Future improvements include:

  • JWT Authentication
  • HTTPS using Let's Encrypt
  • Secrets Manager
  • IAM Roles

⚑ Performance Optimizations

Several optimizations were implemented throughout development.

Backend

  • Lazy initialization
  • Optimized startup sequence
  • Health endpoint
  • Docker health checks

Docker

  • Multi-container architecture
  • Automatic restart policies
  • Docker image cleanup
  • Persistent volumes

Deployment

  • Automated health verification
  • Reduced deployment downtime
  • Image reuse
  • Pull policy optimization

πŸ›  Engineering Challenges Solved

Throughout development several real-world engineering problems were encountered and resolved.

Docker

  • Large image size
  • Disk exhaustion on EC2
  • Dangling image cleanup
  • Container lifecycle management

CI/CD

  • Deployment synchronization
  • Health verification timing
  • SSH connectivity
  • Automated deployment debugging

AI

  • PDF parsing reliability
  • Embedding generation
  • Semantic retrieval
  • Prompt construction
  • Gemini integration

Monitoring

  • Prometheus scraping
  • Grafana dashboards
  • Metrics instrumentation

Infrastructure

  • Docker networking
  • Reverse proxy configuration
  • Persistent volumes
  • Production deployment

πŸ“š Key Learnings

This project provided hands-on experience with modern AI and cloud-native engineering practices.

Artificial Intelligence

  • Retrieval-Augmented Generation
  • Vector Databases
  • Semantic Search
  • Embedding Models
  • Prompt Engineering
  • Large Language Models

Backend Development

  • FastAPI
  • REST APIs
  • File Upload Handling
  • Background Processing

Cloud

  • AWS EC2
  • Linux Server Administration
  • Nginx
  • Docker Deployment

DevOps

  • Docker
  • Docker Compose
  • GitHub Actions
  • Docker Hub
  • CI/CD Pipelines
  • Monitoring
  • Observability

πŸš€ Future Improvements

Planned enhancements include:

  • Kubernetes Deployment
  • AWS ECS
  • AWS EKS
  • Terraform Infrastructure as Code
  • Redis Caching
  • JWT Authentication
  • User Accounts
  • Multi-user Document Collections
  • OpenTelemetry
  • Distributed Tracing
  • Object Storage (Amazon S3)
  • Horizontal Scaling
  • Load Balancing
  • Blue-Green Deployment
  • Canary Releases
  • Automated Unit Testing
  • Integration Testing
  • Security Scanning

πŸ’Ό Skills Demonstrated

This project demonstrates practical experience in:

Artificial Intelligence

  • Retrieval-Augmented Generation (RAG)
  • Generative AI
  • LLM Integration
  • Google Gemini
  • Semantic Search
  • ChromaDB
  • Vector Databases

Backend Engineering

  • FastAPI
  • REST API Development
  • Python
  • API Design
  • File Processing

Cloud Engineering

  • AWS EC2
  • Linux
  • Docker Deployment
  • Reverse Proxy
  • Infrastructure Management

DevOps Engineering

  • Docker
  • Docker Compose
  • GitHub Actions
  • CI/CD
  • Docker Hub
  • Monitoring
  • Observability
  • Health Checks

🀝 Contributing

Contributions are welcome.

Feel free to:

  • Open issues
  • Suggest improvements
  • Submit pull requests

πŸ“„ License

This project is released under the MIT License.


πŸ‘¨β€πŸ’» Author

Adithya Anil

Software Engineer passionate about building production-ready AI systems that combine modern LLM technologies with cloud-native engineering practices.

Areas of Interest

  • Artificial Intelligence
  • Generative AI
  • Retrieval-Augmented Generation
  • Backend Engineering
  • Cloud Computing
  • DevOps
  • Platform Engineering
  • Distributed Systems

Connect

GitHub

https://github.com/aadi090204

LinkedIn

https://www.linkedin.com/in/adithya-anil-8a247a255/


⭐ If you found this project interesting, consider giving it a star!

It helps others discover the project and supports future development.


Thank you for visiting the repository! πŸš€

About

Production-ready Financial RAG platform with FastAPI, React, ChromaDB, Gemini, Docker, AWS EC2, Prometheus, Grafana and GitHub Actions.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages