# AccessNode Database Manager

A secure and flexible database management system built with FastAPI that supports multiple database types and provides user authentication.

## Features

- 🔐 Secure user authentication with JWT tokens
- 🗄️ Support for multiple database types:
  - PostgreSQL
  - MySQL
  - MongoDB
- 🔒 Encrypted database credentials
- 🚀 Async/await support
- 📝 Comprehensive API documentation
- ✅ Extensive test coverage

## Installation

```bash
pip install accessnode-db-manager
```

## Quick Start

```python
from fastapi import FastAPI
from accessnode import AccessNode

# Initialize database connection
db = AccessNode(
    db_type="postgres",
    database="your_db",
    host="localhost",
    port=5432,
    username="user",
    password="pass"
)

# Execute queries
results = db.raw_query("SELECT * FROM your_table")
```

## API Documentation

After starting the server, visit `/docs` for the interactive API documentation.

### Key Endpoints

- `POST /user/register` - Register a new user
- `POST /user/token` - Login and get access token
- `POST /user/databases/setup` - Configure a new database connection
- `POST /user/database/{db_id}/query` - Execute database queries

## Development

1. Clone the repository
2. Install dependencies:
   ```bash
   pip install -e ".[dev]"
   ```
3. Run tests:
   ```bash
   pytest
   ```

## Security

- All passwords are hashed using bcrypt
- Database credentials are encrypted at rest
- JWT tokens for authentication
- CORS protection enabled

## Contributing

1. Fork the repository
2. Create a feature branch
3. Commit your changes
4. Push to the branch
5. Create a Pull Request

## License

MIT License - see LICENSE file for details