# ah-oztrk/socialsense architecture

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

- Interactive diagram: https://gitdiagram.com/ah-oztrk/socialsense
- Repository: https://github.com/ah-oztrk/socialsense

## Overview

##### Project type and purpose
- This is a full-stack “SocialSense” application:
- Back-end API built with Python/FastAPI (folder `app/`)
- Mobile/React-based front-end built with Expo/TypeScript (folder `social-sense/`)
- A relational database (e.g. PostgreSQL) accessed via SQLAlchemy or similar

##### File structure
- Top-level separation:
- `app/` – FastAPI server code (API routers, core logic, DB, models/schemas)
- `social-sense/` – Expo/React Native front-end (App.tsx, app routes, components, assets, hooks)
- `tests/` – Python unit tests for back-end routes
- Within `app/`:
- `api/routes/` – endpoint definitions (auth, forum, history, query, user)
- `core/` – application-wide logic (authentication, security utilities)
- `db/` – database connection and session management
- `models/` & `schemas/` – ORM models vs. Pydantic schemas for request/response
- `main.py` – FastAPI application entrypoint
- Within `social-sense/`:
- `app/(tabs)` – Expo Router tab-based screens
- `components/` – reusable UI pieces and tests
- `assets/`, `constants/`, Tailwind/metro configs

##### README
- It simply names the project “SocialSense,” so we infer the domain is a social or community-driven mobile application with forum and query/history features.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Client Layer
    subgraph "Mobile Client" 
        direction TB
        MC_Entry["Expo Entrypoint\nApp.tsx"]:::frontend
        MC_Screens["Client Screens\n(app/(tabs)/)"]:::frontend
        MC_NotFound["Not-Found & Root Layout"]:::frontend
        MC_Components["Shared UI Components"]:::frontend
        MC_Hooks["Custom Hooks"]:::frontend
        MC_Assets["Assets (fonts & images)"]:::frontend
        MC_Configs["Global Styles & Configs"]:::frontend
    end

    %% Server Layer
    subgraph "API Server" 
        direction TB
        API_Main["FastAPI Entrypoint\nmain.py"]:::api
        subgraph "Routers"
            direction TB
            Auth_Router["Auth Router"]:::api
            Forum_Router["Forum Router"]:::api
            History_Router["History Router"]:::api
            Query_Router["Query Router"]:::api
            User_Router["User Router"]:::api
        end
        subgraph "Core Services"
            direction TB
            Auth_Service["Auth Service"]:::service
            Security_Service["Security Service"]:::service
        end
        subgraph "Data Layer"
            direction TB
            DB_Conn["Database Connection\n& Session"]:::data
            subgraph "ORM Models"
                direction TB
                Model_Forum["Forum Model"]:::data
                Model_History["History Model"]:::data
                Model_Query["Query Model"]:::data
                Model_User["User Model"]:::data
            end
            subgraph "Pydantic Schemas"
                direction TB
                Schema_Forum["Forum Schema"]:::data
                Schema_History["History Schema"]:::data
                Schema_Query["Query Schema"]:::data
                Schema_User["User Schema"]:::data
            end
        end
    end

    %% Database
    Database["PostgreSQL Database"]:::database

    %% Tests
    subgraph "Back-end Tests"
        direction TB
        Test_Auth["test_auth.py"]:::test
        Test_Forum["test_forum.py"]:::test
        Test_History["test_history.py"]:::test
        Test_Queries["test_queries.py"]:::test
    end

    %% External Protocols
    MC_Entry -->|HTTPS| API_Main
    API_Main --> Auth_Router
    API_Main --> Forum_Router
    API_Main --> History_Router
    API_Main --> Query_Router
    API_Main --> User_Router

    Auth_Router --> Auth_Service
    Auth_Router --> Security_Service
    Forum_Router --> DB_Conn
    History_Router --> DB_Conn
    Query_Router --> DB_Conn
    User_Router --> DB_Conn

    Auth_Service --> DB_Conn
    Security_Service --> DB_Conn

    DB_Conn --> Model_Forum
    DB_Conn --> Model_History
    DB_Conn --> Model_Query
    DB_Conn --> Model_User

    Model_Forum --> Schema_Forum
    Model_History --> Schema_History
    Model_Query --> Schema_Query
    Model_User --> Schema_User

    DB_Conn -->|SQL/TCP| Database

    API_Main --> Back_End_Tests
    Auth_Router --> Test_Auth
    Forum_Router --> Test_Forum
    History_Router --> Test_History
    Query_Router --> Test_Queries

    %% Click Events - Mobile Client
    click MC_Entry "https://github.com/ah-oztrk/socialsense/blob/main/social-sense/App.tsx"
    click MC_Screens "https://github.com/ah-oztrk/socialsense/tree/main/social-sense/app/(tabs)/"
    click MC_NotFound "https://github.com/ah-oztrk/socialsense/blob/main/social-sense/app/+not-found.tsx"
    click MC_NotFound "https://github.com/ah-oztrk/socialsense/blob/main/social-sense/app/_layout.tsx"
    click MC_Components "https://github.com/ah-oztrk/socialsense/tree/main/social-sense/components/"
    click MC_Hooks "https://github.com/ah-oztrk/socialsense/tree/main/social-sense/hooks/"
    click MC_Assets "https://github.com/ah-oztrk/socialsense/tree/main/social-sense/assets/"
    click MC_Configs "https://github.com/ah-oztrk/socialsense/blob/main/social-sense/global.css"
    click MC_Configs "https://github.com/ah-oztrk/socialsense/blob/main/social-sense/tailwind.config.js"
    click MC_Configs "https://github.com/ah-oztrk/socialsense/blob/main/social-sense/metro.config.js"

    %% Click Events - Server
    click API_Main "https://github.com/ah-oztrk/socialsense/blob/main/app/main.py"
    click Auth_Router "https://github.com/ah-oztrk/socialsense/blob/main/app/api/routes/auth.py"
    click Forum_Router "https://github.com/ah-oztrk/socialsense/blob/main/app/api/routes/forum.py"
    click History_Router "https://github.com/ah-oztrk/socialsense/blob/main/app/api/routes/history.py"
    click Query_Router "https://github.com/ah-oztrk/socialsense/blob/main/app/api/routes/query.py"
    click User_Router "https://github.com/ah-oztrk/socialsense/blob/main/app/api/routes/user.py"
    click Auth_Service "https://github.com/ah-oztrk/socialsense/blob/main/app/core/auth.py"
    click Security_Service "https://github.com/ah-oztrk/socialsense/blob/main/app/core/security.py"
    click DB_Conn "https://github.com/ah-oztrk/socialsense/blob/main/app/db/database.py"
    click Model_Forum "https://github.com/ah-oztrk/socialsense/blob/main/app/models/forum.py"
    click Model_History "https://github.com/ah-oztrk/socialsense/blob/main/app/models/history.py"
    click Model_Query "https://github.com/ah-oztrk/socialsense/blob/main/app/models/query.py"
    click Model_User "https://github.com/ah-oztrk/socialsense/blob/main/app/models/user.py"
    click Schema_Forum "https://github.com/ah-oztrk/socialsense/blob/main/app/schemas/forum.py"
    click Schema_History "https://github.com/ah-oztrk/socialsense/blob/main/app/schemas/history.py"
    click Schema_Query "https://github.com/ah-oztrk/socialsense/blob/main/app/schemas/query.py"
    click Schema_User "https://github.com/ah-oztrk/socialsense/blob/main/app/schemas/user.py"

    %% Click Events - Tests
    click Test_Auth "https://github.com/ah-oztrk/socialsense/blob/main/tests/test_auth.py"
    click Test_Forum "https://github.com/ah-oztrk/socialsense/blob/main/tests/test_forum.py"
    click Test_History "https://github.com/ah-oztrk/socialsense/blob/main/tests/test_history.py"
    click Test_Queries "https://github.com/ah-oztrk/socialsense/blob/main/tests/test_queries.py"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0284C7,stroke-width:1px;
    classDef api fill:#DFFFD0,stroke:#4CAF50,stroke-width:1px;
    classDef service fill:#FFF5BA,stroke:#F59E0B,stroke-width:1px;
    classDef data fill:#FFE4E1,stroke:#EF4444,stroke-width:1px;
    classDef database fill:#EDE9FE,stroke:#8B5CF6,stroke-width:1px,shape:cylinder;
    classDef test fill:#F3F4F6,stroke:#6B7280,stroke-width:1px;
```
