Skip to content

deepakflow/ai-analytical-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Analytics SaaS Platform

A powerful analytics platform that provides real-time event tracking and AI-powered insights for your applications.

Features

  • πŸ” Organization-based authentication with email OTP verification
  • πŸ“Š Real-time event tracking and analytics
  • πŸ€– AI-powered insights using DeepSeek
  • πŸ’Ύ Efficient data storage with PostgreSQL and TimescaleDB
  • πŸš€ High-performance caching with Redis
  • πŸ“ˆ Subscription plans (Free, Starter, Enterprise)
  • πŸ”„ RESTful API with FastAPI
  • 🐳 Docker containerization

Tech Stack

  • Backend: FastAPI, Python 3.11
  • Database: PostgreSQL with TimescaleDB
  • Caching: Redis
  • AI Integration: DeepSeek
  • Authentication: JWT, Email OTP
  • Infrastructure: Docker, Docker Compose

Prerequisites

  • Python 3.11 or higher
  • Docker and Docker Compose
  • PostgreSQL
  • Redis
  • Rust (for building some Python dependencies)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/analytics-saas.git
cd analytics-saas
  1. Create and activate virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: .\venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
  1. Start services using Docker Compose:
docker-compose up -d
  1. Run database migrations:
alembic upgrade head

Environment Variables

Create a .env file with the following variables:

DATABASE_URL=postgresql://user:password@localhost:5432/analytics_db
REDIS_URL=redis://localhost:6379
SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
REFRESH_TOKEN_EXPIRE_DAYS=7
DEEPSEEK_API_KEY=your-deepseek-api-key
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASSWORD=your-app-password

Project Structure

analytics_saas/
β”œβ”€β”€ alembic/                    # Database migrations
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/                    # API endpoints
β”‚   β”‚   └── v1/
β”‚   β”œβ”€β”€ core/                   # Core configuration
β”‚   β”œβ”€β”€ db/                     # Database setup
β”‚   β”œβ”€β”€ models/                 # Database models
β”‚   β”œβ”€β”€ schemas/                # Pydantic schemas
β”‚   β”œβ”€β”€ services/              # Business logic
β”‚   └── utils/                 # Utilities
β”œβ”€β”€ tests/                     # Test files
β”œβ”€β”€ alembic.ini               # Alembic config
β”œβ”€β”€ docker-compose.yml        # Docker services
β”œβ”€β”€ Dockerfile                # Docker config
└── requirements.txt          # Python dependencies

API Documentation

After starting the server, visit:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

Key Endpoints

  • Authentication:

    • POST /api/v1/auth/signup - Organization signup
    • POST /api/v1/auth/verify - OTP verification
  • Events:

    • POST /api/v1/events - Track events
    • GET /api/v1/events - Retrieve events
  • Analysis:

    • POST /api/v1/analysis/custom - Custom analysis
    • GET /api/v1/analysis - Get analysis
  • Organization:

    • GET /api/v1/organizations/me - Get organization details
    • PUT /api/v1/organizations/me - Update organization

Testing

  1. Run unit tests:
pytest
  1. Run with coverage:
pytest --cov=app tests/

Client Integration

JavaScript Snippet

Add this to your website:

<script>
  (function(w,d,s,o,f,js,fjs){
    w['Analytics']=o;w[o]=w[o]||function(){
    (w[o].q=w[o].q||[]).push(arguments)};
    js=d.createElement(s),fjs=d.getElementsByTagName(s)[0];
    js.id=o;js.src=f;js.async=1;fjs.parentNode.insertBefore(js,fjs);
  }(window,document,'script','ana','https://your-domain.com/tracker.js'));
  
  ana('init', 'YOUR_ORG_ID');
</script>

Development

  1. Start services in development mode:
docker-compose -f docker-compose.dev.yml up -d
  1. Run the FastAPI server with auto-reload:
uvicorn main:app --reload

Deployment

  1. Build production images:
docker-compose -f docker-compose.prod.yml build
  1. Deploy:
docker-compose -f docker-compose.prod.yml up -d

Monitoring

  • Service health: http://localhost:8000/health
  • Metrics: http://localhost:8000/metrics
  • Logs: docker-compose logs -f

Plans and Limits

  • Free:

    • 10,000 events/month
    • 30 days retention
    • Basic analytics
  • Starter:

    • 100,000 events/month
    • 90 days retention
    • Advanced analytics
  • Enterprise:

    • Unlimited events
    • 365 days retention
    • Custom analytics
    • Priority support

Contributing

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

License

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

Support

For support, email support@yourcompany.com or open an issue in the GitHub repository.

Acknowledgments

  • FastAPI
  • PostgreSQL
  • Redis
  • DeepSeek
  • All other open-source contributors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors