Skip to content

Latest commit

Β 

History

336 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Fylex Logo

Fylex

AI-Powered Document Security & Fraud Detection Platform

License: MIT Next.js Spring Boot FastAPI

Advanced document scanning that detects malicious activity line by line. Keep your data safe with intelligent threat detection.


πŸ“‹ Table of Contents


🎯 Overview

Fylex is a comprehensive AI-powered document security platform designed to protect users from fraud and malicious content in documents. The platform analyzes PDFs, contracts, emails, and other text-based documents using advanced AI models to detect:

  • Phishing attempts
  • Lottery scams
  • Financial manipulation
  • Impersonation
  • Other fraudulent activities

The system provides detailed risk assessments with line-by-line analysis, highlighting suspicious content and assigning risk levels (High, Medium, Low) to help users make informed decisions about document safety.


✨ Features

πŸ”’ Security & Analysis

  • Line-by-line document analysis - Deep scanning of every sentence and element
  • Multi-risk detection - Identifies various types of fraud and threats
  • Risk level assessment - Categorizes threats as High, Medium, or Low
  • Detailed explanations - Provides context for each detected risk
  • Fast processing - Get security reports in seconds

πŸ‘€ User Experience

  • OAuth authentication - Sign in with Google or GitHub
  • User dashboard - Monitor document security and analysis history
  • Document management - Upload, view, and manage analyzed documents
  • Statistics tracking - View total scans, threats detected, and clean documents
  • Profile management - Customize your profile with picture upload

πŸ›‘οΈ Platform Features

  • Real-time analysis - Instant document processing
  • Secure file storage - Cloudinary integration for document storage
  • JWT authentication - Secure token-based authentication
  • WebSocket support - Real-time communication capabilities
  • Rate limiting - API protection against abuse

πŸ—οΈ Architecture

Fylex follows a microservices architecture with three main components:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client (UI)   β”‚  Next.js 15 + React 19 + shadcn/ui + Radix UI
β”‚   Port: 3000    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ HTTP/REST
         β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Server (API)   β”‚  Spring Boot 3.5.5 + PostgreSQL
β”‚   Port: 8000    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ HTTP/REST
         β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Model (AI)     β”‚  FastAPI + OpenAI/HuggingFace
β”‚   Port: 7000    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Component Responsibilities

  • Client: User interface, authentication, document upload, dashboard, and visualization
  • Server: Business logic, database management, authentication, file processing, API orchestration
  • Model: AI-powered document analysis, fraud detection, risk assessment

πŸ› οΈ Tech Stack

Frontend (Client)

  • Framework: Next.js 15.5.9
  • UI Library: React 19.1.1
  • Styling: Tailwind CSS + shadcn/ui
  • Language: TypeScript 5.9.3
  • Authentication: OAuth (Google, GitHub)
  • Testing: Vitest 4.0.15
  • Build Tool: Next.js built-in

Backend (Server)

  • Framework: Spring Boot 3.5.5
  • Language: Java 17
  • Database: PostgreSQL
  • Security: Spring Security + JWT
  • File Processing: Apache Tika 2.9.2
  • Storage: Cloudinary
  • Build Tool: Maven
  • WebSocket: Spring WebSocket

AI Service (Model)

  • Framework: FastAPI 0.116.1
  • Language: Python 3.13
  • AI Provider: HuggingFace (Llama 3.3 70B)
  • Rate Limiting: SlowAPI
  • HTTP Client: httpx

Infrastructure

  • Containerization: Docker & Docker Compose
  • Web Server: Nginx (production)
  • Version Control: Git

πŸ“¦ Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js 20+ and npm
  • Java 17+
  • Maven 3.6+
  • Python 3.13+
  • Docker and Docker Compose (recommended)
  • PostgreSQL 12+ (if not using Docker)
  • HuggingFace API Token (for AI model access)
  • Cloudinary Account (for file storage)
  • Google OAuth Credentials
  • GitHub OAuth Credentials

πŸš€ Installation

Option 1: Docker Compose (Recommended)

  1. Clone the repository

    git clone <repository-url>
    cd Fylex
  2. Set up environment variables

    • Create .env files in each service directory (see Configuration)
  3. Build and run with Docker Compose

    docker-compose up --build

    The application will be available at:

Option 2: Manual Setup

Client Setup

cd client
npm install
npm run dev

Server Setup

cd server
mvn clean install
mvn spring-boot:run

Model Setup

cd model
pip install -r requirements.txt
fastapi run app/api.py --port 8000

βš™οΈ Configuration

Client Environment Variables

Create client/.env:

SERVER_BASE_URL=http://localhost:8000/api
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-google-client-id
NEXT_PUBLIC_GITHUB_CLIENT_ID=your-github-client-id

Server Environment Variables

Create server/.env:

# Application
SPRING_APPLICATION_NAME=server

# Database
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/fylex
SPRING_DATASOURCE_USERNAME=your-db-username
SPRING_DATASOURCE_PASSWORD=your-db-password

# JWT
JWT_SECRET=your-jwt-secret-key
EXPIRATIONMS=86400000

# OAuth
CLIENT_ID_GOOGLE=your-google-client-id

# Cloudinary
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret

# CORS
ALLOWED_ORIGINS=http://localhost:3000

Model Environment Variables

Create model/.env:

BASE_URL_HUGINGFACE=https://api-inference.huggingface.co/v1
HF_TOKEN=your-huggingface-token
CORS_ALLOWED_ORIGINS=http://localhost:8000

πŸƒ Running the Application

Development Mode

Client:

cd client
npm run dev

Server:

cd server
mvn spring-boot:run

Model:

cd model
fastapi run app/api.py --port 8000

Production Build

Client:

cd client
npm run build
npm start

Server:

cd server
mvn clean package
java -jar target/server-0.0.1-SNAPSHOT.jar

πŸ“ Project Structure

Fylex/
β”œβ”€β”€ client/                 # Next.js frontend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/            # Next.js app router pages
β”‚   β”‚   β”œβ”€β”€ components/     # React components
β”‚   β”‚   β”œβ”€β”€ actions/        # Server actions
β”‚   β”‚   β”œβ”€β”€ services/       # Business logic services
β”‚   β”‚   β”œβ”€β”€ infrastructure/ # External API clients
β”‚   β”‚   β”œβ”€β”€ types/          # TypeScript type definitions
β”‚   β”‚   └── utils/          # Utility functions
β”‚   β”œβ”€β”€ public/             # Static assets
β”‚   └── tests/              # Test files
β”‚
β”œβ”€β”€ server/                 # Spring Boot backend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   └── main/
β”‚   β”‚       β”œβ”€β”€ java/       # Java source code
β”‚   β”‚       └── resources/  # Configuration files
β”‚   └── pom.xml             # Maven dependencies
β”‚
β”œβ”€β”€ model/                  # FastAPI AI service
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ api.py          # FastAPI application
β”‚   β”‚   β”œβ”€β”€ script.py       # AI analysis logic
β”‚   β”‚   └── base.py         # Data models
β”‚   └── requirements.txt    # Python dependencies
β”‚
└── docker-compose.yml      # Docker orchestration

πŸ§ͺ Testing

Client Tests

The client includes comprehensive test coverage:

cd client

# Run all tests
npm test

# Run tests with UI
npm run test:ui

# Run tests with coverage
npm run test:coverage

# Run tests once
npm run test:run

Test Coverage:

  • Unit tests for services, actions, infrastructure, and utilities
  • Integration tests for authentication, document upload, and error handling
  • Middleware tests

Server Tests

cd server
mvn test

πŸ“š API Documentation

Model Service API

POST /ml/service/analysis

  • Analyzes document text for fraud detection
  • Rate limit: 5 requests per minute
  • Request body: { "text": "document content" }
  • Response: Analysis results with risk levels and explanations

Server API

The server provides RESTful endpoints for:

  • Authentication (login, register, OAuth)
  • Document management (upload, list, view)
  • User profile management
  • Statistics and analytics

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure your code:

  • Follows the existing code style
  • Includes tests for new features
  • Updates documentation as needed
  • Passes all existing tests

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2025 Nefara (Owners Dimitar Anastasov, Martin Velchev)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...

πŸ‘₯ Authors

Nefara

  • Dimitar Anastasov
  • Martin Velchev

πŸ™ Acknowledgments


Made with ❀️ by the Fylex Team

Fylex Footer Logo

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages