# bob13th-queue/ctf architecture

> Architecture diagram of the GitHub repository bob13th-queue/ctf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bob13th-queue/ctf
- Repository: https://github.com/bob13th-queue/ctf

## Overview

##### Main Components

a) API Layer (FastAPI Application)
- This as the top-level component
- Three main service modules: Auth, User, and Note

b) Service Layer
- Create three main service blocks:
- Authentication Service (from service/auth)
- User Service (from service/user)
- Service (from service/note)
- Each service should show its three components:
- Routes (API endpoints)
- CRUD operations
- Schema definitions

c) Database Layer
- SQLite database (ctf.db)
- Connection to database models

d) Utility Services
- OAuth implementation
- Password hashing service
- As supporting components

##### Component Relationships

**┌─────────────────────────────────────────────┐**
- FastAPI App                  │
- (Main Application Entry Point)        │
- ┬───────────────────────────┘
- ↓
**┌─────────────────────────────────────────────┐**
- Service Layer                   │
- ┬───────────────┬─────────────┤
- Auth Service │  User Service │ Note Service │
- Routes     │  - Routes     │ - Routes     │
- CRUD       │  - CRUD       │ - CRUD      │
- Schema     │  - Schema     │ - Schema    │
- ┬───────┴───────┬───────┴──────┬──────┘
- ↓               ↓               ↓
**┌─────────────────────────────────────────────┐**
- Database Layer                  │
- (SQLite - ctf.db)                │
- Database Models                  │
- ┘
- ↑               ↑
**┌───────┴───────┬───────┴───────┐**
- OAuth Utils  │ Password Hash │
- ┴───────────────┘

##### Additional Elements

a) Configuration:
- Core/config.py as a configuration component
- It to all relevant services

b) Docker Container:
- Exposed port (8000)

##### Important Notes

- Version information for key components
- FastAPI swagger documentation endpoint
- Database connection pool
- Authentication flow paths
- Error handling paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Docker["Docker Container"]
        direction TB
        
        API[FastAPI Application]:::api
        click API "https://github.com/BoB13th-queue/ctf/blob/main/main.py"
        
        subgraph Services["Service Layer"]
            direction TB
            
            subgraph AuthService["Authentication Service"]
                direction TB
                AuthRoutes[Routes]:::routes
                AuthCRUD[CRUD Operations]:::crud
                AuthSchema[Schema]:::schema
                click AuthService "https://github.com/BoB13th-queue/ctf/tree/main/service/auth/"
                click AuthRoutes "https://github.com/BoB13th-queue/ctf/blob/main/service/auth/route.py"
                click AuthCRUD "https://github.com/BoB13th-queue/ctf/blob/main/service/auth/crud.py"
                click AuthSchema "https://github.com/BoB13th-queue/ctf/blob/main/service/auth/schema.py"
            end
            
            subgraph UserService["User Service"]
                direction TB
                UserRoutes[Routes]:::routes
                UserCRUD[CRUD Operations]:::crud
                UserSchema[Schema]:::schema
                click UserService "https://github.com/BoB13th-queue/ctf/tree/main/service/user/"
                click UserRoutes "https://github.com/BoB13th-queue/ctf/blob/main/service/user/route.py"
                click UserCRUD "https://github.com/BoB13th-queue/ctf/blob/main/service/user/crud.py"
                click UserSchema "https://github.com/BoB13th-queue/ctf/blob/main/service/user/schema.py"
            end
            
            subgraph NoteService["Note Service"]
                direction TB
                NoteRoutes[Routes]:::routes
                NoteCRUD[CRUD Operations]:::crud
                NoteSchema[Schema]:::schema
                click NoteService "https://github.com/BoB13th-queue/ctf/tree/main/service/note/"
                click NoteRoutes "https://github.com/BoB13th-queue/ctf/blob/main/service/note/route.py"
                click NoteCRUD "https://github.com/BoB13th-queue/ctf/blob/main/service/note/crud.py"
                click NoteSchema "https://github.com/BoB13th-queue/ctf/blob/main/service/note/schema.py"
            end
        end
        
        subgraph DB["Database Layer"]
            direction TB
            SQLite[(SQLite Database)]:::database
            DBConn[Database Connection]:::database
            DBModels[Database Models]:::database
            click SQLite "https://github.com/BoB13th-queue/ctf/blob/main/ctf.db"
            click DBConn "https://github.com/BoB13th-queue/ctf/blob/main/database/database.py"
            click DBModels "https://github.com/BoB13th-queue/ctf/blob/main/database/models.py"
        end
        
        subgraph Utils["Utility Services"]
            direction TB
            OAuth[OAuth Implementation]:::utility
            PassHash[Password Hash Service]:::utility
            Config[Configuration]:::utility
            click OAuth "https://github.com/BoB13th-queue/ctf/blob/main/utils/oauth.py"
            click PassHash "https://github.com/BoB13th-queue/ctf/blob/main/utils/passHash.py"
            click Config "https://github.com/BoB13th-queue/ctf/blob/main/core/config.py"
        end
        
        click Docker "https://github.com/BoB13th-queue/ctf/tree/main/dockerfile"
    end
    
    %% Connections
    API --> AuthService
    API --> UserService
    API --> NoteService
    
    AuthService --> DB
    UserService --> DB
    NoteService --> DB
    
    AuthService --> OAuth
    AuthService --> PassHash
    
    %% Styles
    classDef api fill:#2374ab
    classDef routes fill:#48a9a6
    classDef crud fill:#4ec5c1
    classDef schema fill:#47cacc
    classDef database fill:#e4cc37
    classDef utility fill:#9d9d9d
    
    %% Legend
    subgraph Legend
        direction TB
        API_L[API Layer]:::api
        Routes_L[Routes]:::routes
        CRUD_L[CRUD Operations]:::crud
        Schema_L[Schema]:::schema
        DB_L[(Database)]:::database
        Util_L[Utilities]:::utility
    end
```
