typefaster-cli 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. typefaster_cli-0.1.0/.dockerignore +18 -0
  2. typefaster_cli-0.1.0/.env.example +13 -0
  3. typefaster_cli-0.1.0/.github/ISSUE_TEMPLATE/bug_report.yml +65 -0
  4. typefaster_cli-0.1.0/.github/ISSUE_TEMPLATE/config.yml +5 -0
  5. typefaster_cli-0.1.0/.github/ISSUE_TEMPLATE/feature_request.yml +36 -0
  6. typefaster_cli-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +19 -0
  7. typefaster_cli-0.1.0/.github/workflows/ci.yml +84 -0
  8. typefaster_cli-0.1.0/.github/workflows/release.yml +55 -0
  9. typefaster_cli-0.1.0/.gitignore +31 -0
  10. typefaster_cli-0.1.0/CONTRIBUTING.md +73 -0
  11. typefaster_cli-0.1.0/LICENSE +21 -0
  12. typefaster_cli-0.1.0/Makefile +68 -0
  13. typefaster_cli-0.1.0/PKG-INFO +168 -0
  14. typefaster_cli-0.1.0/README.md +136 -0
  15. typefaster_cli-0.1.0/client/Dockerfile +20 -0
  16. typefaster_cli-0.1.0/client/typefaster/__init__.py +3 -0
  17. typefaster_cli-0.1.0/client/typefaster/__main__.py +8 -0
  18. typefaster_cli-0.1.0/client/typefaster/assets/__init__.py +1 -0
  19. typefaster_cli-0.1.0/client/typefaster/assets/quotes.json +2642 -0
  20. typefaster_cli-0.1.0/client/typefaster/cli.py +196 -0
  21. typefaster_cli-0.1.0/client/typefaster/domain/__init__.py +1 -0
  22. typefaster_cli-0.1.0/client/typefaster/domain/anti_cheat.py +46 -0
  23. typefaster_cli-0.1.0/client/typefaster/domain/calculators.py +47 -0
  24. typefaster_cli-0.1.0/client/typefaster/domain/errors.py +19 -0
  25. typefaster_cli-0.1.0/client/typefaster/domain/ghost.py +61 -0
  26. typefaster_cli-0.1.0/client/typefaster/domain/models.py +186 -0
  27. typefaster_cli-0.1.0/client/typefaster/domain/typing_engine.py +150 -0
  28. typefaster_cli-0.1.0/client/typefaster/infra/__init__.py +1 -0
  29. typefaster_cli-0.1.0/client/typefaster/infra/clock.py +36 -0
  30. typefaster_cli-0.1.0/client/typefaster/infra/config.py +41 -0
  31. typefaster_cli-0.1.0/client/typefaster/infra/db.py +31 -0
  32. typefaster_cli-0.1.0/client/typefaster/infra/migrations.py +106 -0
  33. typefaster_cli-0.1.0/client/typefaster/infra/paths.py +35 -0
  34. typefaster_cli-0.1.0/client/typefaster/infra/quote_loader.py +53 -0
  35. typefaster_cli-0.1.0/client/typefaster/infra/replay_store.py +16 -0
  36. typefaster_cli-0.1.0/client/typefaster/infra/repository.py +63 -0
  37. typefaster_cli-0.1.0/client/typefaster/infra/sqlite_repository.py +360 -0
  38. typefaster_cli-0.1.0/client/typefaster/net/__init__.py +1 -0
  39. typefaster_cli-0.1.0/client/typefaster/net/api.py +103 -0
  40. typefaster_cli-0.1.0/client/typefaster/net/commands.py +188 -0
  41. typefaster_cli-0.1.0/client/typefaster/net/token_store.py +46 -0
  42. typefaster_cli-0.1.0/client/typefaster/services/__init__.py +1 -0
  43. typefaster_cli-0.1.0/client/typefaster/services/container.py +42 -0
  44. typefaster_cli-0.1.0/client/typefaster/services/daily_service.py +23 -0
  45. typefaster_cli-0.1.0/client/typefaster/services/ghost_service.py +50 -0
  46. typefaster_cli-0.1.0/client/typefaster/services/profile_service.py +18 -0
  47. typefaster_cli-0.1.0/client/typefaster/services/race_service.py +152 -0
  48. typefaster_cli-0.1.0/client/typefaster/services/stats_service.py +52 -0
  49. typefaster_cli-0.1.0/client/typefaster/ui/__init__.py +1 -0
  50. typefaster_cli-0.1.0/client/typefaster/ui/app.py +93 -0
  51. typefaster_cli-0.1.0/client/typefaster/ui/online_app.py +24 -0
  52. typefaster_cli-0.1.0/client/typefaster/ui/screens/__init__.py +1 -0
  53. typefaster_cli-0.1.0/client/typefaster/ui/screens/_base.py +30 -0
  54. typefaster_cli-0.1.0/client/typefaster/ui/screens/daily.py +64 -0
  55. typefaster_cli-0.1.0/client/typefaster/ui/screens/help.py +26 -0
  56. typefaster_cli-0.1.0/client/typefaster/ui/screens/history.py +34 -0
  57. typefaster_cli-0.1.0/client/typefaster/ui/screens/leaderboard.py +52 -0
  58. typefaster_cli-0.1.0/client/typefaster/ui/screens/main_menu.py +96 -0
  59. typefaster_cli-0.1.0/client/typefaster/ui/screens/online_race.py +241 -0
  60. typefaster_cli-0.1.0/client/typefaster/ui/screens/practice.py +57 -0
  61. typefaster_cli-0.1.0/client/typefaster/ui/screens/profile.py +28 -0
  62. typefaster_cli-0.1.0/client/typefaster/ui/screens/race.py +238 -0
  63. typefaster_cli-0.1.0/client/typefaster/ui/screens/results.py +89 -0
  64. typefaster_cli-0.1.0/client/typefaster/ui/screens/settings.py +81 -0
  65. typefaster_cli-0.1.0/client/typefaster/ui/screens/stats.py +65 -0
  66. typefaster_cli-0.1.0/client/typefaster/ui/theme.py +82 -0
  67. typefaster_cli-0.1.0/client/typefaster/ui/widgets/__init__.py +1 -0
  68. typefaster_cli-0.1.0/client/typefaster/ui/widgets/bigtext.py +39 -0
  69. typefaster_cli-0.1.0/client/typefaster/ui/widgets/live_stats.py +19 -0
  70. typefaster_cli-0.1.0/client/typefaster/ui/widgets/progress_bars.py +44 -0
  71. typefaster_cli-0.1.0/client/typefaster/ui/widgets/typing_field.py +28 -0
  72. typefaster_cli-0.1.0/docker-compose.yml +68 -0
  73. typefaster_cli-0.1.0/docs/RELEASING.md +173 -0
  74. typefaster_cli-0.1.0/docs/api-spec.md +86 -0
  75. typefaster_cli-0.1.0/docs/architecture.md +123 -0
  76. typefaster_cli-0.1.0/docs/deployment.md +122 -0
  77. typefaster_cli-0.1.0/docs/redis-schema.md +45 -0
  78. typefaster_cli-0.1.0/docs/roadmap.md +48 -0
  79. typefaster_cli-0.1.0/docs/sqlite-schema.md +148 -0
  80. typefaster_cli-0.1.0/docs/ui-design.md +201 -0
  81. typefaster_cli-0.1.0/docs/websocket-protocol.md +65 -0
  82. typefaster_cli-0.1.0/infra/README.md +16 -0
  83. typefaster_cli-0.1.0/infra/nginx/nginx.conf +65 -0
  84. typefaster_cli-0.1.0/infra/redis/redis.conf +21 -0
  85. typefaster_cli-0.1.0/packaging/homebrew/typefaster.rb +36 -0
  86. typefaster_cli-0.1.0/pyproject.toml +118 -0
  87. typefaster_cli-0.1.0/scripts/seed_quotes.py +373 -0
  88. typefaster_cli-0.1.0/server/Dockerfile +32 -0
  89. typefaster_cli-0.1.0/server/app/__init__.py +3 -0
  90. typefaster_cli-0.1.0/server/app/config.py +21 -0
  91. typefaster_cli-0.1.0/server/app/deps.py +56 -0
  92. typefaster_cli-0.1.0/server/app/logging_config.py +27 -0
  93. typefaster_cli-0.1.0/server/app/main.py +90 -0
  94. typefaster_cli-0.1.0/server/app/quotes.py +52 -0
  95. typefaster_cli-0.1.0/server/app/redis_keys.py +55 -0
  96. typefaster_cli-0.1.0/server/app/repositories.py +200 -0
  97. typefaster_cli-0.1.0/server/app/routers/__init__.py +1 -0
  98. typefaster_cli-0.1.0/server/app/routers/auth.py +65 -0
  99. typefaster_cli-0.1.0/server/app/routers/health.py +27 -0
  100. typefaster_cli-0.1.0/server/app/routers/leaderboards.py +40 -0
  101. typefaster_cli-0.1.0/server/app/routers/lobbies.py +86 -0
  102. typefaster_cli-0.1.0/server/app/security.py +49 -0
  103. typefaster_cli-0.1.0/server/app/ws/__init__.py +1 -0
  104. typefaster_cli-0.1.0/server/app/ws/manager.py +295 -0
  105. typefaster_cli-0.1.0/server/pyproject.toml +40 -0
  106. typefaster_cli-0.1.0/server/tests/__init__.py +0 -0
  107. typefaster_cli-0.1.0/server/tests/conftest.py +37 -0
  108. typefaster_cli-0.1.0/server/tests/test_auth.py +57 -0
  109. typefaster_cli-0.1.0/server/tests/test_health_leaderboards.py +37 -0
  110. typefaster_cli-0.1.0/server/tests/test_lobbies.py +62 -0
  111. typefaster_cli-0.1.0/server/tests/test_scoring_anticheat.py +68 -0
  112. typefaster_cli-0.1.0/server/tests/test_ws_race.py +73 -0
  113. typefaster_cli-0.1.0/shared/pyproject.toml +13 -0
  114. typefaster_cli-0.1.0/shared/typefaster_shared/__init__.py +3 -0
  115. typefaster_cli-0.1.0/shared/typefaster_shared/anti_cheat.py +60 -0
  116. typefaster_cli-0.1.0/shared/typefaster_shared/dto.py +56 -0
  117. typefaster_cli-0.1.0/shared/typefaster_shared/events.py +99 -0
  118. typefaster_cli-0.1.0/shared/typefaster_shared/scoring.py +30 -0
  119. typefaster_cli-0.1.0/tests/conftest.py +33 -0
  120. typefaster_cli-0.1.0/tests/fixtures/.gitkeep +0 -0
  121. typefaster_cli-0.1.0/tests/integration/test_container_and_cli.py +94 -0
  122. typefaster_cli-0.1.0/tests/integration/test_migrations.py +26 -0
  123. typefaster_cli-0.1.0/tests/integration/test_profile_stats.py +69 -0
  124. typefaster_cli-0.1.0/tests/integration/test_race_service.py +92 -0
  125. typefaster_cli-0.1.0/tests/integration/test_race_timing.py +96 -0
  126. typefaster_cli-0.1.0/tests/integration/test_sqlite_repository.py +134 -0
  127. typefaster_cli-0.1.0/tests/integration/test_ui_smoke.py +55 -0
  128. typefaster_cli-0.1.0/tests/unit/test_anti_cheat.py +41 -0
  129. typefaster_cli-0.1.0/tests/unit/test_calculators.py +32 -0
  130. typefaster_cli-0.1.0/tests/unit/test_config.py +32 -0
  131. typefaster_cli-0.1.0/tests/unit/test_ghost.py +50 -0
  132. typefaster_cli-0.1.0/tests/unit/test_net.py +43 -0
  133. typefaster_cli-0.1.0/tests/unit/test_quote_loader.py +41 -0
  134. typefaster_cli-0.1.0/tests/unit/test_typing_engine.py +98 -0
@@ -0,0 +1,18 @@
1
+ **/__pycache__/
2
+ **/*.pyc
3
+ .venv/
4
+ venv/
5
+ .git/
6
+ .github/
7
+ .pytest_cache/
8
+ .mypy_cache/
9
+ .ruff_cache/
10
+ htmlcov/
11
+ .coverage
12
+ *.db
13
+ *.db-wal
14
+ *.db-shm
15
+ infra/nginx/certs/
16
+ docs/
17
+ tests/
18
+ server/tests/
@@ -0,0 +1,13 @@
1
+ # Copy to .env and adjust before `docker compose up`.
2
+
3
+ # REQUIRED: a long random string. Generate with: openssl rand -hex 32
4
+ TYPEFASTER_JWT_SECRET=
5
+
6
+ # Comma-separated allowed origins for CORS (use your domain in production).
7
+ TYPEFASTER_CORS_ORIGINS=*
8
+
9
+ # Access token lifetime in minutes (default 1 day).
10
+ TYPEFASTER_ACCESS_TOKEN_MINUTES=1440
11
+
12
+ # Host port to expose the server on for local dev (nginx handles prod).
13
+ SERVER_PORT=8000
@@ -0,0 +1,65 @@
1
+ name: 🐛 Bug report
2
+ description: Report something that doesn't work as expected
3
+ labels: ["bug"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: Thanks for the report! Please fill in the details below.
8
+ - type: textarea
9
+ id: what-happened
10
+ attributes:
11
+ label: What happened?
12
+ description: A clear description of the bug, including any incorrect numbers (WPM/accuracy/time).
13
+ placeholder: "e.g. Quick Race showed 2222 WPM after a normal run…"
14
+ validations:
15
+ required: true
16
+ - type: textarea
17
+ id: steps
18
+ attributes:
19
+ label: Steps to reproduce
20
+ placeholder: |
21
+ 1. Run `typefaster`
22
+ 2. Choose Quick Race
23
+ 3. Type the quote normally
24
+ 4. See …
25
+ validations:
26
+ required: true
27
+ - type: textarea
28
+ id: expected
29
+ attributes:
30
+ label: Expected behavior
31
+ validations:
32
+ required: true
33
+ - type: dropdown
34
+ id: area
35
+ attributes:
36
+ label: Area
37
+ options:
38
+ - Offline race / timing / WPM
39
+ - Ghost races
40
+ - Stats / history / leaderboard
41
+ - Daily challenge
42
+ - Online multiplayer (server/lobbies)
43
+ - Install / packaging
44
+ - Other
45
+ validations:
46
+ required: true
47
+ - type: input
48
+ id: version
49
+ attributes:
50
+ label: Version
51
+ description: Output of `typefaster version`
52
+ placeholder: "typefaster 0.1.0"
53
+ - type: textarea
54
+ id: env
55
+ attributes:
56
+ label: Environment
57
+ description: OS, terminal emulator, Python version (`python3 --version`).
58
+ placeholder: "macOS 14, iTerm2, Python 3.12.3"
59
+ validations:
60
+ required: true
61
+ - type: textarea
62
+ id: logs
63
+ attributes:
64
+ label: Logs / traceback (optional)
65
+ render: shell
@@ -0,0 +1,5 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: 💬 Questions & discussion
4
+ url: https://github.com/Anoshor/typefaster-cli/discussions
5
+ about: Ask questions, share scores, or propose ideas before filing an issue.
@@ -0,0 +1,36 @@
1
+ name: 💡 Feature request
2
+ description: Suggest an idea or improvement
3
+ labels: ["enhancement"]
4
+ body:
5
+ - type: textarea
6
+ id: problem
7
+ attributes:
8
+ label: Problem / motivation
9
+ description: What are you trying to do, and what's missing or awkward today?
10
+ validations:
11
+ required: true
12
+ - type: textarea
13
+ id: proposal
14
+ attributes:
15
+ label: Proposed solution
16
+ description: What would you like to see? Mockups / example commands welcome.
17
+ validations:
18
+ required: true
19
+ - type: textarea
20
+ id: alternatives
21
+ attributes:
22
+ label: Alternatives considered
23
+ - type: dropdown
24
+ id: area
25
+ attributes:
26
+ label: Area
27
+ options:
28
+ - Gameplay / modes
29
+ - Ghosts
30
+ - Stats / progression
31
+ - Online multiplayer
32
+ - Terminal UI / UX
33
+ - Packaging / distribution
34
+ - Other
35
+ validations:
36
+ required: true
@@ -0,0 +1,19 @@
1
+ # Summary
2
+
3
+ <!-- What does this PR do and why? -->
4
+
5
+ ## Changes
6
+
7
+ -
8
+
9
+ ## Checklist
10
+
11
+ - [ ] `make check` passes (ruff + mypy + pytest)
12
+ - [ ] Added/updated tests for the change
13
+ - [ ] Updated docs if behavior or commands changed
14
+ - [ ] (If the server changed) `cd server && pytest` passes
15
+ - [ ] (If quotes changed) regenerated `quotes.json` via `scripts/seed_quotes.py`
16
+
17
+ ## Related issues
18
+
19
+ <!-- e.g. Closes #123 -->
@@ -0,0 +1,84 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ concurrency:
9
+ group: ${{ github.workflow }}-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ jobs:
13
+ quality:
14
+ name: lint · type · test
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ python-version: ["3.11", "3.12"]
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+
23
+ - name: Set up Python ${{ matrix.python-version }}
24
+ uses: actions/setup-python@v5
25
+ with:
26
+ python-version: ${{ matrix.python-version }}
27
+ cache: pip
28
+
29
+ - name: Install
30
+ run: python -m pip install -e ".[dev]"
31
+
32
+ - name: Lint (ruff)
33
+ run: ruff check client tests
34
+
35
+ - name: Format check (black)
36
+ run: black --check client tests
37
+
38
+ - name: Type check (mypy)
39
+ run: mypy
40
+
41
+ - name: Test (pytest)
42
+ run: pytest --cov=typefaster --cov-report=xml
43
+
44
+ - name: Upload coverage artifact
45
+ if: matrix.python-version == '3.12'
46
+ uses: actions/upload-artifact@v4
47
+ with:
48
+ name: coverage
49
+ path: coverage.xml
50
+
51
+ server:
52
+ name: server lint · test
53
+ runs-on: ubuntu-latest
54
+ steps:
55
+ - uses: actions/checkout@v4
56
+ - uses: actions/setup-python@v5
57
+ with:
58
+ python-version: "3.12"
59
+ cache: pip
60
+ - name: Install shared + server
61
+ run: |
62
+ python -m pip install ./shared
63
+ python -m pip install "./server[dev]"
64
+ - name: Lint (ruff)
65
+ run: ruff check server shared --select E,F,I,UP,B --ignore UP042
66
+ - name: Test (pytest)
67
+ run: cd server && pytest
68
+
69
+ build:
70
+ name: build wheel
71
+ runs-on: ubuntu-latest
72
+ needs: [quality, server]
73
+ steps:
74
+ - uses: actions/checkout@v4
75
+ - uses: actions/setup-python@v5
76
+ with:
77
+ python-version: "3.12"
78
+ cache: pip
79
+ - run: python -m pip install build
80
+ - run: python -m build
81
+ - uses: actions/upload-artifact@v4
82
+ with:
83
+ name: dist
84
+ path: dist/*
@@ -0,0 +1,55 @@
1
+ name: Release
2
+
3
+ # Publishes to PyPI and creates a GitHub Release whenever you push a version tag
4
+ # (e.g. `git tag v0.1.0 && git push origin v0.1.0`).
5
+ #
6
+ # Uses PyPI Trusted Publishing (OIDC) — no API tokens stored in the repo. You
7
+ # must configure the trusted publisher once on PyPI (see docs/RELEASING.md).
8
+
9
+ on:
10
+ push:
11
+ tags: ["v*"]
12
+
13
+ permissions:
14
+ contents: write # create the GitHub Release
15
+ id-token: write # OIDC token for PyPI Trusted Publishing
16
+
17
+ jobs:
18
+ build:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: "3.12"
25
+ - run: python -m pip install build
26
+ - run: python -m build # creates dist/*.whl and dist/*.tar.gz
27
+ - run: python -m pip install twine && twine check dist/*
28
+ - uses: actions/upload-artifact@v4
29
+ with:
30
+ name: dist
31
+ path: dist/*
32
+
33
+ publish-pypi:
34
+ needs: build
35
+ runs-on: ubuntu-latest
36
+ environment: pypi # optional: add manual approval in repo settings
37
+ steps:
38
+ - uses: actions/download-artifact@v4
39
+ with:
40
+ name: dist
41
+ path: dist
42
+ - uses: pypa/gh-action-pypi-publish@release/v1
43
+
44
+ github-release:
45
+ needs: build
46
+ runs-on: ubuntu-latest
47
+ steps:
48
+ - uses: actions/download-artifact@v4
49
+ with:
50
+ name: dist
51
+ path: dist
52
+ - uses: softprops/action-gh-release@v2
53
+ with:
54
+ generate_release_notes: true
55
+ files: dist/*
@@ -0,0 +1,31 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+ .eggs/
8
+
9
+ # Virtual envs
10
+ .venv/
11
+ venv/
12
+ env/
13
+
14
+ # Tooling caches
15
+ .pytest_cache/
16
+ .mypy_cache/
17
+ .ruff_cache/
18
+ .coverage
19
+ htmlcov/
20
+ coverage.xml
21
+
22
+ # Local game data (SQLite lives in the OS data dir, but ignore stray copies)
23
+ *.db
24
+ *.db-wal
25
+ *.db-shm
26
+ typefaster.db*
27
+
28
+ # Editors / OS
29
+ .idea/
30
+ .vscode/
31
+ .DS_Store
@@ -0,0 +1,73 @@
1
+ # Contributing to TYPEFASTER-CLI
2
+
3
+ Thanks for your interest in improving TYPEFASTER! Contributions of all kinds are
4
+ welcome — bug reports, quotes, features, docs, and code.
5
+
6
+ ## Project layout
7
+
8
+ ```
9
+ client/typefaster/ the CLI app (domain · services · infra · ui · net · assets)
10
+ server/app/ online server (FastAPI · ws · repositories · security)
11
+ shared/ schemas, WS protocol, scoring, anti-cheat
12
+ tests/ client tests · server/tests/ server tests
13
+ docs/ architecture, schemas, protocol, deployment, releasing
14
+ ```
15
+
16
+ Architecture follows clean layering: **domain** (pure) ← **services** ←
17
+ **infra**/**ui**. The domain never imports Rich/Textual/SQLite. Please keep new
18
+ code in the right layer.
19
+
20
+ ## Development setup
21
+
22
+ Requires **Python 3.11+** (the repo is developed against 3.12).
23
+
24
+ ```bash
25
+ git clone https://github.com/Anoshor/typefaster-cli && cd typefaster-cli
26
+ python3.12 -m venv .venv && source .venv/bin/activate
27
+ make install # editable install + dev deps
28
+ make play # launch the game
29
+ ```
30
+
31
+ > The package lives at `client/typefaster`. The `Makefile` exports
32
+ > `PYTHONPATH=client`, so `make` targets always work regardless of how the
33
+ > editable install resolves on your OS. If you run tools directly, prefix with
34
+ > `PYTHONPATH=client`.
35
+
36
+ ## Before opening a PR
37
+
38
+ Run the full check suite — CI runs the same thing:
39
+
40
+ ```bash
41
+ make check # ruff + mypy + pytest (client)
42
+ cd server && pip install -e ".[dev]" && pytest # if you touched the server
43
+ ```
44
+
45
+ Quality gates (all must pass):
46
+ - **ruff** — lint + import sorting
47
+ - **black** — formatting (`make format` to auto-fix)
48
+ - **mypy --strict** — types (the `typefaster` package)
49
+ - **pytest** — tests; add/adjust tests for any behavior change
50
+
51
+ ## Guidelines
52
+
53
+ - **Keep the domain pure** and deterministic (time is injected via `Clock`).
54
+ - **Add tests** for new logic. UI gets Textual pilot smoke tests; logic gets
55
+ unit/integration tests.
56
+ - **Conventional, focused commits** and small PRs are easier to review.
57
+ - **Adding quotes?** Edit `scripts/seed_quotes.py`, run it, and commit the
58
+ regenerated `client/typefaster/assets/quotes.json`
59
+ (`python scripts/seed_quotes.py && python scripts/seed_quotes.py --check`).
60
+ - Don't commit generated artifacts (`dist/`, caches) — they're git-ignored.
61
+
62
+ ## Reporting bugs / requesting features
63
+
64
+ Use the issue templates (Bug report / Feature request). For race-result or
65
+ timing bugs, please include your terminal, OS, and the exact steps.
66
+
67
+ ## Code of conduct
68
+
69
+ Be respectful and constructive. We follow the spirit of the
70
+ [Contributor Covenant](https://www.contributor-covenant.org/).
71
+
72
+ By contributing, you agree your contributions are licensed under the project's
73
+ [MIT License](LICENSE).
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TYPEFASTER-CLI authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,68 @@
1
+ # TYPEFASTER-CLI — developer commands
2
+ # Phase 1 (offline) targets are active. `up`/`down` arrive with Phase 2 (Docker/Redis).
3
+
4
+ .DEFAULT_GOAL := help
5
+ PYTHON ?= python3
6
+
7
+ # Make the package importable from the monorepo layout (client/typefaster)
8
+ # regardless of how the editable install resolves paths on a given OS.
9
+ export PYTHONPATH := client
10
+
11
+ .PHONY: help install dev play test test-cov lint format typecheck check seed clean up down
12
+
13
+ help: ## Show this help
14
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
15
+ awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}'
16
+
17
+ install: ## Install package + dev deps in editable mode
18
+ $(PYTHON) -m pip install -e ".[dev]"
19
+
20
+ dev: install ## Alias for a full dev environment setup
21
+ @echo "Dev environment ready. Run 'make play' to start the game."
22
+
23
+ play: ## Launch the game (offline)
24
+ typefaster
25
+
26
+ test: ## Run the test suite
27
+ pytest
28
+
29
+ test-cov: ## Run tests with coverage report
30
+ pytest --cov=typefaster --cov-report=term-missing
31
+
32
+ lint: ## Ruff lint
33
+ ruff check client tests
34
+
35
+ format: ## Auto-format (black) + autofix (ruff)
36
+ black client tests
37
+ ruff check --fix client tests
38
+
39
+ typecheck: ## MyPy static type check
40
+ mypy
41
+
42
+ check: lint typecheck test ## Run lint + typecheck + tests (CI parity)
43
+
44
+ seed: ## Validate / (re)build the quotes dataset
45
+ $(PYTHON) scripts/seed_quotes.py
46
+
47
+ clean: ## Remove caches and build artifacts
48
+ rm -rf .pytest_cache .mypy_cache .ruff_cache htmlcov .coverage build dist *.egg-info
49
+ find . -type d -name __pycache__ -prune -exec rm -rf {} +
50
+
51
+ # ── Online stack (Phase 2) ─────────────────────────────────────────────
52
+ up: ## Start the online stack (redis + server) via Docker Compose
53
+ docker compose up -d --build
54
+
55
+ up-proxy: ## Start the full stack including the nginx TLS proxy
56
+ docker compose --profile proxy up -d --build
57
+
58
+ down: ## Stop the online stack
59
+ docker compose down
60
+
61
+ logs: ## Tail server logs
62
+ docker compose logs -f server
63
+
64
+ server-dev: ## Run the server locally (needs a local Redis on :6379)
65
+ cd server && uvicorn app.main:app --reload --port 8000
66
+
67
+ server-test: ## Run the server test suite
68
+ cd server && pytest
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: typefaster-cli
3
+ Version: 0.1.0
4
+ Summary: A terminal-first typing game inspired by MonkeyType and TypeRacer.
5
+ Project-URL: Homepage, https://github.com/Anoshor/typefaster-cli
6
+ Project-URL: Repository, https://github.com/Anoshor/typefaster-cli
7
+ Author: Anoshor Paul
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Keywords: cli,game,monkeytype,terminal,tui,typeracer,typing,wpm
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: End Users/Desktop
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Games/Entertainment
16
+ Requires-Python: >=3.11
17
+ Requires-Dist: httpx>=0.27
18
+ Requires-Dist: platformdirs>=4.2
19
+ Requires-Dist: rich>=13.7
20
+ Requires-Dist: textual>=0.60
21
+ Requires-Dist: typer>=0.12
22
+ Requires-Dist: websockets>=12.0
23
+ Provides-Extra: dev
24
+ Requires-Dist: black>=24.0; extra == 'dev'
25
+ Requires-Dist: mypy>=1.10; extra == 'dev'
26
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
27
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
28
+ Requires-Dist: pytest>=8.0; extra == 'dev'
29
+ Requires-Dist: ruff>=0.5; extra == 'dev'
30
+ Requires-Dist: textual-dev>=1.5; extra == 'dev'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # ⌨ TYPEFASTER-CLI
34
+
35
+ [![CI](https://github.com/Anoshor/typefaster-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/Anoshor/typefaster-cli/actions/workflows/ci.yml)
36
+ [![Python](https://img.shields.io/badge/python-3.11%2B-blue)](https://www.python.org/downloads/)
37
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green)](LICENSE)
38
+
39
+ A **terminal-first** typing game inspired by MonkeyType and TypeRacer.
40
+
41
+ > Not a web app. Not a browser game. Not a desktop GUI.
42
+ > A polished **Python terminal application** that works offline first, then scales to internet multiplayer.
43
+
44
+ ```bash
45
+ typefaster
46
+ ```
47
+
48
+ …and you're racing within seconds. No login, no server, no Docker, no internet required.
49
+
50
+ ---
51
+
52
+ ## Status
53
+
54
+ | Phase | Scope | State |
55
+ |-------|-------|-------|
56
+ | **Phase 1** | Offline experience: races, ghosts, profile, stats, history, daily challenge | ✅ **Implemented & tested** |
57
+ | **Phase 2** | Online multiplayer: FastAPI + Redis + WebSockets, auth, lobbies, leaderboards, anti-cheat, Docker | ✅ **Implemented & tested** |
58
+
59
+ Both phases are implemented. Offline play needs only `pip install`; online play
60
+ adds a Dockerized server (see [Online play](#online-play-phase-2)).
61
+
62
+ ---
63
+
64
+ ## What Phase 1 delivers
65
+
66
+ - **Instant offline races** — random quote, live WPM / accuracy / progress / timer.
67
+ - **30 / 60 / 120 second** race modes.
68
+ - **Ghost races** against your `personal-best`, `last`, or a `random` historical run, animated live.
69
+ - **Local profile & stats** in SQLite — races played/won, best/avg WPM, best/avg accuracy, total chars, total time, full history.
70
+ - **Daily challenge** — same quote for everyone each day, with a local daily leaderboard.
71
+ - **Polished TUI** built on **Textual** + **Rich**, keyboard-only, resize-aware.
72
+
73
+ ## Planned CLI
74
+
75
+ ```bash
76
+ typefaster # launch straight into the game
77
+ typefaster race --time 60 --ghost personal-best
78
+ typefaster race --ghost last
79
+ typefaster race --ghost random
80
+ typefaster daily
81
+ typefaster profile
82
+ typefaster stats
83
+ typefaster history
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Tech stack
89
+
90
+ **Client (Phase 1):** Python 3.11+, Typer, Rich, Textual, SQLite (stdlib), platformdirs.
91
+ **Server (Phase 2):** FastAPI, asyncio, WebSockets, Pydantic, Redis, Docker Compose.
92
+
93
+ ## Repository layout
94
+
95
+ ```
96
+ typefaster-cli/
97
+ ├── client/typefaster/ # CLI app: domain · services · infra · ui · net · assets
98
+ ├── server/app/ # FastAPI server: routers · ws · repositories · security
99
+ ├── shared/ # shared schemas, WS protocol, scoring, anti-cheat
100
+ ├── infra/ # redis.conf · nginx.conf (TLS + WS proxy)
101
+ ├── docs/ # architecture, schemas, protocol, deployment, roadmap
102
+ ├── tests/ # client unit · integration · UI smoke
103
+ ├── scripts/ # quote dataset tooling
104
+ ├── docker-compose.yml # redis + server (+ nginx via --profile proxy)
105
+ ├── pyproject.toml · Makefile · README.md
106
+ ```
107
+
108
+ See [`docs/architecture.md`](docs/architecture.md) for the full design.
109
+
110
+ ## Online play (Phase 2)
111
+
112
+ Run the server stack (Redis + FastAPI + WebSockets) with Docker:
113
+
114
+ ```bash
115
+ cp .env.example .env # set TYPEFASTER_JWT_SECRET
116
+ make up # redis + server on :8000 (make up-proxy adds nginx TLS)
117
+ ```
118
+
119
+ Then, from the client:
120
+
121
+ ```bash
122
+ typefaster register alice # create an account
123
+ typefaster login alice
124
+ typefaster lobby create --name "Friday Sprint" --time 60
125
+ typefaster lobby join ABC123 # join a friend's private lobby
126
+ typefaster lobby list # browse public lobbies
127
+ typefaster leaderboard global # global | daily | weekly
128
+ typefaster logout
129
+ ```
130
+
131
+ The server is **authoritative**: it controls race start/finish, re-scores every
132
+ result, and runs anti-cheat before writing leaderboards. See the docs:
133
+
134
+ - [API specification](docs/api-spec.md)
135
+ - [WebSocket protocol](docs/websocket-protocol.md)
136
+ - [Redis schema](docs/redis-schema.md)
137
+ - [Deployment guide (single Linux VM)](docs/deployment.md)
138
+
139
+ The client points at `http://localhost:8000` by default; set `server_url` in
140
+ `~/.config/typefaster/auth.json` to target a deployed server.
141
+
142
+ ## Development
143
+
144
+ ```bash
145
+ make install # editable install + dev deps
146
+ make play # launch the game
147
+ make test # pytest
148
+ make lint # ruff
149
+ make typecheck # mypy
150
+ make format # black + ruff --fix
151
+ make check # lint + typecheck + test (CI parity)
152
+ ```
153
+
154
+ > **Note on the monorepo layout:** the importable package lives at
155
+ > `client/typefaster`. A normal install (`pip install .`, used by Docker and end
156
+ > users) places it on the path automatically. For local development the
157
+ > `Makefile` exports `PYTHONPATH=client`, so `make play` / `make test` always
158
+ > work. If you invoke tools directly, prefix with `PYTHONPATH=client` (e.g.
159
+ > `PYTHONPATH=client python -m typefaster`).
160
+
161
+ ## Design preferences locked for Phase 1
162
+
163
+ - **Quotes:** curated public-domain set, tagged `short` / `medium` / `long` for difficulty buckets and 30/60/120s fit.
164
+ - **Backspace:** allowed (MonkeyType-style) — corrections permitted, original errors still count toward accuracy; exposed as a Settings toggle.
165
+
166
+ ## License
167
+
168
+ MIT.