2025-06-05 14:29:01 +00:00

130 lines
3.4 KiB
Markdown

# NoteTaker API
A full-featured Note Taking API built with FastAPI and SQLite that allows users to create, manage, and organize their notes.
## Features
- User authentication with JWT
- Create, read, update, and delete notes
- Tag notes for better organization
- Archive and pin notes
- Search functionality for notes
- RESTful API with Swagger documentation
## Tech Stack
- **Backend Framework**: FastAPI
- **Database**: SQLite with SQLAlchemy ORM
- **Authentication**: JWT (JSON Web Tokens)
- **Migration Tool**: Alembic
- **Documentation**: Swagger UI, ReDoc
## Getting Started
### Prerequisites
- Python 3.8+
- pip
### Installation
1. Clone the repository:
```bash
git clone <repository-url>
cd notetaker-api
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Run database migrations:
```bash
alembic upgrade head
```
4. Run the development server:
```bash
uvicorn main:app --reload
```
The API will be available at `http://localhost:8000`
### Environment Variables
Set the following environment variables for production:
- `SECRET_KEY`: A secret key for JWT token generation
- `ALGORITHM`: The algorithm used for JWT encoding (default: "HS256")
- `ACCESS_TOKEN_EXPIRE_MINUTES`: Minutes until a token expires (default: 10080 - 7 days)
## API Documentation
The API documentation is available at:
- Swagger UI: `http://localhost:8000/docs`
- ReDoc: `http://localhost:8000/redoc`
## Database Schema
### User
- id (string): UUID primary key
- email (string): Unique email address
- hashed_password (string): Securely hashed password
- full_name (string): User's full name
- profile_image (string): Profile image filename
- is_active (boolean): Whether the user is active
- is_superuser (boolean): Admin status
- created_at (datetime): Account creation timestamp
- updated_at (datetime): Last update timestamp
### Note
- id (string): UUID primary key
- title (string): Note title
- content (text): Note content
- is_archived (boolean): Archive status
- is_pinned (boolean): Pin status
- user_id (string): Foreign key to User
- created_at (datetime): Creation timestamp
- updated_at (datetime): Last update timestamp
### Tag
- id (string): UUID primary key
- name (string): Tag name
- color (string): Hex color code
- created_at (datetime): Creation timestamp
### NoteTag
- id (string): UUID primary key
- note_id (string): Foreign key to Note
- tag_id (string): Foreign key to Tag
- created_at (datetime): Creation timestamp
## API Endpoints
### Authentication
- `POST /api/v1/auth/login`: Login with username and password
- `POST /api/v1/auth/register`: Register a new user
### Users
- `GET /api/v1/users/me`: Get current user info
- `PUT /api/v1/users/me`: Update current user info
- `POST /api/v1/users/me/profile-image`: Upload profile image
### Notes
- `GET /api/v1/notes`: List user notes
- `GET /api/v1/notes/search`: Search notes
- `POST /api/v1/notes`: Create a new note
- `GET /api/v1/notes/{note_id}`: Get a specific note
- `PUT /api/v1/notes/{note_id}`: Update a note
- `DELETE /api/v1/notes/{note_id}`: Delete a note
- `PATCH /api/v1/notes/{note_id}/archive`: Archive/unarchive a note
- `PATCH /api/v1/notes/{note_id}/pin`: Pin/unpin a note
### Tags
- `GET /api/v1/tags`: List all tags
- `POST /api/v1/tags`: Create a new tag
- `GET /api/v1/tags/{tag_id}`: Get a specific tag
- `PUT /api/v1/tags/{tag_id}`: Update a tag
- `DELETE /api/v1/tags/{tag_id}`: Delete a tag